- 1
header("HTTP/1.1 404 OK");
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+170
header("HTTP/1.1 404 OK");
+142
<?php
class ModelCheckoutOrder extends Model {
public function addOrder($data) {
$this->event->trigger('pre.order.add', $data);
$this->db->query("INSERT INTO `" . DB_PREFIX . "order` SET invoice_prefix = '" . $this->db->escape($data['invoice_prefix']) . "', store_id = '" . (int)$data['store_id'] . "', store_name = '" . $this->db->escape($data['store_name']) . "', store_url = '" . $this->db->escape($data['store_url']) . "', customer_id = '" . (int)$data['customer_id'] . "', customer_group_id = '" . (int)$data['customer_group_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', custom_field = '" . $this->db->escape(isset($data['custom_field']) ? serialize($data['custom_field']) : '') . "', payment_firstname = '" . $this->db->escape($data['payment_firstname']) . "', payment_lastname = '" . $this->db->escape($data['payment_lastname']) . "', payment_company = '" . $this->db->escape($data['payment_company']) . "', payment_address_1 = '" . $this->db->escape($data['payment_address_1']) . "', payment_address_2 = '" . $this->db->escape($data['payment_address_2']) . "', payment_city = '" . $this->db->escape($data['payment_city']) . "', payment_postcode = '" . $this->db->escape($data['payment_postcode']) . "', payment_country = '" . $this->db->escape($data['payment_country']) . "', payment_country_id = '" . (int)$data['payment_country_id'] . "', payment_zone = '" . $this->db->escape($data['payment_zone']) . "', payment_zone_id = '" . (int)$data['payment_zone_id'] . "', payment_address_format = '" . $this->db->escape($data['payment_address_format']) . "', payment_custom_field = '" . $this->db->escape(isset($data['payment_custom_field']) ? serialize($data['payment_custom_field']) : '') . "', payment_method = '" . $this->db->escape($data['payment_method']) . "', payment_code = '" . $this->db->escape($data['payment_code']) . "', shipping_firstname = '" . $this->db->escape($data['shipping_firstname']) . "', shipping_lastname = '" . $this->db->escape($data['shipping_lastname']) . "', shipping_company = '" . $this->db->escape($data['shipping_company']) . "', shipping_address_1 = '" . $this->db->escape($data['shipping_address_1']) . "', shipping_address_2 = '" . $this->db->escape($data['shipping_address_2']) . "', shipping_city = '" . $this->db->escape($data['shipping_city']) . "', shipping_postcode = '" . $this->db->escape($data['shipping_postcode']) . "', shipping_country = '" . $this->db->escape($data['shipping_country']) . "', shipping_country_id = '" . (int)$data['shipping_country_id'] . "', shipping_zone = '" . $this->db->escape($data['shipping_zone']) . "', shipping_zone_id = '" . (int)$data['shipping_zone_id'] . "', shipping_address_format = '" . $this->db->escape($data['shipping_address_format']) . "', shipping_custom_field = '" . $this->db->escape(isset($data['shipping_custom_field']) ? serialize($data['shipping_custom_field']) : '') . "', shipping_method = '" . $this->db->escape($data['shipping_method']) . "', shipping_code = '" . $this->db->escape($data['shipping_code']) . "', comment = '" . $this->db->escape($data['comment']) . "', total = '" . (float)$data['total'] . "', affiliate_id = '" . (int)$data['affiliate_id'] . "', commission = '" . (float)$data['commission'] . "', marketing_id = '" . (int)$data['marketing_id'] . "', tracking = '" . $this->db->escape($data['tracking']) . "', language_id = '" . (int)$data['language_id'] . "', currency_id = '" . (int)$data['currency_id'] . "', currency_code = '" . $this->db->escape($data['currency_code']) . "', currency_value = '" . (float)$data['currency_value'] . "', ip = '" . $this->db->escape($data['ip']) . "', forwarded_ip = '" . $this->db->escape($data['forwarded_ip']) . "', user_agent = '" . $this->db->escape($data['user_agent']) . "', accept_language = '" . $this->db->escape($data['accept_language']) . "', date_added = NOW(), date_modified = NOW()");
Я вас еще немного помучаю, хорошо?
3978 символов, считая отступы
https://github.com/opencart/opencart/blob/d5f66b0d75a5adf35815e333e45598bbc38750d0/upload/catalog/model/checkout/order.php#L6
+147
void Write_Char(char ch)
{
switch(ch)
{
case 'a':
{
set_mode_data;
set_db4_0;
set_db5_1;
set_db6_1;
set_db7_0;
strobe();
set_mode_data;
set_db4_1;
set_db5_0;
set_db6_0;
set_db7_0;
strobe();
return;
}
case 'b':
{
set_mode_data;
set_db4_0;
set_db5_1;
set_db6_1;
set_db7_0;
strobe();
set_mode_data;
set_db4_0;
set_db5_1;
set_db6_0;
set_db7_0;
strobe();
return;
}
case 'c':
{
set_mode_data;
set_db4_0;
set_db5_1;
set_db6_1;
set_db7_0;
strobe();
set_mode_data;
set_db4_1;
set_db5_1;
set_db6_0;
set_db7_0;
strobe();
return;
}
case 'd':
{
set_mode_data;
set_db4_0;
set_db5_1;
set_db6_1;
set_db7_0;
strobe();
set_mode_data;
set_db4_0;
set_db5_0;
set_db6_1;
set_db7_0;
strobe();
return;
}
case 'e':
{
set_mode_data;
set_db4_0;
set_db5_1;
set_db6_1;
set_db7_0;
strobe();
set_mode_data;
set_db4_1;
set_db5_0;
set_db6_1;
set_db7_0;
strobe();
return;
}
case 'f':
{ set_mode_data;
set_db4_0;
set_db5_1;
set_db6_1;
set_db7_0;
strobe();
set_mode_data;
set_db4_0;
set_db5_1;
set_db6_1;
set_db7_0;
strobe();
return;
}
//еще ~800 строк.
Ну почему тут только 100 строк можно вводить? Я хочу поделиться этим со всем миром, ведь это так легко - наговнокодить на Си.(из программы общения с дисплеем hd44780 для STM32)
+142
if ((subchannel == undefined || "none") && (subsubchannel == undefined || "none")) {
subchannel = channel;
subsubchannel = subchannel;
} else if ((subchannel != undefined || "none") && (subsubchannel == undefined || "none")) {
subsubchannel = subchannel;
} else if ((subchannel == undefined || "none") && (subsubchannel != undefined || "none")) {
subchannel = channel;
} else {
subchannel = subchannel;
channel = channel;
}
Скопировал из похожего проекта не глядя, и потом удевляюсь что херня получается. А там ведь как-то работает, бля...
+142
#include <inttypes.h>
#include <stdio.h>
typedef union
{
struct
{
#define BITG(n) uint8_t bit##n : 1
BITG(0);
BITG(1);
BITG(2);
BITG(3);
BITG(4);
BITG(5);
BITG(6);
BITG(7);
#undef BITG
} bits;
uint8_t value;
}getbit;
uint8_t bit_sum(uint8_t, uint8_t);
uint8_t bit_sum(uint8_t a, uint8_t b)
{
getbit op1, op2, opr;
uint8_t carry;
op1.value=a; op2.value=b;
#define OP1(n) op1.bits.bit##n
#define OP2(n) op2.bits.bit##n
#define OPR(n) opr.bits.bit##n
#define XOR(a,b) ((a)^(b))
#define AND(a,b) ((a)&(b))
OPR(0) = XOR(OP1(0), OP2(0));
carry = AND(OP1(0), OP2(0));
#define SETBIT(n) \
OPR(n) = XOR \
( \
carry, \
XOR(OP1(n), OP2(n)) \
);
#define CARRYBIT(n) \
carry = XOR \
( \
AND(OP1(n), OP2(n)), \
AND \
( \
XOR(OP1(n), OP2(n)), \
carry \
) \
);
SETBIT(1);
CARRYBIT(1);
SETBIT(2);
CARRYBIT(2);
SETBIT(3);
CARRYBIT(3);
SETBIT(4);
CARRYBIT(4);
SETBIT(5);
CARRYBIT(5);
SETBIT(6);
CARRYBIT(6);
SETBIT(7);
return opr.value;
#undef SETBIT
#undef CARRYBIT
#undef OP1
#undef OP2
#undef OPR
#undef XOR
#undef AND
}
int main (int argc, char *argv[], char *envp[])
{
uint8_t a, b, c;
scanf ("%"SCNu8"%"SCNu8, &a, &b);
c = bit_sum(a,b);
printf("%"PRIu8"\n", c);
return 0;
}
Побитовое сложение двух 8-битных чисел по схеме двоичного сумматора
+135
Кажется сбылась чья-то мечта. Калькулятор на чистом css
http://habrahabr.ru/company/paysto/blog/255511/
http://experiments.hertzen.com/css3calculator/
+890
Int64 iObjectId;
public Int64 ObjectId
{
get { return iObjectId; }
set {
if (iObjectId == null) { value = 0; } else value = iObjectId;
}
}
Помимо того, что условие (iObjectId == null) никогда не выполняется, сеттер еще и делает свойство ObjectId фактически readonly.
(Авторское форматирование кода сохранено.)
−124
if __name__ == "__main__":
def f():
pass
Динамичненько
−117
self.symbol_ban = {".":".00", "!":".01", "@":".02", "#":".03", "$":".04", "%":".05", "^":".06",
"&":".07", "*":".08", "+":".09", "\n":".10", "\t":".11", "\"":".12", "\'":".13",
"/":".14", "<":".15", ">":".16", '`':".17", '\\':".19", " ":".20", "=":".21",
"(":".22", ")":".23"}
new_path = map((lambda x, y: [x, y]), ["a_"+"".join([j if (j not in self.symbol_ban) else self.symbol_ban[j] for j in i[0]]) for i in path], [j[1] if j[1] in ("dir", "file") else self.Ex(1) for j in path])
часть sax парсера xml для экранирования входных данных, писал для бакалаврской. диплом отдали
−352
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
if (indexPath.row == self.titles.count - 1)
{
cell = [tableView dequeueReusableCellWithIdentifier:@"settingButtonCell" forIndexPath:indexPath];
SWSettingButtonCell *scell = (SWSettingButtonCell *) cell;
[scell.settingButton setTitleForAllStates:self.titles[indexPath.row]];
[scell.settingButton bk_removeEventHandlersForControlEvents:UIControlEventTouchUpInside];
scell.settingIcon.visible = YES;
@weakify(self);
[scell.settingButton bk_addEventHandler:^(id sender) {
[UIAlertView bk_showAlertViewWithTitle:@"Logout"
message:@"Do you want to logout?"
cancelButtonTitle:@"NO"
otherButtonTitles:@[@"YES"]
handler:^(UIAlertView *alertView, NSInteger buttonIndex) {
@strongify(self);
if (buttonIndex != 0)
{
[[SWCore instance] logout];
// fix
[SVProgressHUD show];
// end fix
}
}];
} forControlEvents:UIControlEventTouchUpInside];
}
else if (indexPath.row == self.titles.count - 2)
{
cell = [tableView dequeueReusableCellWithIdentifier:@"settingButtonCell" forIndexPath:indexPath];
SWSettingButtonCell *scell = (SWSettingButtonCell *) cell;
[scell.settingButton setTitleForAllStates:self.titles[indexPath.row]];
[scell.settingButton bk_removeEventHandlersForControlEvents:UIControlEventTouchUpInside];
scell.settingIcon.visible = NO;
@weakify(self);
[scell.settingButton bk_addEventHandler:^(id sender) {
@strongify(self);
[self performSegueWithIdentifier:@"pushSettingsSegue" sender:nil];
} forControlEvents:UIControlEventTouchUpInside];
}
else
{
cell = [tableView dequeueReusableCellWithIdentifier:@"settingCell" forIndexPath:indexPath];
SWSettingCell *scell = (SWSettingCell *) cell;
scell.settingLabel.text = self.titles[indexPath.row];
[scell.settingIcon setImage:self.icons[indexPath.row]];
switch (indexPath.row)
{
case 0:
{
scell.settingSwitch.on = [[SWCore account].settings[[NSString stringWithFormat:SETTINGS_PROFILE_VISIBILITY]] isEqualToString:SETTING_PUBLIC];
scell.settingIcon.image = scell.settingSwitch.isOn ? [UIImage imageNamed:@"settings_profile_icon_on"] : [UIImage imageNamed:@"settings_profile_icon_off"];
}
break;
case 1:
{
scell.settingSwitch.on = [[SWCore account].settings[[NSString stringWithFormat:SETTINGS_EVENTS_VISIBILITY]] isEqualToString:SETTING_PUBLIC];
scell.settingIcon.image = scell.settingSwitch.isOn ? [UIImage imageNamed:@"settings_events_button_on"] : [UIImage imageNamed:@"settings_events_button_off"];
}
break;
case 2:
{
scell.settingSwitch.on = [[SWCore account].settings[[NSString stringWithFormat:SETTINGS_PHONE_VISIBILITY]] isEqualToString:SETTING_PUBLIC];
scell.settingIcon.image = scell.settingSwitch.isOn ? [UIImage imageNamed:@"settings_phone_button_on"] : [UIImage imageNamed:@"settings_phone_button_off"];
}
break;
case 3:
{
scell.settingSwitch.on = [[SWCore account].settings[[NSString stringWithFormat:SETTINGS_PHOTOS_VISIBILITY]] isEqualToString:SETTING_PUBLIC];
scell.settingIcon.image = scell.settingSwitch.isOn ? [UIImage imageNamed:@"settings_photos_button_on"] : [UIImage imageNamed:@"settings_photos_button_off"];
}
break;
default:
break;
}
scell.settingSwitch.tag = indexPath.row;
[scell.settingSwitch bk_removeEventHandlersForControlEvents:UIControlEventValueChanged];
Один из самых классных методов cellForRowAtIndexPath что я когда-либо видел