- 1
preg_replace('/^(.*)\s(.*)$/i', '$1', $item['updated']);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+148
preg_replace('/^(.*)\s(.*)$/i', '$1', $item['updated']);
+142
<tr>
<td><img src=images/spacer.gif border=0 height=1 width=15></td>
<td><img src=images/spacer.gif border=0 height=1 width=77></td>
<td><img src=images/spacer.gif border=0 height=1 width=19></td>
<td><img src=images/spacer.gif border=0 height=1 width=68></td>
<td><img src=images/spacer.gif border=0 height=1 width=19></td>
<td><img src=images/spacer.gif border=0 height=1 width=1></td>
</tr>
Ой ща я разгуляюсь!
Работаю в колл-центре, это исходный код веб-морды панели звонков.
Буду кидать куски потихоньку. Хотя там надо сразу все кидать.
Вот так мы верстаем.
+165
function ChangePhoto(num, photo)
{
if (photo.className != 'photo_selected')
{
var image1 = document.getElementById("ctl00_MainContent_ProductInfo1_ctl00_AlternativePictures_Image1");
var image2 = document.getElementById("ctl00_MainContent_ProductInfo1_ctl00_AlternativePictures_Image2");
var image3 = document.getElementById("ctl00_MainContent_ProductInfo1_ctl00_AlternativePictures_Image3");
var image4 = document.getElementById("ctl00_MainContent_ProductInfo1_ctl00_AlternativePictures_Image4");
var image5 = document.getElementById("ctl00_MainContent_ProductInfo1_ctl00_AlternativePictures_Image5");
var image6 = document.getElementById("ctl00_MainContent_ProductInfo1_ctl00_AlternativePictures_Image6");
if (image1 != null) image1.className = 'photo_notselected';
if (image2 != null) image2.className = 'photo_notselected';
if (image3 != null) image3.className = 'photo_notselected';
if (image4 != null) image4.className = 'photo_notselected';
if (image5 != null) image5.className = 'photo_notselected';
if (image6 != null) image6.className = 'photo_notselected';
photo.className = 'photo_selected';
Hide(0);
setTimeout("ChangeSrc("+num+")", 300);
setTimeout("ShowPhoto()", 400);
}
}
Чо мне ща сказал? Цыклы мне ща сказал? Какие тенна цыклы, ыдисюданна!
Строчки 22, 23 активируют какое-то хитрожопое многопоточное отображение фоток со взаимными блокировками и ожиданием друг друга по таймеру с интервалами в 10 мс.
+138
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctime>
#include <signal.h>
#include <sys/time.h>
#include <fcntl.h>
#include <termios.h>
#include <time.h>
#include <iostream>
using namespace std;
struct termios savetty;
struct termios tty;
char num[]="0123456789QWERTYUIOPASDFGHJKLZXCVBNM";
char let[]="!\",#$%&'()*qwertyuiopasdfghjklzxcvbnm";
int t=1;
int tm=0;
int opnum=0;
char buffer[30];
char var[1000];
char out[1000];
struct timeval tv;
struct timeval tv2;
int main()
{
if ( !isatty(0) ) {
fprintf (stderr, "stdin not terminal\n");
exit (1);
};
tcgetattr (0, &tty);
savetty = tty;
tty.c_lflag &= ~(ICANON|ISIG);
tty.c_cc[VMIN] = 1;
tcsetattr (0, TCSAFLUSH, &tty);
srand(time(0));
int i=0;
bool c=true;
time_t curtime;
int passLen=200+rand()%400;
for(int i=0;i<=passLen;i++){
int s=rand()%2;
if(s==1){
out[i]=let[rand()%37];
} else {
out[i]=num[rand()%35];
};
if((i%5)==0 && i!=0)out[i]=' ';
};
out[passLen]='\0';
int tt=gettimeofday(&tv, NULL);
if(tt<0)exit(0);
printf("%s\n",out);
while(out[i]!='\0')
{
var[i]=getchar();
if(var[i]!=out[i]){
opnum++;
printf("Er%c",out[i]);
};
i++;
};
tt=gettimeofday(&tv2, NULL);
if(tt<0)exit(0);
int tm=tv2.tv_sec-tv.tv_sec;
int v=(passLen*60)/tm;
int min=tm/60;
tm%=60;
printf("Time %d min %d sec\n",min,tm);
cout<<"Num of errors "<<opnum<<" Speed "<<v<<endl;
tcsetattr (0, TCSAFLUSH, &savetty);
};
Клавиатурный тренажер
+171
void Cryptogram(const vector<string> &vector1, vector<string> &vector2)
{
string word;
char new_letter;
long i, j, wordSize, vecSize, vecSize2;
vecSize = vector1.size();
for(j=0; j<vecSize; j++)
{
word = vector1[j];
//cout<<word<<endl;
wordSize = word.size();
cout<<wordSize<<endl;
for(i=0; i<wordSize; i++)
{
new_letter = word[i];
cout<<"& " << new_letter<< " " << isalpha(new_letter) << endl;
if(isalpha(new_letter)==true)
{
if(isupper(new_letter)==true)
{
if (new_letter == 'A')
new_letter = 'W';
else if(new_letter == 'B')
new_letter = 'Y';
else if(new_letter == 'C')
new_letter = 'I';
else if(new_letter == 'D')
new_letter = 'J';
else if(new_letter == 'E')
new_letter = 'K';
else if(new_letter == 'F')
new_letter = 'C';
else if(new_letter == 'G')
new_letter = 'U';
else if(new_letter == 'H')
new_letter = 'V';
else if(new_letter == 'I')
new_letter = 'D';
else if(new_letter == 'J')
new_letter = 'P';
else if(new_letter == 'K')
new_letter = 'Q';
else if(new_letter == 'L')
new_letter = 'L';
else if(new_letter == 'M')
new_letter = 'Z';
else if(new_letter == 'N')
new_letter = 'H';
else if(new_letter == 'O')
new_letter = 'T';
else if(new_letter == 'P')
new_letter = 'G';
else if(new_letter == 'Q')
new_letter = 'A';
else if(new_letter == 'R')
new_letter = 'B';
else if(new_letter == 'S')
new_letter = 'M';
else if(new_letter == 'T')
new_letter = 'X';
else if(new_letter == 'U')
new_letter = 'E';
else if(new_letter == 'V')
new_letter = 'F';
else if(new_letter == 'W')
new_letter = 'O';
else if(new_letter == 'X')
new_letter = 'N';
else if(new_letter == 'Y')
new_letter = 'R';
else if(new_letter == 'Z')
new_letter = 'S';
}
Cryptogram function, it's much longer, with 26 if statements if the letter is lowercase.
+82
for (FileItem item : items) {
try {
item.write(new File(repo
+ System.currentTimeMillis()
+ "_" + item.getName()));
} catch (Exception ex) {
log.error(ex, ex);
}
mav.addObject("result", "http://xxx.xx/uploads/"
+ System.currentTimeMillis()
+ "_" + item.getName());
}
долго думал почему имя файла на диске не совпадает с именем в ссылке.
+158
<script language="php">
$curl=curl_init("http://www.sportbox.ru");
$proxy='us:psw@IP:port';
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_PROXY, $proxy);
$content=curl_exec($curl);
preg_match_all('#<h3><a href(.*)>(.*)</a></h3>#siU', $content, $titles);
foreach ($titles[2] as $title)
echo "<b>$title</b><br>";
curl_close($content);
</script>
+169
<?php
exit
(
empty($_POST['key']) ||
empty($_POST['time']) ||
empty($_POST['email']) ||
(int)$_POST['time'] != $_POST['time'] ||
strlen((int)$_POST['time']) != strlen($_POST['time']) ||
!preg_match('/^[^@]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/', $_POST['email']) ||
($_SERVER['REQUEST_TIME'] - $_POST['time']) > 60 * 60 ||
md5(str_rot13(md5($_POST['time']))) != $_POST['key']
?'-':'+'
);
?>
Вот Ajax ответ
+158
/* Адаптация под оперу */
if ( stristr($_SERVER['HTTP_USER_AGENT'], 'Opera') )
echo "<input type=hidden value='file_ok' name='action'><br><input type=\"image\" src=\"".$url."images/buttons/button_file_ok.png\">";
else
echo "<br><input type=\"image\" src=\"".$url."images/buttons/button_file_ok.png\" value=\"file_ok\" name=\"action\">";
особый говнокод для Оперы
http://my.opera.com/russian/forums/topic.dml?id=918821
+92
type BOOK= record
Name:string[20];
Avtor:string[20];
Price:integer;
end;
BOOKS=Array[1..100] of BOOK;
F= File of BOOK;
procedure Vvod(var biblioteka: books; var File_tBIBL:F; var n:integer);
Procedure AVTOR_KN(VAR File_tBIBl:F; VAR File_tBIBl_AVTOR:text);
Procedure TIP_TEXT(VAR File_tBIBl:F; VAR File_tBIBl_text:text);
Function MIN_CENA( var File_tBIBl:F ; n:integer ):integer;
procedure Vvod(var biblioteka: books; var File_tBIBL:F; var n:integer);
var i:integer;
begin
rewrite(File_tBIBL);
FOR i:=1 to n do begin
Writeln(' Vvedite nazvanie knigi');
readln(biblioteka[i].Name);
Writeln(' Vvedite avtora');
readln(biblioteka[i].Avtor);
Writeln(' Vvedite cenu');
readln(biblioteka[i].Price);
Write(File_tBIBL,biblioteka[i]);
writeln;
end;
close(File_tBIBL);
end;
Procedure TIP_TEXT(VAR File_tBIBl:F; VAR File_tBIBl_text:text);
var BIBLIOTEKA:BOOk;
BEGIN
reset(File_tBIBl);
rewrite(File_tBIBl_text);
WHILE not eof(File_tBIBl) do begin
read(File_tBIBl,BIBLIOTEKA);
writeln(File_tBIBl_text,BIBLIOTEKA.Name);
writeln(File_tBIBl_text,BIBLIOTEKA.Avtor);
writeln(File_tBIBl_text,BIBLIOTEKA.Price);
writeln(File_tBIBl_text);
writeln(File_tBIBl_text);
end;
close(File_tBIBl);
close(File_tBIBl_text);
end;
Procedure AVTOR_KN(VAR File_tBIBl:F; VAR File_tBIBl_AVTOR:text);
var BIBLIOTEKA:BOOk; Av:string;
BEGIN
reset(File_tBIBl);
rewrite(File_tBIBl_AVTOR);
Writeln('Vvedite iskomogo avtora');
readln(Av);
WHILE not eof(File_tBIBl) do begin
read(File_tBIBl,BIBLIOTEKA);
if BIBLIOTEKA.Avtor = Av then begin
writeln(File_tBIBl_AVTOR,BIBLIOTEKA.Name);
writeln(File_tBIBl_AVTOR,BIBLIOTEKA.Avtor);
writeln(File_tBIBl_AVTOR,BIBLIOTEKA.Price:4);
writeln(File_tBIBl_AVTOR);
end;
end;
close(File_tBIBl);
close(File_tBIBl_AVTOR);
end;
var nomer,i,min:integer;BIBLIOTEKA:BOOks; SIZE:integer;
begin
reset(File_tBIBl);
size:=1;
while not eof(File_tBIBl) do
with BIBLIOTEKA[size] do
begin
readln(File_tBIBl , BIBLIOTEKA.name);
Readln(File_tBIBl,BIBLIOTEKA.Avtor);
readln(File_tBIBl,BIBLIOTEKA.Price);
inc(size);
end;
dec(size);
min:=BIBLIOTEKA[1].Price;
for i:=1 to size do
if BIBLIOTEKA[i].Price< min then begin
min:=BIBLIOTEKA[i].Price;
nomer:=i;
end;