- 1
if (!(bundle == null))
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+74
if (!(bundle == null))
+129
#region Work with massive slovo
public string sFileNameMassiveSlovar = "";
public bool flChangeSlovo = false;
public int nCountSavedSlovo { get; private set; }
public int nCountAllSlovo { get; private set; }
public int nCountAddSlovo { get; private set; }
public void ClearMassiveSlovo()
{
slovo = slovo.Select(n => (byte)0).ToArray();
}
public int GetCountAllSlovo()
{
int npock = nLengthSlovo;
return slovo.Where((n, index) => index % npock == 0 && n != 0).Count();
}
public bool WriteMassiveSlovo()
{
bool res = false;
FileStream fs = null;
try
{
fs = File.Open(sFileNameMassiveSlovar, FileMode.Create, FileAccess.Write);
if (fs != null)
{
fs.Write(slovo, 0, nSizeMassiveSlova);
}
res = true;
}
catch (Exception e1)
{
res = false;
System.Windows.Forms.MessageBox.Show(e1.Message);
}
finally
{
if (fs != null) fs.Close();
}
return res;
}
#endregion
+157
window.SYSTEM_LOCALE ='ru';
if ((/ru/i).test(window.SYSTEM_LOCALE)) {
window.SYSTEM_LOCALE = "ru";
} else if ((/en/i).test(window.SYSTEM_LOCALE)) {
window.SYSTEM_LOCALE = "en";
} else if ((/uk|ua/i).test(window.SYSTEM_LOCALE)) {
window.SYSTEM_LOCALE = "uk";
};
wtf?
−106
Всякий раз наводя курсор на кнопку "Пуск" в Windows 7 вы видели как она менялась.
И вы наверно думали: а как реолизовать такой эффект в VB6? Давайте попробуем
Код:
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Picture = LoadPicture("C:Безымянный.bmp") ' при наведении курсора на имейдж в него загрузится картинка
End Sub
Ну теперь запускаем. Чтож мы видим? Навели курсор - картинка в имейдже измнилась.
Но ведь она должна изменятся обратно при отведении курсора. Но почему-то MuseMove этого не поддерживает.
Тогда придётся втянуть в это дело форму. Наведением курсора на форму мы будем имитировать отведение курсора от имейджа.
Вот код вместе с первым примером.
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Picture = LoadPicture("C:Безымянный1.bmp")' при наведении курсора на форму в имейдж загрузится картинка которая была раньше
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Picture = LoadPicture("C:Безымянный.bmp")' при наведении курсора на имейдж в него загрузится картинка
End Sub
Еще пара таких кодов, и мне начнет нравиться Борис М.
А че, интересный парень.
+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 Тогда
ПромежуточнаяТаблица = УслугиПоГрафику.Выгрузить();
УслугиПоГрафику.Очистить();
Для Каждого СтрокаТЗ Из ПромежуточнаяТаблица Цикл
НоваяСтрока = УслугиПоГрафику.Добавить();
ЗаполнитьЗначенияСвойств(НоваяСтрока, СтрокаТЗ);
КонецЦикла;
КонецЕсли;
Видимо изначально здесь что-то делалось с данными в таблице, потом было не глядя удалено, в результате остался вот такой кусок медитативного кода.