- 1
- 2
- 3
- 4
- 5
- 6
- 7
if (App.TimerClock != null)
{
App.TimerClock.Enabled = false;
App.TimerClock.Close();
App.TimerClock.Dispose();
App.TimerClock = null;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+105
if (App.TimerClock != null)
{
App.TimerClock.Enabled = false;
App.TimerClock.Close();
App.TimerClock.Dispose();
App.TimerClock = null;
}
+109
static void Main(string[] args)
{
Console.WriteLine("Как желаете заполнить?");
Console.WriteLine("Цифра 1 = в столбик, цифра 2 = в строчку");
int valMethod = Convert.ToInt32(Console.ReadLine());
Console.Clear();
Console.SetCursorPosition(1, 0);
for (int index = 1; index != 22; index++)
{
Console.CursorLeft = 1;
Console.WriteLine('║');
if (index < 21)
{
Console.CursorLeft = 19;
Console.Write('║');
}
}
Console.SetCursorPosition(1, 0);
for (int index = 1; index != 62; index++)
Console.Write('═');
Console.SetCursorPosition(35, 1);
int valueRow = 0;
for (int i = 0; i < 4; i++)
{
for (int index = 1; index != 20; index++)
{
Console.SetCursorPosition(28 + valueRow, 1 + index);
Console.WriteLine('║');
}
valueRow += 8;
}
for (int index = 1; index != 20; index++)
{
Console.SetCursorPosition(29 + valueRow, 0 + index);
Console.WriteLine('║');
}
Console.SetCursorPosition(20, 2);
for (int index = 1; index != 43; index++)
Console.Write('═');
int value = 4;
for (int i = 0; i < 9; i++)
{
Console.SetCursorPosition(1, value);
for (int index = 1; index != 62; index++)
Console.Write('═');
value += 2;
}
Console.SetCursorPosition(6, 2);
Console.WriteLine("Спортсмен");
Console.SetCursorPosition(25, 1);
Console.WriteLine("Вид спорта");
int value1 = 5;
for (int i = 1; i < 9; i++)
{
Console.SetCursorPosition(6, value1);
Console.WriteLine("{0}", i);
value1 += 2;
}
int value2 = 2;
for (int i = 1; i < 6; i++)
{
Console.SetCursorPosition(22 + value2, 3);
Console.Write("{0}", i);
value2 += 8;
}
Console.SetCursorPosition(1, 0);
Console.Write("╔");
Console.SetCursorPosition(61, 0);
Console.Write("╗");
Console.SetCursorPosition(1, 20);
Console.Write("╚");
Console.SetCursorPosition(61, 20);
Console.Write("╝");
...
Мы так любим магические числа...
+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?!