- 1
- 2
- 3
%% Evaluate function Func() for all subscribers to Key
public_message(SubscrPid, Message) ->
gen_server:cast(SubscrPid, {public_message, Message}).
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+126
%% Evaluate function Func() for all subscribers to Key
public_message(SubscrPid, Message) ->
gen_server:cast(SubscrPid, {public_message, Message}).
К слову об актуальных комментариях.
+161
static function anyToTimestamp($date) {
// 2009-09-03 12:10:55
if (preg_match('/^([0-9]{4})\-([0-9]{2})\-([0-9]{2})(?: ([0-9]{2})\:([0-9]{2})\:([0-9]{2}))?$/', $date, $arr)) {
$ts = mktime($arr[4], $arr[5], $arr[6], $arr[2], $arr[3], $arr[1]);
// 03.04.2008 10:12:11
} elseif (preg_match('/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})(?: ([0-9]{1,2})\:([0-9]{1,2})(?:\:([0-9]{2}))?)?$/', $date, $arr)) {
$ts = mktime($arr[4], $arr[5], $arr[6], $arr[2], $arr[1], $arr[3]);
// MySQL timestamp YYYYMMDDHHMISS
} elseif (preg_match('/^\d{14}$/', $date)) {
$ts = mktime(substr($string, 8, 2), substr($string, 10, 2), substr($string, 12, 2), substr($string, 4, 2), substr($string, 6, 2),
substr($string, 0, 4));
// PHP timestamp
} elseif (is_int($date)) {
$ts = $date;
// давно заметил, что предыдущее условие не всегда срабатывает. добавил условие ниже. если передается timestamp 100% сработает
}elseif(strlen((int)$date)>=10 && is_int((int)$date)) {
$ts = $date;
}
return ($ts && $ts!=-1)?$ts:null;
}
Копаюсь как обычно в проекте, а этот довольно большой на протяжении нескольких лет над ним трудились разные программисты.
Причем бывает читаю смешные комментарии.
Однако весь смысл не в этом как вы уже поняли.
−117
//try setting up POST request, if failed settle with GET
try {
if (url_variables == null || (params && params.method == URLRequestMethod.GET)) throw new ArgumentError();
url_request.data = url_variables;
url_request.method = URLRequestMethod.POST;
}
catch(er:Error) {
url_request.url = url;
url_request.method = URLRequestMethod.GET;
}
Ветвление с помощью try..catch.
Возьму себе на заметку.
+141
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
//Перегруженый метод Paint
//Если нужно будет работать с графиксом в других методах (рисовать на нем в других методах)
//сделайте его глобальным
//Graphics gr = this.CreateGraphics();//Создаем объект графикс из окна
Graphics gr = e.Graphics;
int w = this.ClientSize.Width;//размеры клиентской области
int h = this.ClientSize.Height;//размеры клиентской области
int widthLines = 20;//Ширина клетки
int heightLines = 20;//Высота клетки
for(int i = 0; i < w; i += widthLines)
{
//Вертикальные линии
gr.DrawLine(new Pen(Brushes.Blue), new Point(i + widthLines, 0), new Point(i + widthLines, h));
//Горизонтальные линии
gr.DrawLine(new Pen(Brushes.Blue), new Point(0, i + heightLines), new Point(w, i + heightLines));
}
//Graphics gr = e.Graphics;
graf_func();
Pen p = new Pen(Color.Red, 3);// цвет линии и ширина
Point p1 = new Point(10, data_graf_x[0]);// первая точка
Point p2 = new Point(20, data_graf_x[1]);// вторая точка 1-y 2-x 1
Point p3 = new Point(30, data_graf_x[2]);// вторая точка 1-y 2-x 2
Point p4 = new Point(40, data_graf_x[3]);// вторая точка 1-y 2-x 3
Point p5 = new Point(50, data_graf_x[4]);// вторая точка 1-y 2-x
Point p6 = new Point(60, data_graf_x[5]);// вторая точка 1-y 2-x
Point p7 = new Point(70, data_graf_x[6]);// вторая точка 1-y 2-x
Point p8 = new Point(80, data_graf_x[7]);// вторая точка 1-y 2-x
Point p9 = new Point(90, data_graf_x[8]);// вторая точка 1-y 2-x
Point p10 = new Point(100, data_graf_x[9]);// вторая точка 1-y 2-x
Point p11 = new Point(110, data_graf_x[10]);// вторая точка 1-y 2-x
Point p12 = new Point(120, data_graf_x[11]);// вторая точка 1-y 2-x
Point p13 = new Point(130, data_graf_x[12]);// вторая точка 1-y 2-x
Point p14 = new Point(140, data_graf_x[13]);// вторая точка 1-y 2-x
Point p15 = new Point(150, data_graf_x[14]);// вторая точка 1-y 2-x
Point p16 = new Point(160, data_graf_x[15]);// вторая точка 1-y 2-x
Point p17 = new Point(170, data_graf_x[16]);// вторая точка 1-y 2-x
Point p18 = new Point(180, data_graf_x[17]);// вторая точка 1-y 2-x
Point p19 = new Point(190, data_graf_x[18]);// вторая точка 1-y 2-x
Point p20 = new Point(200, data_graf_x[19]);// вторая точка 1-y 2-x
Point p21 = new Point(210, data_graf_x[20]);// вторая точка 1-y 2-x
Point p22 = new Point(220, data_graf_x[21]);// первая точка
Point p23 = new Point(230, data_graf_x[22]);// вторая точка 1-y 2-x 1
Point p24 = new Point(240, data_graf_x[23]);// вторая точка 1-y 2-x 2
Point p25 = new Point(250, data_graf_x[24]);// вторая точка 1-y 2-x 3
Point p26 = new Point(260, data_graf_x[25]);// вторая точка 1-y 2-x
Point p27 = new Point(270, data_graf_x[26]);// вторая точка 1-y 2-x
Point p28 = new Point(280, data_graf_x[27]);// вторая точка 1-y 2-x
Point p29 = new Point(290, data_graf_x[28]);// вторая точка 1-y 2-x
Point p30 = new Point(300, data_graf_x[29]);// вторая точка 1-y 2-x
Point p31 = new Point(310, data_graf_x[30]);// вторая точка 1-y 2-x
//...
Point p180 = new Point(900, data_graf_y[89]);// вторая точка 1-y 2-x
Point[] my_point =
{
p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23,p24,p25,p26,p27,p28,p29,p30,
p31,p32,p33,p34,p35,p36,p37,p38,p39,p40,p41,p42,p43,p44,p45,p46,p47,p48,p49,p50,p51,p52,p53,p54,p55,p56,p57,p58,p59,p60,
p61,p62,p63,p64,p65,p66,p67,p68,p69,p70,p71,p72,p73,p74,p75,p76,p77,p78,p79,p80,p81,p82,p83,p84,p85,p86,p87,p88,p89,p90
};
Point[] my_point1 =
{
p91,p92,p93,p94,p95,p96,p97,p98,p99,p100,p101,p102,p103,p104,p105,p106,p107,p108,p109,p110,p111,p112,p113,p114,p115,p116,p117,p118,p119,p120,
p121,p122,p123,p124,p125,p126,p127,p128,p129,p130,p131,p132,p133, p134,p135,p136,p137,p138,p139,p140,p141,p142,p143,p144,p145,p146,p147,p148,p149,p150,
p151,p152,p153,p154,p155,p156,p157,p158,p159,p160,p161,p162,p163,p164,p165,p166,p167,p168,p169,p170,p171,p172,p173,p174,p175,p176,p177,p178,p179,p180
};
p180... мама дорогая... Боюсб даже представить, сколько временина это ушло, не говоря про ресурс клавиш ctlr, c и v.
При попытке добавить хотя бы 100 строк (из 200) пишет "Такой длинный код врядли может быть смешным. Пожалуйста, ограничьтесь сотней строк и 6000 символами."
Даже забавно
источник творения
http://www.cyberforum.ru/csharp-beginners/thread1069910.html
+130
foreach($filenames as $fk => $fv) {
if($noBootStrap) {
$pos = strpos($fv->filename, 'bootstrap');
if($pos === false) {} else {
continue;
}
}
...
if ($fv->menulink != '') {
$menuLinks = explode(',', $fv->menulink);
$isIncluded = in_array((int)$itemid, $menuLinks);
if ($isIncluded) {
JHtml::stylesheet($path . $fv->filename );
}
} else {
JHtml::stylesheet($path . $fv->filename );
}
}
@copyright Copyright (C) Jan Pavelka www.phoca.cz
Я плакал...
+153
$db = new Db();
$db->prepare('SELECT `ID`, `Title`, `Date`, `Active` FROM `videos` WHERE `UserID` = :userId AND `is_temporary` = 0 ORDER BY `Date` DESC')
->bindInt(':userId', $userId)
->execute();
$dbResult = $db->fetchAll();
if (empty($dbResult)) return array();
$orderDir = strtoupper($orderDir);
if (!in_array($orderDir, array('DESC', 'ASC'))) $orderDir = 'DESC';
if (empty($filter) && $orderDir == 'DESC') return ArrayHelper::extract($dbResult, 'ID', ArrayHelper::INT);
$db->prepare('CREATE TEMPORARY TABLE `videos_tmp` (
`id` INT(11),
`title` VARCHAR(256),
`date` DATETIME,
`active` VARCHAR(1)
) ENGINE = MEMORY
CHARACTER SET utf8
COLLATE utf8_general_ci')
->execute();
foreach ($dbResult as $row) {
$db->prepare('INSERT INTO `videos_tmp` (`id`, `title`, `date`, `active`) VALUES (:id, :title, :date, :active)')
->bindInt(':id', $row['ID'])
->bindStr(':title', $row['Title'])
->bindStr(':date', $row['Date'])
->bindStr(':active', $row['Active'])
->execute();
}
$sql = 'SELECT `id` FROM `videos_tmp` WHERE 1';
if (isset($filter['active'])) $sql .= ' AND `Active` = :active';
if (isset($filter['search'])) $sql .= ' AND `title` LIKE :search';
if (isset($filter['fromDate'])) $sql .= ' AND `Date` >= :fromDate';
if (isset($filter['toDate'])) $sql .= ' AND `Date` <= :toDate';
$sql .= ' ORDER BY `Date` ' . $orderDir;
$stmt = $db->prepare($sql);
if (isset($filter['active'])) $stmt->bindStr(':active', $filter['active']);
if (isset($filter['search'])) $stmt->bindStr(':search', '%' . $filter['search'] . '%');
if (isset($filter['fromDate'])) $stmt->bindStr(':fromDate', $filter['fromDate']);
if (isset($filter['toDate'])) $stmt->bindStr(':toDate', $filter['toDate']);
$stmt->execute();
$dbResult = $db->fetchAll();
$db->prepare('DROP TABLE `videos_tmp`')->execute();
Извиняюсь, что так много, но какого слоника надо было делать выборку, создавать временную таблицу и делать выборку снова - загадка.
+154
var i1id = setInterval(function () {
$('#step-2 table.step-1-top-tabs td#images').addClass('tab-selected');
$('#step-2 table.step-1-top-tabs td#images').click();
clearInterval(i1id);
}, 100);
О функции setTimeout не слышали.
−83
setRegState :: RegisterStates -> M_Register -> Word8 -> RegisterStates
setRegState rs r n =
let (a, b, c, d, e, f, h, l, pc, sp) = rs in
case r of
M_A -> (n, b, c, d, e, f, h, l, pc, sp)
M_B -> (a, n, c, d, e, f, h, l, pc, sp)
M_C -> (a, b, n, d, e, f, h, l, pc, sp)
M_D -> (a, b, c, n, e, f, h, l, pc, sp)
M_E -> (a, b, c, d, n, f, h, l, pc, sp)
M_F -> (a, b, c, d, e, n.&.0xF0, h, l, pc, sp)
M_H -> (a, b, c, d, e, f, n, l, pc, sp)
M_L -> (a, b, c, d, e, f, h, n, pc, sp)
Haskell has no boilerplate.
Из исходников заброшенного эмулятора GameBoy (https://github.com/bitc/omegagb/)
+148
<link rel="stylesheet" href="css/css.css" type="text/css" />
Ехал Гитлер через Гитлер,
Гитлер Гитлер Гитлер Гитлер!
+126
Пони тред!
Поняшки!