- 1
- 2
- 3
- 4
try {} finally {
retVal = NativeMethods.CreateProcess ( /* ... */ );
/* ... и дальше остальной код... */
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+111
try {} finally {
retVal = NativeMethods.CreateProcess ( /* ... */ );
/* ... и дальше остальной код... */
}
Откопано в исходниках .NET 2.0 Framework, так реализуется Process.Start. Не очень понял замысла. Нашёл, что finally обязательно продолжит исполняться, если во время его исполнения на поток ВНЕЗАПНО вызван метод Abort. Т.е. если потоку, создающему процесс, сделать аборт, процесс всё равно упорно создаcтся и запустится (чистки памяти я не нашёл). В чём смысл? Так можно было бы тогда всякий код оборачивать в finally... Ящитаю, что это всё костыли вокруг говноархитектуры. Не зря в Яве Thread.stop сделали deprecated. А вы как считаете?
+110.7
if (typ == 4) // Это ножницы
if (mirror == 0)
Size_N = " " + (beems[1].LenghtE - (int)dd[0]["value"]).ToString() + "0";
else
Size_N = " " + (mirror - (beems[1].LenghtE - (int)dd[0]["value"])).ToString() + "0";
else
{ // Это механизм
if (typ == 0 || typ == 2 || typ == 3)
{
if (mirror == 0)
Size_M = (((int)tRow["len"] / 2 + (beems[0].LenghtE / 2 - (int)dd[0]["value"]))).ToString() + "0";
else
Size_M = (mirror - ((int)tRow["len"] / 2 + (beems[0].LenghtE / 2 - (int)dd[0]["value"]))).ToString() + "0";
}
else
if (mirror == 0)
Size_M = (beems[0].LenghtE - (int)dd[0]["value"]).ToString() + "0";
else
Size_M = (mirror - (beems[0].LenghtE - (int)dd[0]["value"])).ToString() + "0";
if (typ == 0 || typ == 2 || typ == 3)
{
if (mirror == 0)
Size_M += " " + (beems[0].LenghtE - (int)dd[0]["value"] * 2).ToString() + "0";
else
Size_M += " " + (mirror - (beems[0].LenghtE - (int)dd[0]["value"] * 2)).ToString() + "0";
}
else
Size_M += " 0";
}
Формирование чего то для чего то..
+110.2
function HexStrToint(S: String): Integer;
begin
if (s='$00000000') or (s='clBlack')then HexStrToint:=0
else
if s='$00010101' then HexStrToint:=1
else
if s='$00020202' then HexStrToint:=2
else
if s='$00030303' then HexStrToint:=3
else
if s='$00040404' then HexStrToint:=4
else
if s='$00050505' then HexStrToint:=5
else
if s='$00060606' then HexStrToint:=6
else
if s='$00070707' then HexStrToint:=7
else
if s='$00080808' then result:=8
else
if s='$00090909' then result:=9
else
if s='$000A0A0A' then result:=10
else
if s='$000B0B0B' then result:=11
else
if s='$000C0C0C' then result:=12
else
if s='$000D0D0D' then result:=13
else
if s='$000E0E0E' then result:=14
else
if s='$000F0F0F' then result:=15
else
if s='$00101010' then result:=16
else
if s='$00111111' then result:=17
else
if s='$00121212' then result:=18
else
if s='$00131313' then result:=19
else
if s='$00141414' then result:=20
else
if s='$00151515' then result:=21
else
if s='$00161616' then result:=22
else
if s='$00171717' then result:=23
else
if s='$00181818' then result:=24
else
if s='$00191919' then result:=25
else
if s='$001A1A1A' then result:=26
else
if s='$001B1B1B' then result:=27
else
if s='$001C1C1C' then result:=28
else
if s='$001D1D1D' then result:=29
else
if s='$001E1E1E' then result:=30
else
if s='$001F1F1F' then result:=31
else
if s='$00202020' then result:=32
else
if s='$001D1D1D' then result:=33
else
if s='$00222222' then result:=34
else
if s='$00232323' then result:=35
else
if s='$00242424' then result:=36
else
if s='$00252525' then result:=37
else
if s='$00262626' then result:=38
else
if s='$00272727' then result:=39
else
if s='$00282828' then result:=40
else
if s='$00292929' then result:=41
else
if s='$002A2A2A' then result:=42
else
if s='$002B2B2B' then result:=43
else
if s='$002C2C2C' then result:=44
else
if s='$002D2D2D' then result:=45
else
if s='$002E2E2E' then result:=46
else
if s='$002F2F2F' then result:=47
else
if s='$00303030' then result:=48
else
Наткнулся на проявление "гениальности"
// про язык, на котором написано, вообще молчу
Это перевод хексов оттенков серого в числа (там до 255 включительно, но здесь не влезает)
Код, может, и сгенерирован, но все равно это говнокод ^_^
+110
private string _guin = Convert.ToString(Convert.ToString(Convert.ToString((string)Guid.NewGuid().ToString()).ToString() as string).ToString() as string).ToString() as string;
+110
// Двухклеточная прямая.
({D2A2}(Pixels[X+h,Y-1]=clWhite) and(Pixels[x+h,y-2]=clBlack) and(Pixels[x+h,y-3]=clBlack) and{D2A2} (Pixels[x+h+1,y-1]=clWhite) and(Pixels[x+h+1,y-2]=clBlack) and(Pixels[x+h+1,y-3]=clWhite) and{D2A2}(Pixels[x+h+2,y-2]=clWhite) and(Pixels[x+h+2,y-3]=clBlack) and(Pixels[x+h+2,y-4]=clWhite) and{D2A2}(Pixels[x+h+3,y-2]=clWhite) and(Pixels[x+h+3,y-3]=clBlack) and(Pixels[x+h+3,y-4]=clWhite)) or {D2A2}
({D2A2A-1}(Pixels[X+h,Y-1]=clWhite) and(Pixels[x+h,y-2]=clBlack) and(Pixels[x+h,y-3]=clWhite) and{D2A2A-1}(Pixels[x+h+1,y-1]=clWhite) and(Pixels[x+h+1,y-2]=clBlack) and(Pixels[x+h+1,y-3]=clWhite) and{D2A2A-1}(Pixels[x+h+2,y-2]=clWhite) and(Pixels[x+h+2,y-3]=clBlack) and(Pixels[x+h+2,y-4]=clBlack) and{D2A2A-1}(Pixels[x+h+3,y-2]=clWhite) and(Pixels[x+h+3,y-3]=clBlack) and(Pixels[x+h+3,y-4]=clWhite)) or {D2A2A-1}
({D2A3}(Pixels[X+h,Y-1]=clWhite) and(Pixels[x+h,y-2]=clBlack) and(Pixels[x+h,y-3]=clWhite) and{D2A3}(Pixels[x+h+1,y-1]=clWhite) and(Pixels[x+h+1,y-2]=clBlack) and(Pixels[x+h+1,y-3]=clBlack) and{D2A3}(Pixels[x+h+2,y-2]=clWhite) and(Pixels[x+h+2,y-3]=clBlack) and(Pixels[x+h+2,y-4]=clWhite) and{D2A3}(Pixels[x+h+3,y-2]=clWhite) and(Pixels[x+h+3,y-3]=clBlack) and(Pixels[x+h+3,y-4]=clWhite) and{D2A3}(Pixels[x+h+4,y-3]=clWhite) and(Pixels[x+h+4,y-4]=clBlack) and(Pixels[x+h+4,y-5]=clWhite)) or {D2A3}
({D2A4}(Pixels[X+h,Y-1]=clBlack) and(Pixels[x+h,y-2]=clBlack) and(Pixels[x+h,y-3]=clWhite) and{D2A4}(Pixels[x+h+1,y-1]=clWhite) and(Pixels[x+h+1,y-2]=clBlack) and(Pixels[x+h+1,y-3]=clWhite) and{D2A4}(Pixels[x+h+2,y-2]=clWhite) and(Pixels[x+h+2,y-3]=clBlack) and(Pixels[x+h+2,y-4]=clWhite) and{D2A4}(Pixels[x+h+3,y-2]=clWhite) and(Pixels[x+h+3,y-3]=clBlack) and(Pixels[x+h+3,y-4]=clWhite)) or {D2A4}
... Ещё 20 строк в таком стиле
({D2B2}(Pixels[X+h,Y-1]=clWhite) and(Pixels[x+h,y-2]=clWhite) and(Pixels[x+h,y-3]=clBlack) and{D2B2}(Pixels[x+h+1,y-1]=clWhite) and(Pixels[x+h+1,y-2]=clBlack) and(Pixels[x+h+1,y-3]=clWhite) and{D2B2}(Pixels[x+h+2,y-2]=clWhite) and(Pixels[x+h+2,y-3]=clBlack) and(Pixels[x+h+2,y-4]=clWhite) and{D2B2}(Pixels[x+h+3,y-2]=clWhite) and(Pixels[x+h+3,y-3]=clBlack) and(Pixels[x+h+3,y-4]=clWhite) and{D2B2}(Pixels[x+h+4,y-3]=clWhite) and(Pixels[x+h+4,y-4]=clBlack) and(Pixels[x+h+4,y-5]=clWhite)) or {D2B2}
({D2B3}(Pixels[X+h,Y-1]=clWhite) and(Pixels[x+h,y-2]=clWhite) and(Pixels[x+h,y-3]=clWhite) and{D2B3}(Pixels[x+h+1,y-1]=clWhite) and(Pixels[x+h+1,y-2]=clBlack) and(Pixels[x+h+1,y-3]=clBlack) and{D2B3}(Pixels[x+h+2,y-2]=clWhite) and(Pixels[x+h+2,y-3]=clBlack) and(Pixels[x+h+2,y-4]=clWhite) and{D2B3}(Pixels[x+h+3,y-2]=clWhite) and(Pixels[x+h+3,y-3]=clBlack) and(Pixels[x+h+3,y-4]=clWhite) and{D2B3}(Pixels[x+h+4,y-3]=clWhite) and(Pixels[x+h+4,y-4]=clBlack) and(Pixels[x+h+4,y-5]=clWhite)) or {D2B3}
({D2B4}(Pixels[X+h,Y-1]=clBlack) and(Pixels[x+h,y-2]=clWhite) and(Pixels[x+h,y-3]=clWhite) and{D2B4}(Pixels[x+h+1,y-1]=clWhite) and(Pixels[x+h+1,y-2]=clBlack) and(Pixels[x+h+1,y-3]=clBlack) and{D2B4}(Pixels[x+h+2,y-2]=clWhite) and(Pixels[x+h+2,y-3]=clBlack) and(Pixels[x+h+2,y-4]=clWhite) and{D2B4}(Pixels[x+h+3,y-2]=clWhite) and(Pixels[x+h+3,y-3]=clBlack) and(Pixels[x+h+3,y-4]=clWhite) and{D2B4}(Pixels[x+h+4,y-3]=clWhite) and(Pixels[x+h+4,y-4]=clBlack) and(Pixels[x+h+4,y-5]=clWhite)) {or} {D2B4}
{(J1(Pixels[X+h,Y-1]=clWhite) and (Pixels[x+h,y]=clWhite) and (Pixels[x+h,y-2]=clBlack))} then // Проверка, если обрыв по x, начало следующей ступенрки.
begin
goto k8;
end ;
goto k3;//Если убрать эту строчку,то может фиксироваться вся линия исключая точку с дифектоми, т.к.
end; // если не отрабатывает сравнение пикселей по длине ступеньки и не отрабатывает по переходу на новую ступеньку, прог. прибавляет h и перемещает пиксель опроса в право.
k8: if (CPlx-CPLxI=0) or (CPlx-CPlxI=1) or (CPlxI-CPlx=1)or(CPlxI-CPlx=CPlxI/2) or (CPlx-CPlxI=CPlx/2) or (CPlxI-CPlx=(CPlxI/2)-1) or (CPlx-CPlxI=(CPlx/2)-1) or ((CPlxI-CPlx>(CPlxI/2)-1) and (CPlxI-CPlx<(CPlxI/2)+1)) then
begin
a:=x+h;
b:=y-1;
count:=count+1; // Счет ступеник.
goto k5;
end;
k3: OperEnd:=DateTimeToTimeStamp(Now);
Total:=OperEnd.Time-OperBegin.Time;
ListBox1.Items.Add(IntToStr(CPlx0)+' CPlx0');
ListBox1.Items.Add(IntToStr(CPlxI)+' CPlxI');
ListBox1.Items.Add(IntToStr(count)+' Ступеньки.');
ListBox1.Items.Add(IntToStr(Total)+' MSec');
end; // Конец прог.
end;
end.
Адовый пиздец с киберфорума.
http://www.cyberforum.ru/delphi-beginners/thread941698.html
+110
private void Save(string ThreadID, string Board)
{
string pathL;
if (cbGIF.Checked)
{
pathL = String.Format(path, Board, ThreadID, "-gif");
}
else
{
pathL = String.Format(path, Board, ThreadID, "");
}
string htmlPath = String.Format(threadPath, Board, ThreadID);
WebClient wcli = new GZipWebClient();
string cThread = wcli.DownloadString(htmlPath);
var rx = new Regex(cbGIF.Checked ? regExGif : regEx);
var ms = rx.Matches(cThread);
imgSaved = 0;
imgCount = ms.Count;
saveProgress.Minimum = 0;
saveProgress.Maximum = imgCount;
saveProgress.Value = 0;
if (!Directory.Exists(pathL))
{
Directory.CreateDirectory(pathL);
}
try
{
foreach (Match m in ms)
{
WebClient ccl = new WebClient();
ccl.DownloadFileCompleted += new AsyncCompletedEventHandler(ccl_DownloadFileCompleted);
string[] v = m.Value.Split('"');
string sd = v[1].Split('/').Last();
string a = url + v[1];
string b = pathL + sd;
if (File.Exists(b))
{
imgSaved++;
saveProgress.Value = imgSaved;
lblSaveProgress.Text = imgSaved.ToString() + "/" + imgCount.ToString();
if (imgSaved == imgCount)
{
btnSave.Enabled = true;
lblSaveProgress.Text = "FUKKEN SAVED!";
}
}
else ccl.DownloadFileAsync(new Uri(a),b);
}
}
catch (WebException e)
{
MessageBox.Show(e.Message + e.StackTrace);
}
}
В пределах одного метода бросаемся из крайности в крайность в именовании переменных.
+110
public void UpdateCollection()
{
object l = new object();
lock (l)
{
// Обновляем коллекцию
}
}
Эксклюзивная блокировка в действии
+110
<img border="0" width="476" height="179" src="file:///C|/Users/jy88h0/AppData/Roaming/Macromedia/Dreamweaver /eCustomer/iq/images/AI289.jpg" alt="Image of a properly addressed mail piece">
http://faq.usps.com/eCustomer/iq/usps/request.do?create=kb%3AUSPSFAQ&view%28%2 9=c[c_usps0910]
+110
int strnlen(const char *s, int size)
{
int i;
for(i=0; i<size; i++) if(!*s) break;
return i;
}
+110
public static int getRandomNumber(int from, int to)
{
System.Threading.Thread.Sleep(10);
Random r = new Random();
int var = r.Next(from, to);
return var;
}
No comments