- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
WORD StrLen(PChar s)
{
ASSERT(s!=NULL);
int i;
for (i=0; ( (*(s+i)!=0) && (i<=WORDMAX) ); i++) {};
ASSERT(i<=WORDMAX);
return (WORD)i;
};
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
WORD StrLen(PChar s)
{
ASSERT(s!=NULL);
int i;
for (i=0; ( (*(s+i)!=0) && (i<=WORDMAX) ); i++) {};
ASSERT(i<=WORDMAX);
return (WORD)i;
};
По заявкам из http://govnokod.ru/11318
+146
huiX5uiPH5;;P5;@@5HH4XPPDXDPhuiX5fiTГ
Было запощено в 11315, но, мне кажется, что этот ГК заслуживает отдельного топика.
Когда-то давно пытался на ассемблере включить видеорежим 320x200x256 (13h) и порисовать. Но XP сменив режим потеряла управление. Помог только ребут. В тот день, матерясь на MS, я и решил написать эту строчку так, чтобы ее можно было вводить с помощью обычного блокнота на любой машине...
Системные требования: Windows XP
Текст набирается в кодировке CP1251. Файл должен иметь расширение COM.
−18
return StrLen((*i).second);
В точку.
+58
$attr_id = json_decode($_GET['attr_id']);
$obj_id = json_decode($_GET['obj_id']);
$a_href = $_GET['file_id'];
Разгребаю что осталось от недавно уволенного джуниора.
2 json_decoda толкают в уныние. При том что джсон туда вообще не приходит =\
Жаль вот уже, не сохранился код, в к-м он пришедший на _клиент в браузер_ json парсил руками(JSON.parse() - для слабых)
−92
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
self.view.frame=CGRectMake(10,10, 300, 200);
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
cell.selectionStyle=UITableViewCellSelectionStyleNone;
switch (indexPath.row) {
case 0:
//ToDo: Add UserInfo's view into TableView
[cell.contentView addSubview:upperView];
break;
case 1:{
//Remove preous view/tableview
for (id vw in cell.contentView.subviews) {
if ([vw isKindOfClass:[UITableView class]]) {
[vw removeFromSuperview];
}
}
//
//Add View which contain tableview
EditListViewController *editlistvw=[[EditListViewController alloc] initWithNibName:@"EditListViewController" bundle:nil] ;
editlistvw.view.frame=CGRectMake(10, 10, 300, 20);
[cell.contentView addSubview:editlistvw.tableView];
//
break;
}
case 2:
//Remove previous view/tableview
for (id vw in cell.contentView.subviews) {
if ([vw isKindOfClass:[UITableView class]]) {
[vw removeFromSuperview];
}
}
break;
default:
break;
}
return cell;
}
Творение индийского джуниора, совместно с которым приходится делать проект
+184
CD20
первая программа на асм
−16
void setOn(const bool &on) {
// ...
}
А вот чего только не встретишь в коде...
+199
sum proc ; ax=ax+bx
push dx
m1: mov dx, ax
xor ax, bx
and bx, dx
shl bx, 01h
cmp bx, 00h
jnz m1
pop dx
ret
sum endp
Навеяно http://govnokod.ru/11311
+65
$quGroup = mysql_query($x = "
SELECT
a.latitude, a.longitude, a.catid, a.id, a.title, a.arttype, a.userid, b.firstname, b.lastname, b.usertype,
a.latitude2, a.longitude2, a.latitude3, a.longitude3, a.latitude4, a.longitude4, a.latitude5, a.longitude5,
a.latitude6, a.longitude6, a.latitude7, a.longitude7, a.latitude8, a.longitude8, a.latitude9, a.longitude9,
a.latitude10, a.longitude10, a.latitude11, a.longitude11
from materials a, users b
where a.status='1' and a.userid=b.id and add_date > $day)
$sql_cond");
while ($flGroup = mysql_fetch_row($quGroup)) {
$j++;
$a1 = $a2 = array ();
$l1 = $flGroup[0];
$l2 = $flGroup[1];
if ($l1 && $l2) {
$a1[] = $l1;
$a2[] = $l2;
}
$latitude2 = $flGroup[10];
$longitude2 = $flGroup[11];
if ($latitude2 && $longitude2) {
$a1[] = $latitude2;
$a2[] = $longitude2;
}
$latitude3 = $flGroup[12];
$longitude3 = $flGroup[13];
if ($latitude3 && $longitude3) {
$a1[] = $latitude3;
$a2[] = $longitude3;
}
$latitude4 = $flGroup[14];
$longitude4 = $flGroup[15];
if ($latitude4 && $longitude4) {
$a1[] = $latitude4;
$a2[] = $longitude4;
}
$latitude5 = $flGroup[16];
$longitude5 = $flGroup[17];
if ($latitude5 && $longitude5) {
$a1[] = $latitude5;
$a2[] = $longitude5;
}
$latitude6 = $flGroup[18];
$longitude6 = $flGroup[19];
if ($latitude6 && $longitude6) {
$a1[] = $latitude6;
$a2[] = $longitude6;
}
$latitude7 = $flGroup[20];
$longitude7 = $flGroup[21];
if ($latitude7 && $longitude7) {
$a1[] = $latitude7;
$a2[] = $longitude7;
}
$latitude8 = $flGroup[22];
$longitude8 = $flGroup[23];
if ($latitude8 && $longitude8) {
$a1[] = $latitude8;
$a2[] = $longitude8;
}
$latitude9 = $flGroup[24];
$longitude9 = $flGroup[25];
if ($latitude9 && $longitude9) {
$a1[] = $latitude9;
$a2[] = $longitude9;
}
$latitude10 = $flGroup[26];
$longitude10 = $flGroup[27];
if ($latitude10 && $longitude10) {
$a1[] = $latitude10;
$a2[] = $longitude10;
}
$latitude11 = $flGroup[28];
$longitude11 = $flGroup[29];
if ($latitude11 && $longitude11) {
$a1[] = $latitude11;
$a2[] = $longitude11;
}
if (!$l1 && !$l2 && !$latitude2 && !$longitude2 && !$latitude3 && !$longitude3 && !$latitude4 && !$longitude4 && !$latitude5 && !$longitude5 && !$latitude6 && !$longitude6 && !$latitude7 && !$longitude7 && !$latitude8 && !$longitude8 && !$latitude9 && !$longitude9 && !$latitude10 && !$longitude10 && !$latitude11 && !$longitude11)
continue;
...
}
как изящно
−2
//сравниваем два числа, функция не использует операторы < и > в целях переносимости на платформы, где они не поддерживаются
auto intcmp( int a, int b ) -> int {
while( a && b ) {
a--;
b--;
}
if ( a == 0 && b == 0 ) // числа равны
return 0;
if ( a == 0 ) // a - меньше
return -1;
if ( b == 0 ) // a - больше
return 1;
assert( true ); // да нам подсунули какие-то неправильные числа
}
К слову "auto foo( ... ) -> type" добавили в C++11.