- 1
Давайте в жопу ебаться
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
Давайте в жопу ебаться
Давайте в жопу ебаться
0
#!/usr/bin/env instantfpc
program PrintCharTable;
const
space = ' '; { }
point = '.'; {.}
caret = '^'; {^}
vline = '|'; {│}
hline = '-'; {─}
cross = '+'; {┼}
hex_0 = ord('0');
hex_a = ord('A')-10;
function tohex(d: integer): char;
begin
if d < 10 then
tohex := chr(d+hex_0)
else
tohex := chr(d+hex_a)
end;
var
i, j: integer;
code: integer;
begin
write(space, space, vline);
for i := 0 to 15 do
write(space, point, tohex(i));
writeln;
write(hline, hline, cross);
for i := 0 to 15 do
write(hline, hline, hline);
writeln;
for i := 0 to 15 do begin
write(tohex(i), point, vline);
for j := 0 to 15 do begin
code := i * 16 + j;
if code < 32 then
write(space, caret, chr(code+64))
else if code = 127 then
write(space, caret, chr(code-64))
else
write(space, space, chr(code))
end;
writeln
end
end.
{
$ ./print_ascii.pas | iconv -f koi8-r
| .0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .A .B .C .D .E .F
--+------------------------------------------------
0.| ^@ ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O
1.| ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^\ ^] ^^ ^_
2.| ! " # $ % & ' ( ) * + , - . /
3.| 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
4.| @ A B C D E F G H I J K L M N O
5.| P Q R S T U V W X Y Z [ \ ] ^ _
6.| ` a b c d e f g h i j k l m n o
7.| p q r s t u v w x y z { | } ~ ^?
8.| ─ │ ┌ ┐ └ ┘ ├ ┤ ┬ ┴ ┼ ▀ ▄ █ ▌ ▐
9.| ░ ▒ ▓ ⌠ ■ ∙ √ ≈ ≤ ≥ ⌡ ° ² · ÷
A.| ═ ║ ╒ ё ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞
B.| ╟ ╠ ╡ Ё ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ©
C.| ю а б ц д е ф г х и й к л м н о
D.| п я р с т у ж в ь ы з ш э щ ч ъ
E.| Ю А Б Ц Д Е Ф Г Х И Й К Л М Н О
F.| П Я Р С Т У Ж В Ь Ы З Ш Э Щ Ч Ъ
}
Печатает таблицу нужной кодировки. Пример использования в комменте после end.
0
program square;
var sep, input: string;
i, j, n, m : integer;
begin
write('sep:');
readln(sep);
write('str:');
readln(input);
for i:=1 to length(input) do write(input[i], ' ');
writeln();
for i:=2 to length(input)-1 do begin
write(input[i]);
for j:=1 to length(input)*2-3 do write (sep);
writeln(input[length(input) - i + 1]);
end;
for i:=0 to length(input)-1 do
write(input[length(input)-i], ' ');
end.
Написала на скучной лекции программку на телефоне, чтобы распечатывать
Х У Й
У У
Й У Х
0
type
.....
TSyncParamsPasser = class
PassedJSON:String;
constructor Create(RJS:String);
procedure ProcessExternalCmd;
end;
.....
.....
procedure TForm1.TCPServerExecute(AContext: TIdContext);
begin
.....
SyncParamsPasser:=TSyncParamsPasser.Create(CustomData);
TIdSync.SynchronizeMethod(SyncParamsPasser.ProcessExternalCmd);
FreeAndNil(SyncParamsPasser);
.....
end;
.....
constructor TSyncParamsPasser.Create(RJS:String);
begin
PassedJSON:=RJS;
end;
procedure TSyncParamsPasser.ProcessExternalCmd;
var
JSON:TJSONObject;
begin
JSON:=TJSONObject.ParseJSONValue(PassedJSON) as TJSONObject;
.....
Событие OnExecute компонента TCPServer вызывается из рабочего потока, в котором обрабатывается входящее подключение.
Способ передачи параметров в процедуру, выполняющуюся внутри Synchronize, с помощью класса.
Говно или сойдёт?
0
procedure ProgramRestart(Sender: TObject);
begin
Application.Terminate;
ShellExecute(0,'open',Application.ExeName,'','',SW_NORMAL); // ))
end;
Неделю когда-то пытался понять почему этот код не работает: "Я же программу вырубил? - вырубил... Я же ее запускаю? - запускаю... А че она не запускается?)))..."
0
// добавляем новые ссылки
for i := 0 to ATags.Count - 1 do
begin
// так мне кажется лучше
Application.ProcessMessages;
кому или чему лучше кроме тебя, автор ?
0
procedure TWorker.handleAdminClient(socket: TTCPBlockSocket; json: ISuperObject);
var
msg: ansistring;
request: SOString;
//s: ISuperObject;
res: ISuperObject;
begin
res := json['data'];
msg := json['func'].AsString;
if msg = 'deletemarket' then
begin
database.deleteMarket(res.GetS('id'));
msg:='getmarkets';
end;
if msg = 'addmarket' then
begin
database.addMarket(res.GetS('mapid'),res.GetS('name'),res.GetS('type_id'));
msg:='getmarkets';
end;
if msg = 'setmarketitems' then
begin
database.setMarktItems(res.GetS('id'),res.GetA('items'));
TSocketSender.sendStr(socket, '{"type":"' + msg + '","data":{"id":' + res.GetS('id') + '}}');
exit;
end;
if msg = 'updatemarket' then
begin
database.updateMarkt(res.GetS('id'),res.GetS('name'),res.GetS('enabled'));
TSocketSender.sendStr(socket, '{"type":"' + msg + '","data":{"id":' + res.GetS('id') + '}}');
exit;
end;
if msg = 'getmarktitems' then
begin
request := database.getMarktItems(res.GetS('id'));
TSocketSender.sendStr(socket, '{ "type" : "' + msg + '" , "data" : ' + request + '}');
exit;
end;
if msg = 'getmarkets' then
begin
request := database.getMarkets();
TSocketSender.sendStr(socket, '{ "type" : "' + msg + '" , "data" : ' + request + '}');
exit;
end;
if msg = 'getmarkettypes' then
begin
request := database.getMarketTypes();
TSocketSender.sendStr(socket, '{ "type" : "' + msg + '" , "data" : ' + request + '}');
exit;
end;
if msg = 'getitems' then
begin
request := database.getAdminItems();
TSocketSender.sendStr(socket, '{ "type" : "' + msg + '" , "data" : ' + request + '}');
exit;
end;
if msg = 'getitemstypes' then
begin
request := database.getAdminItemsTypes();
TSocketSender.sendStr(socket, '{ "type" : "' + msg + '" , "data" : ' + request + '}');
exit;
end;
if msg = 'getitem' then
begin
request := database.getItem(res['itemid'].AsInteger).getJSON.AsString;
TSocketSender.sendStr(socket, '{ "type" : "' + msg + '" , "data" : ' + request + '}');
exit;
end;
if msg = 'additem' then
begin
request := database.addItem(res);
TSocketSender.sendStr(socket, '{ "type" : "' + msg + '" , "data" : ' + request + '}');
exit;
end;
if msg = 'setitem' then
begin
database.setItem(res);
exit;
end;
if msg = 'getavatar' then
begin
getAvatar(socket);
exit;
end;
if msg = 'acceptavatar' then
begin
acceptAvatar(res);
exit;
end;
if msg = 'declineavatar' then
begin
declineAvatar(res);
exit;
end;
if msg = 'admindata' then
begin
sendAdminData(socket);
exit;
Ужаснитесь.
0
Я обычный козоёб из Осетии.
0
Type
ONETWO = 1 .. 2;
var I: ONETWO;
begin
I:=1;
I:=I+1;
writeln(I); //2
I:=1+I;
writeln(I); //3
inc(I);
writeln(I); //4
inc(I);
writeln(I); //5
end.
https://ideone.com/mtmPPq
Всё что нужно знать о продвинутой тупизации в «Паскале».
0
begin
G4.Caption:='X';
if G5.Caption='' then
begin
G5.Caption:='X';
if G6.Caption='' then
begin
G6.Caption:='X';
if G7.Caption='' then
begin
G7.Caption:='X';
if G8.Caption='' then G8.Caption:='X' else
if sg8=1 then
G8.Font.Style:=[fsBold,fsStrikeOut];
end else
if sg7=1 then
G7.Font.Style:=[fsBold,fsStrikeOut];
end else
if sg6=1 then
G6.Font.Style:=[fsBold,fsStrikeOut];
end else
if sg5=1 then
G5.Font.Style:=[fsBold,fsStrikeOut];
end else
if sg4=1 then
G4.Font.Style:=[fsBold,fsStrikeOut];
end else
if sg3=1 then
G3.Font.Style:=[fsBold,fsStrikeOut];
end else
if sg2=1 then
G2.Font.Style:=[fsBold,fsStrikeOut];
if H2.Caption='' then H2.Caption:='X' else
if sh2=1 then H2.Font.Style:=[fsBold,fsStrikeOut];
if F2.Caption='' then
begin
F2.Caption:='X';
if E3.Caption='' then
begin
E3.Caption:='X';
if D4.Caption='' then
begin
D4.Caption:='X';
if C5.Caption='' then
begin
C5.Caption:='X';
if B6.Caption='' then
begin
B6.Caption:='X';
if A7.Caption='' then A7.Caption:='X' else
if sa7=1 then
A7.Font.Style:=[fsBold,fsStrikeOut];
end else
if sb6=1 then
B6.Font.Style:=[fsBold,fsStrikeOut];
end else
if sc5=1 then
C5.Font.Style:=[fsBold,fsStrikeOut];
end else
if sd4=1 then
D4.Font.Style:=[fsBold,fsStrikeOut];
end else
if se3=1 then
E3.Font.Style:=[fsBold,fsStrikeOut];
end else
if sf2=1 then
F2.Font.Style:=[fsBold,fsStrikeOut];
end;
6: begin //Король
{E1} if ((se1=1) and not ((E1.Caption<>'Ферзь') or (E1.Caption<>'Ладья') or (E1.Caption<>'Король')) or
{D1} ((sd1=1) and not ((E1.Caption='') and ((D1.Caption='Ферзь') or (D1.Caption='Ладья')))) or
{C1} ((sc1=1) and not (((E1.Caption='') and (D1.Caption='')) and ((C1.Caption='Ферзь') or (C1.Caption='Ладья')))) or
{B1} ((sb1=1) and not (((E1.Caption='') and (D1.Caption='') and (C1.Caption='')) and ((B1.Caption='Ферзь') or (B1.Caption='Ладья')))) or
{A1} ((sa1=1) and not (((E1.Caption='') and (D1.Caption='') and (C1.Caption='') and (B1.Caption='')) and ((A1.Caption='Ферзь') or (A1.Caption='Ладья')))) or
{E2} ((se2=1) and not ((E2.Caption='Слон') or (E2.Caption='Ферзь') or (E2.Caption='Пешка') or (E2.Caption='Король'))) or
//ПРОДОВЖИТИ
{D3} ((sd3=1) and not ((E2.Caption='') and ((D3.Caption='Ферзь') or (D3.Caption='Слон')))) or
{C4} ((sc4=1) and not (((E2.Caption='') and (D3.Caption='')) and ((C4.Caption='Ферзь') or (C4.Caption='Слон')))) or
{B5} ((sb5=1) and not (((E2.Caption='') and (D3.Caption='') and (C4.Caption='')) and ((B5.Caption='Ферзь') or (B5.Caption='Слон')))) or
{A6} ((sa6=1) and not (((E2.Caption='') and (D3.Caption='') and (C4.Caption='') and (B5.Caption='')) and ((A6.Caption='Ферзь') or (A6.Caption='Ладья')))) or
{F2} ((sf2=1) and not (E2.Caption='Ладья') or (E2.Caption='Ферзь')) or
{F3} ((sf3=1) and not ((F2.Caption='') and ((F3.Caption='Ферзь') or (F3.Caption='Ладья')))) or
{F4} ((sf4=1) and not (((F2.Caption='') and (F3.Caption='')) and ((F4.Caption='Ферзь') or (F4.Caption='Ладья')))) or
{F5} ((sf5=1) and not (((F2.Caption='') and (F3.Caption='') and (F4.Caption='')) and ((F5.Caption='Ферзь') or (F5.Caption='Ладья')))) or
{F6} ((sf6=1) and not (((F2.Caption='') and (F3.Caption='') and (F4.Caption='') and (F5.Caption='')) and ((F6.Caption='Ферзь') or (F6.Caption='Ладья')))) or
{F7} ((sf7=1) and not (((F2.Caption='') and (F3.Caption='') and (F4.Caption='') and (F5.Caption='') and (F6.Caption='')) and ((F7.Caption='Ферзь') or (F7.Caption='Ладья')))) or
{F8} ((sf8=1) and not (((F2.Caption='') and (F3.Caption='') and (F4.Caption='') and (F5.Caption='') and (F6.Caption='') and (F7.Caption='')) and ((F8.Caption='Ферзь') or (F8.Caption='Ладья')))) or
{G2} ((sg2=1) and not (G2.Caption='Ферзь') or (G2.Caption='Слон')) or
{H3} ((sh3=1) and not ((G2.Caption='') and ((H3.Caption='Ферзь') or (H3.Caption='Слон')))) or
{H1} ((sh1=1) and not (H1.Caption'Ферзь') or (H1.Caption='Слон')) or
{Кони} ((sh2=1) and not (H2.Caption='Конь')) or ((sg3=1) and not (G3.Caption='Конь')) or ((se3=1) and not (E3.Caption='Конь')) or ((sd2=1) and not(D2.Caption='Конь'))
) then if (F1.Caption='') then F1.Caption:='X' else
if sf1=1 then F1.Font.Style:=[fsBold,fsStrikeOut];
end;
Как-то на первом или втором курсе недоунивера возникло желание сделать шахматы в ООП на Паскале. Решил закодить 64 кнопки (8*8 поле). Сделал переменные для идентификации хода черных/белых, для 2 режимов, в первом из которых кликаешь на свою фигуру (надпись на кнопке) и тебе показывают доступные ходы ею (Х куда можно поставить фигуру, подчеркнутое название вражеской фигуры при возможность её забрать). Ты кликаешь, поле очищается от подсказок, фигура перемещается, проверка на шах/мат (ад), ход передается другому цвету фигур (Жирное начертание для определения) и режим взаимодействия с игровым полем опять переходит в выбор фигуры. Теоретически закодировав каждую кнопку на все возможные события шахматы были бы закончены полностью. Вот только спустя окончания кодировки первой кнопки я заYAYлся и забросил ибо говнокод вышел в 1000 строк на одну YAYдь кнопку. Разумеется, показать могу лишь часть