- 1
Именно поэтому я за «PHP» #4
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
Именно поэтому я за «PHP» #4
#1: https://govnokod.ru/26462 https://govnokod.xyz/_26462
#2: https://govnokod.ru/26827 https://govnokod.xyz/_26827
#3: https://govnokod.ru/26832 https://govnokod.xyz/_26832
+1
namespace Ifaces {
interface IFoo {
foo(): number;
}
}
class Cls1 implements Ifaces.IFoo
{
foo(): number
{
print("Hello");
return 1;
}
}
function main()
{
const cls1 = new Cls1();
cls1.foo();
const ifoo: Ifaces.IFoo = cls1;
ifoo.foo();
}
Алилуя. я вам интерфейсы принес... узрите теперь дампик
+1
class Solution {
public:
std::vector<std::vector<int>> diagonalSort(std::vector<std::vector<int>> & mat) {
if (!mat.size()) return mat;
const size_t rl = mat[0].size();
const size_t cl = mat.size();
sort(mat, rl, cl, 0, 0);
for (size_t i = 1; i < rl; ++i) {
sort(mat, rl, cl, 0, i);
}
for (size_t i = 1; i < cl; ++i) {
sort(mat, rl, cl, i, 0);
}
return mat;
}
private:
void sort(std::vector<std::vector<int>> & mat, size_t rl, size_t cl, size_t i, size_t j) {
const size_t len = std::min(rl - j, cl - i);
const size_t endj = j + len;
const size_t endi = i + len;
std::sort(diag_iter<false>{&mat, i, j}, diag_iter<false>{&mat, endi, endj});
}
template <bool isConst>
class diag_iter {
std::vector<std::vector<int>> *base;
size_t i, j;
using T = int;
public:
using iterator_category = std::forward_iterator_tag;
using difference_type = std::ptrdiff_t;
using value_type = T;
using pointer = T*;
using reference = typename std::conditional<isConst, const T&, T&>::type;
diag_iter(std::vector<std::vector<int>> *base, size_t i, size_t j) : base(base), i(i), j(j) { }
diag_iter(const diag_iter&) = default;
diag_iter& operator=(const diag_iter&) = default;
~diag_iter() = default;
reference operator*() const { return (*base)[i][j]; }
diag_iter& operator++() { i++; j++; return *this; }
friend bool operator== (const diag_iter& a, const diag_iter& b) { return a.i == b.i && a.j == b.j; };
friend bool operator!= (const diag_iter& a, const diag_iter& b) { return !(a == b); };
pointer operator->() const { return &(this->operator*()); }
diag_iter operator++(int) { diag_iter tmp = *this; ++(*this); return tmp; }
diag_iter() = default;
diag_iter& operator--() { i--; j--; return *this; }
diag_iter operator--(int) { diag_iter tmp = *this; --(*this); return tmp; }
diag_iter& operator+=(difference_type n) { i += n; j += n; return *this; }
friend diag_iter operator+(diag_iter it, difference_type n) { return it += n; }
diag_iter& operator-=(difference_type n) { i -= n; j -= n; return *this; }
diag_iter operator-(difference_type n) const { return diag_iter(*this) -= n; }
friend difference_type operator-(const diag_iter& a, const diag_iter& b) { return (b.j * b.base->size() + b.i) - (a.j * a.base->size() + a.i); }
reference operator[](difference_type n) const { return *(*this + n); }
friend bool operator<(const diag_iter& a, const diag_iter& b) { return b - a > 0; }
friend bool operator>(const diag_iter& a, const diag_iter& b) { return b < a; }
friend bool operator>=(const diag_iter& a, const diag_iter& b) { return !(a < b); }
friend bool operator<=(const diag_iter& a, const diag_iter& b) { return !(a > b); }
};
};
https://leetcode.com/problems/sort-the-matrix-diagonally/
Сортировка через итераторы оказалась примерно в три раза медленнее, чем через копирование в вектор, сортировку его и копирование обратно.
+1
#include <iostream>
#include <functional>
#define STD_FUNCTION(a, ...) typeof( a (*) __VA_ARGS__ )
template<typename T>
T do_op_t(T a, T b, STD_FUNCTION(T,(T,T)) op)
{
return op(a,b);
}
template
<
typename T,
STD_FUNCTION(
T,
(
T,T,
STD_FUNCTION(
T,
(T,T)
)
)
) F1,
STD_FUNCTION(
T,
(T,T)
) F2
>
T do_op_spec(T a, T b)
{
return F1(a, b, F2);
}
int add(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
std::function<int(int,int)> fnc = \
do_op_spec\
<
int,
do_op_t<int>,
add
>;
int main()
{
std::cout << do_op_t<int>(9, 9, add) << "\n";
std::cout << do_op_t<int>(9, 9, mul) << "\n";
std::cout << do_op_spec<int, do_op_t<int>,add>(9,9) << "\n";
std::cout << do_op_spec<int, do_op_t<int>,mul>(9,9) << "\n";
std::cout << fnc(9,9) << "\n";
}
Какая крестопараша )))
+1
Dictionary<Tuple<MapOfRestoredOwnership, bool, bool, bool>, IDictionary<PropertySqlGeography, IEnumerable<LandConsolidationData>>> villages
Parameter for function...
+1
func (c *Client) DeleteFile(filename string) {
_, err := s3.New(c.session).DeleteObject(&s3.DeleteObjectInput{
Bucket: aws.String(c.bucket),
Key: aws.String(filename),
})
if err != nil {
return
}
}
Ошибочка обработана
+1
/* В отдельном файле */
function Skif_Email(auth,em) {
em = em.substring(3,em.length-3);
auth = auth.substring(4,auth.length-4);
document.write('<a href="mailto:',em,'" title="Защищён от спам-роботов">',auth,'</a>');
}
/* На странице */
<script type="text/javascript">Skif_Email('[email protected]', '[email protected]');</script>
Какая защита )))
+1
// https://github.com/shanecoughlan/OpenGEM/blob/ac06b1a3fec3f3e8defcaaf7ea0338c38c3cef46/source/OpenGEM-7-RC3-SDK/OpenGEM-7-SDK/GEM%20AES%20AND%20SOURCE%20CODE/FreeGEM%20AES%203.0%20(source%20code)/GEMEVLIB.C#L143
/*
* Do a multi-wait on the specified events.
*/
WORD
ev_multi(flags, pmo1, pmo2, tmcount, buparm, mebuff, prets)
REG WORD flags;
REG MOBLK *pmo1;
MOBLK *pmo2;
LONG tmcount;
LONG buparm;
LPVOID mebuff;
WORD prets[];
{
QPB m;
REG EVSPEC which;
REG WORD what;
REG CQUEUE *pc;
#if MULTIAPP
WORD evbuff[8];
WORD pid;
SHELL *psh;
LONG ljunk;
pid = rlr->p_pid;
psh = &sh[pid];
if ( psh->sh_state & SHRINK ) /* shrink accessory */
{
if (pr_shrink(pid, TRUE, &ljunk, &ljunk))
ap_exit(TRUE); /* if no swap space terminate acc */
psh->sh_state &= ~SHRINK;
}
#endif
/* say nothing has */
/* happened yet */
what = 0x0;
/* do a pre-check for a */
/* keystroke & then */
/* clear out the forkq*/
chkkbd();
forker();
/* a keystroke */
if (flags & MU_KEYBD)
{
/* if a character is */
/* ready then get it */
pc = &rlr->p_cda->c_q;
if ( pc->c_cnt )
{
prets[4] = (UWORD) dq(pc);
what |= MU_KEYBD;
}
}
/* if we own the mouse */
/* then do quick chks */
if ( rlr == gl_mowner )
{
/* quick check button */
if (flags & MU_BUTTON)
{
if ( (mtrans > 1) &&
(downorup(pr_button, buparm)) )
{
what |= MU_BUTTON;
prets[5] = pr_mclick;
}
else
{
if ( downorup(button, buparm) )
{
what |= MU_BUTTON;
prets[5] = mclick;
}
}
}
/* quick check mouse rec*/
if ( ( flags & MU_M1 ) &&
( in_mrect(pmo1) ) )
what |= MU_M1;
/* quick check mouse rec*/
if ( ( flags & MU_M2 ) &&
( in_mrect(pmo2) ) )
what |= MU_M2;
}
/* quick check timer */
if (flags & MU_TIMER)
{
if ( tmcount == 0x0L )
what |= MU_TIMER;
}
/* quick check message */
if (flags & MU_MESAG)
{
if ( rlr->p_qindex > 0 )
{
#if MULTIAPP
ap_rdwr(MU_MESAG, rlr, 16, ADDR(&evbuff[0]) );
#endif
#if SINGLAPP
Уххх бля
+1
async Create(id, subscribe_yyyymmdd) {
const query = "INSERT INTO users(id,subscribe_yyyymmdd) VALUES ($1,$2) RETURNING *";
const values = [id, subscribe_yyyymmdd];
try {
const result = await this.db.query(query, values);
return result.rows[0].id;
} catch (error) {
this.logger.error(error);
}
},
async Update() {
const query = "UPDATE users SET subscribe_yyyymmdd = $1 where id=$2 RETURNING *";
const values = [id, subscribe_yyyymmdd];
try {
const result = await this.db.query(query, values);
return result.rows[0].id;
} catch (error) {
this.logger.error(error);
}
},
Из https://vk.com/wall521764930_6553 .
+1
import std.stdio;
template GenMix()
{
const char[] GenMix =
"template GenMix2()" ~
"{" ~
" const char[] GenMix2 = \"writeln(\\\"Hello, Wandbox!\\\");\";" ~
"};";
}
template MixMix(string Name)
{
const char[] MixMix = "mixin(" ~ Name ~ "!());";
}
mixin(GenMix!());
void main()
{
mixin(GenMix2!());
mixin(MixMix!("GenMix2"));
}
https://wandbox.org/permlink/1HpjfgrgVLyBSrXG
ГОМОИКОННОСТЬ в D