- 1
- 2
- 3
- 4
jQuery(document).ready(function() {
var this = jQuery(this);
this.someMethod();
});
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+150
jQuery(document).ready(function() {
var this = jQuery(this);
this.someMethod();
});
"Почему-то не работает..."
+59
#ifndef PORT_H_
#define PORT_H_
#define MAKE_PORT(portName, ddrName, pinName, className, ID) \
class className{\
public:\
typedef uint8_t DataT; /* Alias for the type of data port*/\
private:\
static volatile DataT &data()\
{\
return portName;\
}\
static volatile DataT &dir()\
{\
return ddrName;\
}\
static volatile DataT &pin()\
{\
return pinName;\
}\
public:\
static void Write(DataT value) /*Write value to port PORT = value*/\
{\
data() = value;\
}\
static void ClearAndSet(DataT clearMask, DataT value) /*Clear by mask and set PORT = (PORT & ~clearMask) | value */\
{\
data() = (data() & ~clearMask) | value;\
}\
static DataT Read() /*Read the value written to the port*/\
{\
return data();\
}\
static void DirWrite(DataT value)/*Record the value of the direction of the lines I/O */\
{\
dir() = value;\
}\
static DataT DirRead() /*Read the value of the direction of the lines I/O */\
{\
return dir();\
}\
static void Set(DataT value) /*Set bits in the port PORT |= value;*/\
{\
data() |= value;\
}\
static void Clear(DataT value) /*Clear bits in the port PORT &= ~value;*/\
{\
data() &= ~value;\
}\
static void Togle(DataT value) /*Switch bits PORT ^= value;*/\
{\
data() ^= value;\
}\
static void DirSet(DataT value) /*Set direction bits*/\
{\
dir() |= value;\
}\
static void DirClear(DataT value) /*Clear direction bits*/\
{\
dir() &= ~value;\
}\
static void DirTogle(DataT value)\
{\
dir() ^= value;\
}\
static DataT PinRead()\
{\
return pin();\
}\
enum{Id = ID};\
enum{Width=sizeof(DataT)*8};/*Bit depth*/\
};
#ifdef PORTA
MAKE_PORT(PORTA, DDRA, PINA, Porta, 'A');
#endif
#ifdef PORTB
MAKE_PORT(PORTB, DDRB, PINB, Portb, 'B');
#endif
#ifdef PORTC
MAKE_PORT(PORTC, DDRC, PINC, Portc, 'C');
#endif
#ifdef PORTD
MAKE_PORT(PORTD, DDRD, PIND, Portd, 'D');
#endif
#endif /* PORT_H_ */
Использование СИ++ в микроконтроллерах доставляет....
+73
final double[][] matrix = new double[companies.size() + 1][(sampleSizeTo - sampleSizeFrom) / sampleSizeStep + 2];
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[0].length; j++) {
if (i == 0 && j == 0) {
continue;
}
if (i == 0) {
matrix[i][j] = sampleSizeFrom + (j - 1) * sampleSizeStep;
continue;
}
if (j == 0) {
matrix[i][j] = companies.get(i-1);
continue;
}
}
}
Название функции getSmartDistibution (именно так) какбэ намекает, что дальше будет весело
+134
Random random = new Random(Environment.TickCount);
for (int i = 0; i < random.Next(380, 480); i++)
{
Marshal.AllocHGlobal(random.Next(0x4400, 0xd400));
Thread.Sleep(1);
}
Из исходников подрядчика...
Заказчиков надо садить на иглу правильно
+135
if (currentItem.Type.ActiveProperty != null)
{
Type controltype = currentControl.GetType();
PropertyInfo pinfo = controltype.GetProperty(currentItem.Type.ActiveProperty.Name);
bool enabledtrue = (currentItem.Type.ActiveProperty.Name.ToLower() != "readonly");
if ((r1 != 2) || _page.ReadOnly)
enabledtrue = !enabledtrue;
pinfo.SetValue(currentControl, enabledtrue, null);
}
enabledtrue как пример интуитивно-понятного названия переменной
+154
$this->db->insert("orders", $data);
//Get order's id
$this->db->select("orders_id");
$this->db->where('orders_customer_tel', $data['tel']);
$this->db->order_by("orders_id", "desc");
$this->db->limit(1);
$query = $this->db->get("orders");
foreach ($query->result_array() as $res) {
$orders_id = $res['orders_id'];
}
Ништяяяк!
−131
[self
performSelectorOnMainThread: @selector(_blockCaller:)
withObject: ^{
[self _reportAchievement:achievement listener:listener];
}
waitUntilDone: YES
];
<...>
- (void) _blockCaller:(void(^)())blockHandler {
blockHandler();
}
GCD не в моде.
+154
<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>
<?if (!empty($arResult)):?>
<nav class="mainNav">
<table>
<tbody><tr>
<?
$i = 0;
$previousLevel = 0;
//echo '<pre>'; print_r($arResult); echo '</pre>';
$CatItemMenu = str_replace("/", "", $arResult[0]['LINK']);
foreach($arResult as $arItem):?>
<?$i++;?>
<?if ($previousLevel && $arItem["DEPTH_LEVEL"] < $previousLevel):?>
<?if($previousLevel != 3):?>
<?=str_repeat("</ul></li>", ($previousLevel - $arItem["DEPTH_LEVEL"]));?>
<?endif;?>
<?if($previousLevel == 3):?>
</li></ul>
<div class="someProduct" style="min-height: 336px;">
<a class="productLink" href="<?=$arResult["CATALOG_MENU"][$CatItemMenu]["DETAIL_PAGE_URL"]?>">
<span class="image"><img alt="" src="<?=$arResult["CATALOG_MENU"][$CatItemMenu]["PICTURE_SRC"]?>"></span>
<span><?=$arResult["CATALOG_MENU"][$CatItemMenu]["NAME"]?></span>
<?if($arResult["CATALOG_MENU"][$CatItemMenu]["SALE_PRICE"] < $arResult["CATALOG_MENU"][$CatItemMenu]["CATALOG_PRICE_1"]):?>
<span class="oldPrice"><?=$arResult["CATALOG_MENU"][$CatItemMenu]["CATALOG_PRICE_1"]?> руб.</span>
<span class="newPrice"><?=$arResult["CATALOG_MENU"][$CatItemMenu]["SALE_PRICE"]?> руб.</span>
<?else:?>
<span class="newPrice"><?=$arResult["CATALOG_MENU"][$CatItemMenu]["CATALOG_PRICE_1"]?> руб.</span>
<?endif;?>
</a> </div></div> <?endif;?> <?endif?><?if ($arItem["IS_PARENT"]):?> <?if ($arItem["DEPTH_LEVEL"] == 1):?>
<td><div><a href="<?=$arItem["LINK"]?>" class="<?if ($arItem["SELECTED"]):?>root-item-selected<?else:?>root-item<?endif?>"><?=$arItem["TEXT"]?></a>
<div class="test_mark" style=""><ul>
<?else:?>
<?if($arItem["DEPTH_LEVEL"] == 2):?>
<li><a href="<?=$arItem["LINK"]?>"><?=$arItem["TEXT"]?><ins>»</ins></a>
<div class="test_mark" style="min-height: 336px;"><ul style="min-height: 304px;">
<?else:?>
<li><a href="<?=$arItem["LINK"]?>" class="parent<?if ($arItem["SELECTED"]):?> item-selected<?endif?>"><?=$arItem["TEXT"]?></a>
<ul>
<?endif;?>
<?endif?>
<?else:?>
<?if ($arItem["PERMISSION"] > "D"):?>
<?if ($arItem["DEPTH_LEVEL"] == 1):?>
<li><a href="<?=$arItem["LINK"]?>" class="<?if ($arItem["SELECTED"]):?>root-item-selected<?else:?>root-item<?endif?>"><?=$arItem["TEXT"]?></a></li>
<?else:?>
<?if($arItem["DEPTH_LEVEL"] == 3):?>
<?//Танцы с бубном для вывода меню по два пункта. ?>
<?if($i%2):?>
<li>
<span><a href="<?=$arItem["LINK"]?>"><?=$arItem["TEXT"]?></a></span>
<?if($arResult[$i]["DEPTH_LEVEL"] == 3):?><span><a href="<?=$arResult[$i]["LINK"]?>"><?=$arResult[$i]["TEXT"]?></a></span><?endif;?>
<?if($arResult[$i-3]["DEPTH_LEVEL"] == 2 && $arItem["TEXT"] != $arResult[$i-1]["TEXT"]):?><span><a href="<?=$arResult[$i-1]["LINK"]?>"><?=$arResult[$i-1]["TEXT"]?></a></span><?endif;?>
<?endif;?>
<?if(!($i%2)):?></li><?endif;?>
<?//Танцы Окончены. ?>
<?else:?>
<li><a href="<?=$arItem["LINK"]?>" <?if ($arItem["SELECTED"]):?> class="item-selected"<?endif?>><?=$arItem["TEXT"]?></a></li>
<?endif;?>
<?endif?>
<?else:?>
<?if ($arItem["DEPTH_LEVEL"] == 1):?>
<li><a href="" class="<?if ($arItem["SELECTED"]):?>root-item-selected<?else:?>root-item<?endif?>" title="<?=GetMessage("MENU_ITEM_ACCESS_DENIED")?>"><?=$arItem["TEXT"]?></a></li>
<?else:?>
<li><a href="" class="denied" title="<?=GetMessage("MENU_ITEM_ACCESS_DENIED")?>"><?=$arItem["TEXT"]?></a></li>
<?endif?>
<?endif?>
<?endif?>
<?$previousLevel = $arItem["DEPTH_LEVEL"];?>
<?
//Добавляем товар
if($arItem["DEPTH_LEVEL"] == 1){
$ClearLink = str_replace("/", "", $arItem['LINK']);
$CatItemMenu = $ClearLink;
//echo $ClearLink.' - '.$previousLevel;
}
?>
<?endforeach?>
<?if ($previousLevel > 1)://close last item tags?>
<?=str_repeat("</ul>", ($previousLevel-1) );?>
<?endif?>
</tr>
</tbody></table>
</nav>
<?endif?>
Создадим меню и выведем его списком по два пункта.
+154
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($this->request->post['shipping_country_id']);
if ($country_info && $country_info['postcode_required'] && (utf8_strlen($this->request->post['shipping_postcode']) < 2) || (utf8_strlen($this->request->post['shipping_postcode']) > 10)) {
$json['error']['shipping']['postcode'] = $this->language->get('error_postcode');
}
if ($this->request->post['shipping_country_id'] == '') {
$json['error']['shipping']['country'] = $this->language->get('error_country');
}
if ($this->request->post['shipping_zone_id'] == '') {
$json['error']['shipping']['zone'] = $this->language->get('error_zone');
}
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($this->request->post['shipping_country_id']);
if ($country_info && $country_info['postcode_required'] && (utf8_strlen($this->request->post['shipping_postcode']) < 2) || (utf8_strlen($this->request->post['shipping_postcode']) > 10)) {
$json['error']['shipping']['postcode'] = $this->language->get('error_postcode');
}
строки 279 - 301
файл catalog/controller/checkout/manual.php
opencart 1.5.5.1.1
Зачем два идентичных куска кода (1 - 6 и 16 - 21), в одном файле идущих друг за другом, я так и не понял.
+160
if ( String(typeof Ext).toLowerCase() === "object") {
Ext.BLANK_IMAGE_URL = '/style/ext/resources/images/default/s.gif';
}
Ох. Штабильненько.