- 1
- 2
- 3
- 4
- 5
- 6
- 7
/// <summary>
/// Converts an object to null. Returns null.
/// </summary>
public static object ToNull(this object value)
{
return null;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−1
/// <summary>
/// Converts an object to null. Returns null.
/// </summary>
public static object ToNull(this object value)
{
return null;
}
Индийский extension
0
var width = $(window).width(), check;
width > 950 ? check = true : check = false;
−2
template<typename ProcessT, typename... Args>
requires (!std::derived_from<ProcessT, Process<ProcessT>>)
ProcessT& startProcess(processing::Processor& processor, Args&&... args)
{
processor.template getProcess<ProcessT>(processor.template attach<ProcessT>(args...));
}
template<typename ProcessT, typename... Args>
requires std::derived_from<ProcessT, Process<ProcessT>>
ProcessT& startProcess(processing::Processor& processor, Args&&... args)
{
processor.template getProcess<ProcessT>(processor.template attach<ProcessT>(
static_cast<T*>(this)->entity, args...));
}
Ко мне вернулось вдохновение
−4
// first is information about the first byte in a UTF-8 sequence.
var first = [256]uint8{
// 1 2 3 4 5 6 7 8 9 A B C D E F
as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x00-0x0F
as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x10-0x1F
as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x20-0x2F
as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x30-0x3F
as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x40-0x4F
as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x50-0x5F
as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x60-0x6F
as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x70-0x7F
// 1 2 3 4 5 6 7 8 9 A B C D E F
xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, // 0x80-0x8F
xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, // 0x90-0x9F
xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, // 0xA0-0xAF
xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, // 0xB0-0xBF
xx, xx, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, // 0xC0-0xCF
s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, // 0xD0-0xDF
s2, s3, s3, s3, s3, s3, s3, s3, s3, s3, s3, s3, s3, s4, s3, s3, // 0xE0-0xEF
s5, s6, s6, s6, s7, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, // 0xF0-0xFF
}
как вы уже догадались, это у тэ эф восемь
"as" это as is
xx -- хуйня хуёвая
s1 -- size1 и пр
Такое вот табличное программирование
−1
#define BITS 8
typedef union
{
int v;
struct
{
#define FIELD(x,_) int b##x:1;
EVAL(REPEAT(BITS, FIELD, ~))
#undef FIELD
};
} Num;
Num shl(Num n, int carry)
{
#define SHIFTL(x,_) CAT(n.b, CAT(x = n.b, CAT(DEC_,x)));
EVAL(RREPEAT(BITS, SHIFTL, ~))
#undef SHIFTL
n.b0 = carry;
}
Num shr(Num n, int carry)
{
#define SHIFTR(x,_) CAT(n.b, CAT(CAT(DEC_,x) = n.b, x));
EVAL(REPEAT(BITS, SHIFTR, ~))
#undef SHIFTR
CAT(n.b, CAT(DEC_,BITS)) = carry;
}
int main()
{
for (int i=0; i<33; ++i){
Num n = {i};
Num n1 = shl(n,0);
Num n2 = shr(n,0);
printf("%d %d %d\n",n ,n1 , n2);
}
}
https://godbolt.org/z/48h6EWacY
Двунаправленный сдвиговый регистр на препроцессоре.
Сделан без использования арифметических действий.
0
// реализация интерфейса IArguments2 для самодельного скриптового движка, aka vbs to exe
unit Arguments;
interface
uses
Windows, ComObj, ActiveX, Stub_TLB, SysUtils,WSHNamedArguments,WSHUnNamedArguments, CmdUtils;
type
TIarguments=class(TAutoObject, IArguments2, IEnumVariant)
FAArgs:array of WideString;
FWSHNamedArguments:TIWSHNamedArguments;
FWSHUnNamedArguments:TIWSHUnNamedArguments;
function Item(Index: Integer): WideString; safecall;
function Count: Integer; safecall;
function Get_length: Integer; safecall;
function _NewEnum: IUnknown; safecall;
property length: Integer read Get_length;
function Get_Named: IWSHNamedArguments; safecall;
function Get_Unnamed: IWSHUnnamedArguments; safecall;
procedure ShowUsage; safecall;
property Named: IWSHNamedArguments read Get_Named;
property Unnamed: IWSHUnnamedArguments read Get_Unnamed;
function Next(celt: LongWord; var rgvar : OleVariant;
out pceltFetched: LongWord): HResult; stdcall;
function Skip(celt: LongWord): HResult; stdcall;
function Reset: HResult; stdcall;
function Clone(out Enum: IEnumVariant): HResult; stdcall;
public
constructor Create;
end;
implementation
uses ComServ;
var
FIndex:Integer=0;
{ TIarguments }
function TIarguments._NewEnum: IUnknown;
begin
Result:=self;
end;
function TIarguments.Count: Integer;
begin
Result:=System.Length(FAArgs);
end;
function TIarguments.Get_length: Integer;
begin
Result:=Count;
end;
function TIarguments.Item(Index: Integer): WideString;
begin
if (Index >= System.Length(FAArgs)) then
raise EOleSysError.Create('Range check error', HRESULT($800A0009),0)
else
Result:=FAArgs[Index]
end;
function TIarguments.Get_Named: IWSHNamedArguments;
begin
Result:=FWSHNamedArguments;
end;
function TIarguments.Get_Unnamed: IWSHUnnamedArguments;
begin
Result:=FWSHUnNamedArguments;
end;
procedure TIarguments.ShowUsage;
begin
OleError(E_NOTIMPL);
end;
constructor TIarguments.Create;
var
I,J, PCnt:Integer;
S, CmdLine:string;
begin
inherited Create;
FIndex:=0;
FWSHNamedArguments:=TIWSHNamedArguments.Create;
FWSHUnNamedArguments:=TIWSHUnNamedArguments.Create;
PCnt:=ParamCount;
SetLength(FAArgs, PCnt);
for I:=1 to PCnt do
begin
J:=I-1;
FAArgs[J]:=ParamStr(I);
end;
//Parsing named args.
CmdLine:='';
S:=GetCommandLine;
PCnt:=iParamCount(PChar(S));
if PCnt > 1 then
begin
for I:=1 to PCnt-1 do
begin
CmdLine:=CmdLine+iParamStr(PChar(S), I);
if I < PCnt-1 then
CmdLine:=CmdLine+' ';
end;
end;
0
// Takes a printf-style format string and returns a formatted string.
char *format(char *fmt, ...) {
char *buf;
size_t buflen;
FILE *out = open_memstream(&buf, &buflen);
va_list ap;
va_start(ap, fmt);
vfprintf(out, fmt, ap);
va_end(ap);
fclose(out);
return buf;
}
+1
if x == 2 or 3: # если x равен 2 или 3
print('Пыщь.')
Вот уже не впервый раз натыкаюсь на подобный "машинный перевод с русского на питон".
0
void pong_game(void)
{
/*Set the first random direction the ball will be traviling*/
direction=random_direction();
/*Play the game while the ESC key is not pressed*/
while(!key[KEY_ESC]) {
/*Move the Ball*/
move_ball();
/*Respond to the input*/
key_respond();
/*Put the information on the Screen*/
textout(buffer,pong_datafile[pong_text].dat,"Player 1 Score:",
150,0,254);
textout(buffer,pong_datafile[pong_text].dat,itoa(score_p1,NULL,10),
text_length(pong_datafile[pong_text].dat,
"Player 1 Score:")+150,0,10);
textout(buffer,pong_datafile[pong_text].dat,"Player 2 Score:",
350,0,254);
textout(buffer,pong_datafile[pong_text].dat,itoa(score_p2,NULL,10),
text_length(pong_datafile[pong_text].dat,
"Player 2 Score:")+350,0,10);
textout(buffer,pong_datafile[pong_text].dat,"keyboard",0,0,255);
textout(buffer,pong_datafile[pong_text].dat,"joystick",
640-text_length(pong_datafile[pong_text].dat,"joystick"),
0,255);
/*Draw a line to set the boundries*/
line(buffer,0,30,640,30,10);
/*Put the buffer screen on the screen*/
blit(buffer,screen,0,0,0,0,640,480);
/*Clear the buffer*/
clear(buffer);
}
return;
}
помните?
−4
Функция ПолучитьОсновногоБухгалтераПоОрганизации(организация) Экспорт
текстЗапроса = "
|ВЫБРАТЬ ПЕРВЫЕ 1
| ПользовательБухгалтер
|ИЗ
| РегистрСведений.СКАНИЯ_ОтветственныеБухгалтерыПоОрганизациям
|ГДЕ
| Организация = &организация
| И Основной = ИСТИНА
|";
запрос = Новый Запрос(текстЗапроса);
запрос.УстановитьПараметр("организация", организация);
выборка = запрос.Выполнить().Выбрать();
Если выборка.Следующий() Тогда
возврат выборка.ПользовательБухгалтер;
Иначе
возврат Справочники.Пользователи.ПустаяСсылка();
КонецЕсли;
КонецФункции