- 1
- 2
- 3
#if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE)
#define main SDL_main
#endif
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+17
#if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE)
#define main SDL_main
#endif
Боже, за что??!
http://hg.libsdl.org/SDL/file/75726efbf679/include/SDL_main.h
+135
(***************************************************************************
_____ _ _ __ __ _ _ _____
/ ____| | (_) \ \ / / | | | | | __ \
| | ___ __| |_ _ __ __ \ \ /\ / /__ _ __| | __| | | |__) | _
| | / _ \ / _` | | '_ \ / _` \ \/ \/ / _ \| '__| |/ _` | | _ / | | |
| |___| (_) | (_| | | | | | (_| |\ /\ / (_) | | | | (_| |_| | \ \ |_| |
\_____\___/ \__,_|_|_| |_|\__, | \/ \/ \___/|_| |_|\__,_(_)_| \_\__,_|
__/ |
|___/
*****************************************************************************)
(*****************************************************************************
Автор программы - CraftR14
Исходники предоставлены для форума CodingWorld.Ru
*****************************************************************************)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
gsvThread, idhttp, Spin, ShellAPI, Menus, CoolTrayIcon, Dialogs,
ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
SpinEdit1: TSpinEdit;
Button1: TButton;
Memo2: TMemo;
Label5: TLabel;
Label6: TLabel;
Timer1: TTimer;
SpinEdit2: TSpinEdit;
Label1: TLabel;
Label4: TLabel;
Label2: TLabel;
Label3: TLabel;
Button2: TButton;
Button3: TButton;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
Button4: TButton;
Button5: TButton;
GroupBox3: TGroupBox;
GroupBox4: TGroupBox;
Label7: TLabel;
Label8: TLabel;
GroupBox5: TGroupBox;
SaveDialog1: TSaveDialog;
OpenDialog1: TOpenDialog;
Bevel1: TBevel;
Button6: TButton;
CoolTrayIcon1: TCoolTrayIcon;
PopupMenu1: TPopupMenu;
PopupMenu2: TPopupMenu;
Show1: TMenuItem;
SaveGood1: TMenuItem;
ClearGood1: TMenuItem;
CloseChecker1: TMenuItem;
Label9: TLabel;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Show1Click(Sender: TObject);
procedure SaveGood1Click(Sender: TObject);
procedure ClearGood1Click(Sender: TObject);
procedure CloseChecker1Click(Sender: TObject);
procedure CoolTrayIcon1DblClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TMyTr = class(TgsvThread)
http:TidHttp;
protected
procedure Execute; override;
end;
var
Form1: TForm1;
ind:integer=-1;
thr: array [1..900] of TMyTr;
checked:Integer=0;
implementation
{$R *.dfm}
function getnumberproxy:integer;
begin
if ind<>form1.Memo1.Lines.Count then
inc(ind);
result:=ind;
end;
Вот эта вот, херня ходит по интернету и называется "Прокси-чеккер". Особо умилило то, что автор каким-то макаром приплел сюда GSVthreads.
+132
public static string[] GetLogicalDrives()
{
// System.Environment.GetLogicalDrives()
new EnvironmentPermission(PermissionState.Unrestricted).Demand();
// System.IO.Directory.GetLogicalDrives()
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
int logicalDrives = Win32Native.GetLogicalDrives();
if (logicalDrives == 0)
{
__Error.WinIOError();
}
uint num = (uint)logicalDrives;
int num2 = 0;
while (num != 0u)
{
if ((num & 1u) != 0u)
{
num2++;
}
num >>= 1;
}
string[] array = new string[num2];
char[] array2 = new char[]
{
'A',
':',
'\\'
};
num = (uint)logicalDrives;
num2 = 0;
while (num != 0u)
{
if ((num & 1u) != 0u)
{
array[num2++] = new string(array2);
}
num >>= 1;
char[] expr_6E_cp_0 = array2;
int expr_6E_cp_1 = 0;
expr_6E_cp_0[expr_6E_cp_1] += '\u0001';
}
return array;
}
Копался сегодня в дебрях .NET'а и нашёл 2 метода получения списка дисков:
System.Environment.GetLogicalDrives() и System.IO.Directory.GetLogicalDrives()
Различается код только первой срокой запроса разрешений.
Если один метод устарел-бы, то можно было его форварднуть через атрибут TypeForwardedTo.
Или хотя-бы объединить код вынеся запрос разрешений.
Оба метода доступны ещё с .NET 1.1. Но вот класс DriveInfo, который появился только в .NET 2.0 использует метод Directory.GetLogicalDrives()
Это такая "фича" с копипастом кода или тут есть какой-то сакральный смысл?
−162
//сохраним уже начисленные услуги
Если УслугиПоГрафику.Количество() > 0 Тогда
ПромежуточнаяТаблица = УслугиПоГрафику.Выгрузить();
УслугиПоГрафику.Очистить();
Для Каждого СтрокаТЗ Из ПромежуточнаяТаблица Цикл
НоваяСтрока = УслугиПоГрафику.Добавить();
ЗаполнитьЗначенияСвойств(НоваяСтрока, СтрокаТЗ);
КонецЦикла;
КонецЕсли;
Видимо изначально здесь что-то делалось с данными в таблице, потом было не глядя удалено, в результате остался вот такой кусок медитативного кода.
+12
template <class ToPtr,class From>
ToPtr DynamicCast (From f)
{
// static check if *ToPtr is derived from f
(void)sizeof (static_cast<From> ((ToPtr)NULL));
// lazy precalculation
static bool castable = dynamic_cast<ToPtr> (f)!=NULL;
static int offset =
int ((char *)dynamic_cast<ToPtr> (f)-(char *)f);
return castable? (ToPtr)((char *)f+offset) : NULL;
}
// usage: TBase *ptr1 = ...; TDerived *ptr2 = DynamicCast<TDerived *> (ptr1);
Performance oriented dynamic_cast
+151
function getNextDay($_arr_date, $day)
{
$_arr_result = array();
$str_result = '';
$str_result = substr($_arr_date[0], 0, 2);
$str_result .= '-';
$str_result .= substr($_arr_date[0], 2, 2);
$str_result .= '-';
$str_result .= substr($_arr_date[0], 4, 4);
$arrDate = explode('-', $str_result);
$_arr_result[0] = date('d-m-Y', mktime(0, 0, 0, $arrDate[1], $arrDate[0] + $day, $arrDate[2]));
$_arr_result[1] = date('d-m-Y', mktime(0, 0, 0, $arrDate[1], ($arrDate[0] + $day + 1), $arrDate[2]));
$_arr_result[2] = date('Y-m-d', mktime(0, 0, 0, $arrDate[1], $arrDate[0] + $day, $arrDate[2])); //for BD
$_arr_result[3] = date('Y-m-d', mktime(0, 0, 0, $arrDate[1], ($arrDate[0] + $day + 1), $arrDate[2])); //for BD
return $_arr_result;
}
Получаем дату следующего дня
+35
#if defined(_WIN32) || defined(_WIN64)
ofstream outfile("help.txt");
outfile << message << endl;
system("notepad.exe help.txt");
#else
cout << message ;
#endif
Зачем бороться с юникодом в консоли, когда есть блокнот?
+76
https://github.com/mongodb/mongo-java-driver/blob/master/src/main/com/mongodb/ConnectionStatus.java#L213
wtf?!
−158
update "Employee"."Jobs" set "default_group_id" = '1' where "id" in (select "id" from "Employee"."Jobs" where title like '%родавец%');
update "Employee"."Jobs" set "default_group_id" = '2' where "id" in (select "id" from "Employee"."Jobs" where title like '%правляющ%');
update "Employee"."Jobs" set "default_group_id" = '3' where "id" in (select "id" from "Employee"."Jobs" where title like '%лиент%');
update "Employee"."Jobs" set "default_group_id" = '4' where "id" in (select "id" from "Employee"."Jobs" where title like '%клад%' and title not like '%борщиц%');
like '%клад% должен был включать всяких "работников склада" и "замзавсклада", но туда попала также и "уборщица склада" - пришлось заводить второе условие
+84
uses crt;
type point=record{точки}
x,y:real;
end;
okr=record{окружности}
x,y,r:real;
end;
const nmax=20;
function Peres(a,b:point;c:okr):boolean;{пересекаются или нет}
var s,ab,h:real;
begin
s:=abs(a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y));{удвоенная площадь треугольника
вершины которого центр окружности и 2 точки}
ab:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));{сторона, противоположная центру окружности}
h:=s/ab;{высота на нее=расстояние от центра до прямой}
Peres:=h<c.r;{если лно меньше радиуса, пересекаются}
end;
var a:array[1..nmax] of point;
b:array[1..nmax] of okr;
n,m,i,j,k,p,mx,imx,jmx:integer;
begin
clrscr;
randomize;
repeat
write('Количество точек до ',nmax,' n=');
readln(n);
until n in [1..nmax];
repeat
write('Количество окружностей до ',nmax,' m=');
readln(m);
until m in [1..nmax];
for i:=1 to n do
begin
a[i].x:=-10+random*21;
a[i].y:=-10+random*21;
end;
for i:=1 to m do
begin
b[i].x:=-5+11*random;
b[i].y:=-5+11*random;
b[i].r:=5*random;
end;
writeln('Координаты точек:');
write('X:');
for i:=1 to n do
write(a[i].x:6:2);
writeln;
write('Y:');
for i:=1 to n do
write(a[i].y:6:2);
writeln;
writeln;
writeln('Параметры окружностей:');
write('X:');
for i:=1 to m do
write(b[i].x:6:2);
writeln;
write('Y:');
for i:=1 to m do
write(b[i].y:6:2);
writeln;
write('R:');
for i:=1 to m do
write(b[i].r:6:2);
writeln;
writeln;
mx:=0;
imx:=0;
jmx:=0;
for i:=1 to n-1 do
for j:=i+1 to n do
begin
k:=0;
for p:=1 to m do
if Peres(a[i],a[j],b[p]) then k:=k+1;
if k>mx then
begin
mx:=k;
imx:=i;
jmx:=j;
end;
end;
if mx=0 then write('Нет пересекающихся прямых и окружностей')
else
begin
writeln('Максимальное число пересечений прямой с окружностями=',mx);
write('Эта прямая проходит через точки (',a[imx].x:0:2,';',a[imx].y:0:2,') и (',a[jmx].x:0:2,';',a[jmx].y:0:2,')');
end;
readln
end.
Рекурсивная функций с циклами тройной вложенности