- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
struct Point3D {
float x,y,z;
float& operator [] (int i) {
switch (i) {
case 0: return x;
case 1: return y;
case 2: return z;
default: assert(false);
}
}
};
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+15
struct Point3D {
float x,y,z;
float& operator [] (int i) {
switch (i) {
case 0: return x;
case 1: return y;
case 2: return z;
default: assert(false);
}
}
};
Писал Жабапоглащенный.
+23
const Tifon& Tifon::operator=(const Tifon& Buffer)
{
assert(&Buffer!=this);
if(&Buffer==this)
return *this;
Tifon OldForExceptionSafe(*this);
try{
this->~Tifon();
::new((void*)this)Tifon(Buffer);
}catch(...){//try restore
::new((void*)this)Tifon(OldForExceptionSafe);
}
return *this;
};
//...
namespace std
{
const Tifon&swap (Tifon& a, Tifon& b) {
assert(&a!=&b);
if(&a==&b)
return a;
Tifon c(a);
a=b;
b=c;
}
};
+111
var
s:string;
begin
repeat
readln(s);
until
(length(s)=4)
and(
(s[1]='1')
or(s[1]='2')
or(s[1]='3')
or(s[1]='4')
or(s[1]='5')
or(s[1]='6')
or(s[1]='7')
or(s[1]='8')
or(s[1]='9')
)
and(
(s[2]='1')
or(s[2]='2')
or(s[2]='3')
or(s[2]='4')
or(s[2]='5')
or(s[2]='6')
or(s[2]='7')
or(s[2]='8')
or(s[2]='9')
or(s[2]='0')
)
and(
(s[3]='1')
or(s[3]='2')
or(s[3]='3')
or(s[3]='4')
or(s[3]='5')
or(s[3]='6')
or(s[3]='7')
or(s[3]='8')
or(s[3]='9')
or(s[3]='0')
)
and(
(s[4]='1')
or(s[4]='2')
or(s[4]='3')
or(s[4]='4')
or(s[4]='5')
or(s[4]='6')
or(s[4]='7')
or(s[4]='8')
or(s[4]='9')
or(s[4]='0')
)
end.
Нашёл у себя из первого курса.
+107
function HexToInt(s: string): integer;
label
gte;
var
tempt: string;
i: integer;
begin
tempt := '';
if s = '' then
begin
HexToInt := 0;
goto gte;
end;
for i := 1 to Length(s) do
begin
tempt := tempt + IntToHex(Ord(s[i]), 2);
end;
HexToInt := StrToInt('$' + tempt);
gte:
end;
Ряд гениальных решений из-за незнания особенностей языка.
Честно взято с: http://www.delphisources.ru/pages/faq/base/hex_to_int.html
Честно написано автором: Перегинец Иваном ( [email protected] )
−3
Блять, какое же lua говно блять...
0
Fixpoint mint_add0 {N} (i k : Fin.t N) te_i te' t0 vec
(Ht : MInt nonCommRel N k vec (te' :: t0))
(Hik : k < i)
(Hcomm0 : trace_elems_commute te_i te')
{struct Ht} :
exists t' : list TE,
MInt nonCommRel N k (vec_append i te_i vec) (te' :: t') /\
Permutation trace_elems_commute (te_i :: te' :: t0) (te' :: t').
Proof with eauto.
(* Welcome to the hell proof! *)
remember (te' :: t0) as t_.
destruct Ht as [k
|k j vec te_k t Hij Ht
|k j vec te_k te_j t Hij Hcomm Ht
];
[discriminate
|replace te' with te_k in * by congruence; clear Heqt_..
].
2:{ destruct (trace_elems_commute_dec te_i te_j).
- apply mint_add0 with (te_i := te_i) (i := i) in Ht; [|lia|assumption].
destruct Ht as [t' [Ht' Hperm']].
exists (te_j :: t'). split.
+ swap_vec_append.
eapply mint_cons2...
+ apply permut_cons with (a := te_k) in Hperm'.
eapply permut_trans...
now apply permut_head'.
- exists (te_i :: te_j :: t). split.
+ swap_vec_append.
apply mint_cons1 with (j0 := i); [lia|].
apply mint_cons2 with (j0 := j); [lia|auto..].
+ now apply permut_head'.
}
{ inversion_ Ht.
- exists [te_i]. split.
+ swap_vec_append.
apply mint_cons1 with (j0 := i); [lia|].
apply mint_cons1 with (j0 := i); [lia|].
constructor.
+ now apply permut_head'.
- rename te into te_j.
destruct (PeanoNat.Nat.lt_ge_cases j i).
2:{ exists (te_i :: te_j :: t1). split.
- swap_vec_append.
apply mint_cons1 with (j1 := i); [lia|].
apply mint_cons1 with (j1 := j); [lia|assumption].
- now apply permut_head'.
}
{ destruct (trace_elems_commute_dec te_i te_j) as [Hte_ij|Hte_ij].
- apply mint_add0 with (i := i) (te_i := te_i) in Ht; [|lia|assumption].
destruct Ht as [t' [Ht' Hperm']].
exists (te_j :: t'). split.
+ swap_vec_append.
eapply mint_cons1...
+ apply permut_cons with (a := te_k) in Hperm'.
now apply permut_head.
- exists (te_i :: te_j :: t1). split.
+ swap_vec_append.
apply mint_cons1 with (j1 := i); [lia|].
apply mint_cons2 with (j1 := j); [lia|assumption..].
+ apply permut_head; [assumption|constructor].
}
- rename j0 into i0. cbn in H0.
destruct (PeanoNat.Nat.lt_ge_cases j i).
2:{ exists (te_i :: te_i0 :: te_j :: t1). split.
+ swap_vec_append.
apply mint_cons1 with (j0 := i); [lia|].
apply mint_cons1 with (j0 := j); [lia|assumption].
+ now apply permut_head'.
}
{ destruct (trace_elems_commute_dec te_i te_i0).
- apply mint_add0 with (i := i) (te_i := te_i) in Ht; [|lia|assumption].
destruct Ht as [t' [Ht' Hperm']].
exists (te_i0 :: t'). split.
+ swap_vec_append.
eapply mint_cons1...
+ apply permut_cons with (a := te_k) in Hperm'.
now apply permut_head.
- exists (te_i :: te_i0 :: te_j :: t1). split.
+ swap_vec_append.
apply mint_cons1 with (j0 := i); [lia|].
apply mint_cons2 with (j0 := j); [lia|assumption..].
+ apply permut_head.
* assumption.
* constructor.
}
}
Qed.
Мой magnum opus. Часть доказательства про выкидывание из рассмотрения коммутирующих системных вызовов.
+3
/**
* formHostnameRule: правило, проверяющее имя хоста
*
* @package system
* @subpackage forms
* @version 0.1.1
*/
class formHostnameRule extends formAbstractRule
{
private $validTlds = array(
'ac', 'ad', 'ae', 'aero', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao',
'aq', 'ar', 'arpa', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb',
'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'biz', 'bj', 'bm', 'bn', 'bo',
'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cat', 'cc', 'cd',
'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'com', 'coop',
'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do',
'dz', 'ec', 'edu', 'ee', 'eg', 'er', 'es', 'et', 'eu', 'fi', 'fj',
'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh',
'gi', 'gl', 'gm', 'gn', 'gov', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu',
'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il',
'im', 'in', 'info', 'int', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm',
'jo', 'jobs', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kr', 'kw',
'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu',
'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mil', 'mk', 'ml', 'mm',
'mn', 'mo', 'mobi', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'museum', 'mv',
'mw', 'mx', 'my', 'mz', 'na', 'name', 'nc', 'ne', 'net', 'nf', 'ng',
'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'org', 'pa', 'pe',
'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'pro', 'ps', 'pt',
'pw', 'py', 'qa', 're', 'ro', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd',
'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr',
'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj',
'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'travel', 'tt', 'tv', 'tw',
'tz', 'ua', 'ug', 'uk', 'um', 'us', 'uy', 'uz', 'va', 'vc', 've',
'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'yu', 'za', 'zm',
'zw'
);
https://github.com/wiistriker/govnokod_legacy/blob/master/mzz/system/forms/validators/formHostnameRule.php
Кажется, я эту хуйню уже выкладывал, но да ладно, похуй: это говнище достойно даже повторной публикации здесь. Проебал из-за какой-то древней тупой пхп-макаки деньги за домен!
+1
def fake_bin(x):
k = ''
while len(x) > 0:
if int(x) % 10 >= 5:
k += '1'
x = x[0:-1]
else:
k += '0'
x = x[0:-1]
return k[::-1]
0
--Запрос в яндекс за спичером
function thstart(text)
local th = [[
love.filesystem.remove("tmp.ogg");
local str = ...
local encodeURI = function(str)
if (str) then
str = string.gsub (str, "\n", "\r\n")
str = string.gsub (str, "([^%w ])",
function (c) return string.format ("%%%02X", string.byte(c)) end)
str = string.gsub (str, " ", "+")
end
return str
end
str = encodeURI(str)
local http = require("socket.http");
body = http.request("https://tts.voicetech.yandex.net/generate?text="..str.."&format=mp3&lang=ru-RU&speaker=kolya&emotion=evil&key=069b6659-984b-4c5f-880e-aaedcfd84102&speed=0.8")
if body then
love.filesystem.write("tmp.mp3",body)
love.thread.getChannel('im'):push("tmp.mp3")
else
love.thread.getChannel('im'):push("err")
end
--love.thread.getChannel('im'):push("err")
]]
tred = nil
tred = love.thread.newThread(th);
tred:start(text);
end
function thpop()
local info = love.thread.getChannel( 'im' ):pop()
if info then
if info == "err" then
return "err"
else
return info
end
end
return nil
end
+322
void worker(int id)
{
while (true) {
std::unique_lock<std::mutex> lock(connPoolMutex);
connPoolCond.wait(lock, [] { return !connectionsPool.empty(); });
ClientConnection conn = connectionsPool.front();
connectionsPool.pop();
lock.unlock();
TCPSocket sock(conn);
sock.setReadTimeout(READ_TIMEOUT);
char buffer[MAX_PACKET_LEN] = {};
int sz = sock.recv(buffer, sizeof(buffer));
// [...]
}
}
// [...]
int main()
{
// [...]
TCPSocket server("0.0.0.0:1234");
server.bind();
server.listen(1000);
while (true) {
ClientConnection conn = server.accept();
std::unique_lock<std::mutex> l(connPoolMutex);
connectionsPool.push(conn);
connPoolCond.notify_one();
}
}
Современный, многопоточный и масштабируемый сервер на C++!
TCPSocket - очень тонкая обёртка над голым сокетом.