- 1
- 2
- 3
- 4
- 5
data М = М { unМ :: String }
instance Show М where
show = map succ . unМ
main = print $ М"ФТИ"
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+131
data М = М { unМ :: String }
instance Show М where
show = map succ . unМ
main = print $ М"ФТИ"
Синтетический баян...
+75
int i128 = 0, i256 =0, i384=0, i512=0, i640=0, i786=0, i896=0, i1024=0, i1152=0, i1280=0, i1408=0, i1536=0;
for (int index: data) {
if (index>max) max = index;
if (min>index) min = index;
if (0<=index & index<128) i128++;
else if (128<=index & index<256) i256++;
else if (256<=index & index<384) i384++;
else if (384<=index & index<512) i512++;
else if (512<=index & index<640) i640++;
else if (640<=index & index<786) i786++;
else if (786<=index & index<896) i896++;
else if (896<=index & index<1024) i1024++;
else if (1024<=index & index<1152) i1152++;
else if (1152<=index & index<1280) i1280++;
else if (1280<=index & index<1408) i1408++;
else if (1408<=index & index<1536) i1536++;
Считаем количество попаданий index в различные диапазоны значений.
+164
if (
$arItem["DEPTH_LEVEL"]==$previousLevel
&&$arItem["IS_PARENT"]
&&$arItem["DEPTH_LEVEL"]>3
||$arItem["DEPTH_LEVEL"]<$previousLevel
&&$arItem["IS_PARENT"]
&&$arItem["DEPTH_LEVEL"]==3
&&$previousLevel-$arItem["DEPTH_LEVEL"]==1
)
.....
Paranoid mode deteсted! Внимание! (Г)Код был в строку, для удобства чтения отформатировал.
−116
// было
-(BOOL)textFieldShouldReturn:(UITextField *)textField {
if (textField == firstName) {
[lastName becomeFirstResponder];
}
else if (textField == lastName) {
[zip becomeFirstResponder];
}
else if (textField == emailAdr) {
[confirmEmailAdr becomeFirstResponder];
}
else if (textField == confirmEmailAdr) {
[zip becomeFirstResponder];
}
else if (textField == zip) {
[street becomeFirstResponder];
}
else if (textField == street) {
[city becomeFirstResponder];
}
else if (textField == city) {
[telephonNumber becomeFirstResponder];
}
else if (textField == telephonNumber) {
[wachtwoord becomeFirstResponder];
}
else{
[textField resignFirstResponder];
}
return YES;
}
// решил заменить на ( при условии что все текстфилды протаганы от 1 до N):
-(BOOL)textFieldShouldReturn:(UITextField *)textField {
int tag = textField.tag;
UITextField* tf = (UITextField*)[self.scrollView viewWithTag:tag+1];
if ( tf )
[tf becomeFirstResponder];
else
[textField resignFirstResponder];
return YES;
}
+80
@Deprecated
private byte getLoByte(int i) {
byte ret = 0x00;
String hex = Integer.toHexString(i);
int length = hex.length();
if (length == 1) {
ret = Integer.valueOf(hex.substring(length - 1), 16).byteValue();
} else if (length >= 2) {
ret = Integer.valueOf(hex.substring(length - 2), 16).byteValue();
}
return ret;
}
@Deprecated
private byte getHiByte(int i) {
String hex = Integer.toHexString(i);
byte ret = 0x00;
int length = hex.length();
if (length > 3) {
ret = Integer.valueOf(hex.substring(length - 4, length - 2), 16).byteValue();
} else if (length == 3) {
ret = Integer.valueOf(hex.substring(length - 3, length - 2), 16).byteValue();
}
return ret;
}
Вытаскивание старшего и младшего байтов числа из последних одного или двух байтов
−102
Сегодня мы отказались от 1С.
Сегодня, когда день апплодировал стоя.
А в штанах остались желтые бумажки. В назидание?
−128
if (players.indexOf(String(Game.uid)) == 0)
players.shift();
else
players.pop();
+171
<?if($USER_ID$='1')?><font color="#FF0000"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='2')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='3')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='4')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='5')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='6')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='7')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='8')?><font color="#00BFFF"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='9')?><font color="#30EFFF"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='10')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='11')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='12')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='13')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='14')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='15')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='16')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='17')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='18')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='19')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='20')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='21')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='22')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='23')?><font color="#9B0000"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='24')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='25')?><font color="#FF0000"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='26')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='27')?><font color="#9B0000"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='28')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='29')?><font color="#30EFFF"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='30')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='31')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='32')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='33')?><font color="#FFFF00"><b>$NAME$</b></font><?else?>
<?if($USER_ID$='34')?><font color="#FF0000"><b>$NAME$</b></font><?else?><b>$NAME$</b>
<?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?end if?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?><?endif?>< ?endif?><?endif?><?endif?>
Вообще то тут переменные uCoz, но это не важно.
Автор: http://1759741350.unet.com/
+133
/* ... */
/**************************************************************************************
cpu_information () parse /proc/cpuinfo to get information about CPU
**************************************************************************************/
int cpu_information (data* user_data, int pos)
{
FILE *cpufp/* /proc/cpuinfo */ /*, *sysfs_max_cpu_freq_fp /sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq */;
char* ch = (char*)malloc (MAXLEN);
char* line = (char*)malloc (MAXLEN);
char* buf = (char*)malloc (MAXLEN);
GtkTreeIter iter[2];
// int y = 0;
if ((cpufp = fopen(CPU_INFORMATION_FILE, "r")) == NULL)
printf ("%s\n", "Error opening /proc/cpuinfo");
while (fgets (ch, MAXLEN, cpufp) != NULL)
{
if (!strncmp (ch, "processor", 9))
{
sscanf (ch, "%*s %*s %s", line);
strcpy (buf, "CPU");
gtk_tree_store_insert_with_values (user_data->InformationTreeStore, &iter[0],NULL, pos, 0, buf, 1, line, -1);
} else if (!strncmp(ch, "vendor_id", 9))
{
sscanf(ch,"%*s %*s %s", line);
strcpy (buf, "Processor type:");
gtk_tree_store_insert_with_values (user_data->InformationTreeStore, &iter[1],&iter[0], pos, 0, buf, 1, line, -1);
} else if (!strncmp(ch, "model name", 10))
{
strcpy(buf, "Model name");
ch[strlen(ch)-1] = '\0'; //delete '\n' symbol from the end of string
gtk_tree_store_insert_with_values (user_data->InformationTreeStore, &iter[1],&iter[0], pos, 0, buf, 1, &ch[13], -1);
} else if (!strncmp(ch, "cpu MHz", 7))
{
int curr_cpu_freq;
sscanf(ch, "%*s %*s %*s %d\n", &curr_cpu_freq);
sprintf(line, "%d", curr_cpu_freq);
strcpy (buf, "Current Processor Speed in MHz");
gtk_tree_store_insert_with_values (user_data->InformationTreeStore, &iter[1],&iter[0], pos, 0, buf, 1, line,-1);
/*
Begin parsing /sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq
sprintf (sysfs_max_cpu_freq_path, SYSFS_CPU_MAX_FREQ_FORMAT_STRING, y);
if ((sysfs_max_cpu_freq_fp = fopen (sysfs_max_cpu_freq_path, "r")) == NULL) {
printf("%s %s\n", "Error opening", sysfs_max_cpu_freq_path);
}
while (fgets (line, MAXLEN, sysfs_max_cpu_freq_fp) != NULL)
{
sscanf (line, "%d", &max_cpu_freq);
sprintf (line, "%d", max_cpu_freq/1000);
strcpy (buf, "Max Processor Speed in MHz");
gtk_tree_store_insert_with_values (user_data->InformationTreeStore, &iter[2],&iter[1], pos, 0, buf, 1, line,-1);
}
y++;
End parsing
fclose (sysfs_max_cpu_freq_fp);*/
} else if (!strncmp(ch, "cache size", 10))
{
sscanf(ch, "%*s %*s %*s %s", line);
strcpy (buf, "Processor cache size");
strcat (line, " KB");
gtk_tree_store_insert_with_values (user_data->InformationTreeStore, &iter[1],&iter[0], pos, 0, buf, 1, line, -1);
} else if (!strncmp(ch, "bogomips", 8))
{
sscanf(ch, "%*s %*s %s", line);
strcpy (buf, "Processor speed in Bogomips");
gtk_tree_store_insert_with_values (user_data->InformationTreeStore, &iter[1],&iter[0], pos, 0, buf, 1, line, -1);
cpu_temperature (user_data,&iter[0], pos); //get CPU temperature.
}
pos++;
}
free (buf);
free (line);
free (ch);
//free (sysfs_max_cpu_freq_path);
fclose (cpufp);
return 0;
}
/* ... */
По просьбам трудящихся http://govnokod.ru/7979#comment116436
По коду:
1) хорошо бы проверять, что попытался выделить;
2) ошибка произошла успешно — начинаем парсить...;
3) для решения таких задач стоит обратить своё внимание на, например, PyGTK.
P.S. Если уж совсем не в мочь и к строкам так тянет,
то допилите под себя LiteC, у Г.Шилдта есть что подсмотреть.
+163
function moveIcon(ui,top) {
ob = ui["draggable"][0]["id"];
level = getIconsPlace(ob, top);
left = ((level-1) * step) + icon_down;
pos = getLeftPX(ob);
pos_level = 0;
// check icon position
if(pos < 58) {
pos_level = 0;
} else if(pos > 58 && pos < 83) {
pos_level = 1;
} else if(pos > 83 && pos < 108) {
pos_level = 2;
} else if(pos > 108 && pos < 133) {
pos_level = 3;
} else if(pos > 133 && pos < 158) {
pos_level = 4;
} else if(pos > 158) {
pos_level = 5;
}
pos_left = ((pos_level) * step) + icon_down;
left = ((level-1) * step) + icon_down;
if(left > pos_left) {
left = pos_left;
}
$("#" + ui["draggable"][0]["id"]).css("left", left + "px");
$("#" + ui["draggable"][0]["id"]).css("top", top + "px");
changePosition();
getResult();
}
Я думаю здесь без комментариев