- 1
- 2
if (suspended())
resume();
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+162
if (suspended())
resume();
http://www.gamedev.ru/code/forum/?id=152077
+78
getText(
wifiStates[
Settings.getLocationService( ) == null || !Settings.isCellConfigEnabled( ) ? LED_OFF
: Settings.isNetworkLocationEnabled( ) ? LED_ON
: LED_ERROR
] ), Toast.LENGTH_SHORT )
.show( );
Кусочек кода из приложения для андроида, которое придется поддерживать.... 0_0
−119
private function onEnterFrame(e:Event):void {
if (success)
{
}
else
{
}
}
24 раза в секунду: "У вас всё хорошо? Вот и славно. Всё плохо? Да и чёрт с ним."
−109
for (var i:int = 0; i < _levelingScores[i]; i++)
Три дня багу искал :D Подумываю сходить к доктору.
+156
/**
* форматирование даты - преобразует дату в формат ДД-ММ-ГГГГ
*
* @param unknown_type $inDate - дата
* @return unknown
*/
public static function getDateFormatted($inDate, $forView = false, $inTime = '') {
//2011-05-03 20:27:26
$a_tmp = explode(' ', $inDate);
if ($forView) {
$time = substr($a_tmp[1], 0, 5);
if ($a_tmp[0] == date('Y-m-d')) {
if ($time == '') {
$time = substr($inTime, 11, 5);
if ($time == '') {
$time = $inTime;
}
}
if ($time != '') {
return 'Сегодня, ' . $time;
}
}
$a_tmp = explode('-', $a_tmp[0]);
return $a_tmp[2] . '-' . $a_tmp[1] . '-' . $a_tmp[0];
}
$inDate = substr($inDate, 0 , 10);
$inDate = str_replace(' ', '', $inDate);
$inDate = str_replace('.', '-', $inDate);
$a_tmp = explode('-', $inDate);
if (strlen($a_tmp[0]) == 4) {
$inDate = str_pad($a_tmp[2], 2, '0', STR_PAD_LEFT) . '-' . $a_tmp[1] . '-' . $a_tmp[0];
}
return $inDate;
}
+165
function show_price_list() {
$period_1 = $period_2 = $period_3 = $period_4 = $period_5 = $period_6 = "";
$query = "
SELECT id, price, type
FROM price
ORDER BY type, start
";
$this->registry['sql']->query($query);
if ($this->registry['sql']->getNumberRows()>0) {
foreach ($this->registry['sql']->getFetchObject() as $oRow) {
switch($oRow->type) {
case 0: $period_1 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
break;
case 1: $period_2 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
break;
case 2: $period_3 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
break;
case 3: $period_4 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
break;
case 4: $period_5 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
break;
case 5: $period_6 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
break;
}
}
}
@$this->registry['template']->set('period_1', $period_1);
@$this->registry['template']->set('period_2', $period_2);
@$this->registry['template']->set('period_3', $period_3);
@$this->registry['template']->set('period_4', $period_4);
@$this->registry['template']->set('period_5', $period_5);
@$this->registry['template']->set('period_6', $period_6);
}
Модель в шаблоне MVC
+159
if (strlen($_POST["NEW_PASSWORD"]) <= 0)
$arResult["ERROR"][] = GetMessage("STOF_ERROR_REG_FLAG1");
if (strlen($_POST["NEW_PASSWORD"]) > 0 && strlen($_POST["NEW_PASSWORD_CONFIRM"]) <= 0)
$arResult["ERROR"][] = GetMessage("STOF_ERROR_REG_FLAG1");
if (strlen($_POST["NEW_PASSWORD"]) > 0
&& strlen($_POST["NEW_PASSWORD_CONFIRM"]) > 0
&& $_POST["NEW_PASSWORD"] != $_POST["NEW_PASSWORD_CONFIRM"])
$arResult["ERROR"][] = GetMessage("STOF_ERROR_REG_PASS");
Взято из Битрикса /bitrix/components/bitrix/sale.order.ajax/component.php
Потрясающие идентификаторы мессаджей. Ну а то, что прочитать код без слома глаз нельзя отдельная песня.
В целом там такого внутри много.
+174
function get_field_by_id($tbl,$field,$id){ //получить field по id
$res=mysql_query($v="SELECT * FROM $tbl where `id`=$id");
$rez=mysql_fetch_array($res);
return $rez["$field"];
}
+164
function prepare_graph_query($query, $date_column, $date_format="%b %d") {
$date_format = empty($date_format) ? "%Y %b" : $date_format;
//...
}
+157
function utf8win1251($s){
$out=""; $c1=""; $byte2=false;
for ($c=0;$c<strlen($s);$c++){
$i=ord($s[$c]); if ($i<=127) $out.=$s[$c];
if ($byte2) { $new_c2=($c1&3)*64+($i&63); $new_c1=($c1>>2)&5;
$new_i=$new_c1*256+$new_c2;
if ($new_i==1025) $out_i=168; else
if ($new_i==1105) $out_i=184; else $out_i=$new_i-848;
$out.=chr($out_i); $byte2=false; }
if (($i>>5)==6) {$c1=$i;$byte2=true; } }
return $out; }
Я ничо не понял, но это круто.
http://letopisi.ru/index.php/Знаете-ли-что%3F_скрипт