- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
#include <iostream>
#include <typeinfo>
struct Test {};
int main()
{
std::cout << typeid(int).name() << ", " << typeid(Test).name() << std::endl;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+64
#include <iostream>
#include <typeinfo>
struct Test {};
int main()
{
std::cout << typeid(int).name() << ", " << typeid(Test).name() << std::endl;
}
Очередные КРЕСТОПРОБЛЕМЫ.
MSVC: int, struct Test
GCC: i, 4Test
http://ideone.com/KPsIlP
Вот что говорит стандарт:
The class type_info describes type information generated by the implementation. Objects of this class effectively store a pointer to a name for the type, and an encoded value suitable for comparing two types for equality or collating order. The names, encoding rule, and collating sequence for types are all unspecified and may differ between programs.
RTTI ещё бесполезнее, чем я думала.
+125
http://coliru.stacked-crooked.com/a/a5ba510a2075393f
Под другим ником опубликовал чуть раньше:
http://govnokod.ru/12937
+132
rc = system
(
"test "
"`ls -1 $WORKDIR/somedir/ | wc -l` = 1"
" -a "
"`ls -1 $WORKDIR/somedir/*/somefiles.* | wc -l` = 1"
);
ASSERTM( rc != -1, "check for number of <dirs>" );
ASSERTM( rc == 0, "number of <some> files is greater than 1" );
по мотивам http://govnokod.ru/14374
из теста. да, можно было на С написать. да, мне было просто лень.
+128
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<dict>
<key>author</key>
<string>Nobody</string>
<key>name</key>
<string>my-theme</string>
<key>settings</key>
<array>
<!-- ... -->
<dict>
<key>name</key>
<string>Attribute</string>
<key>scope</key>
<string>entity.other.attribute-name</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#006E28</string>
</dict>
</dict>
<!-- ... -->
</array>
</dict>
</plist>
XML. Такой загадочный и энтерпрайзный.
// Цветовая схема для Sublime Text (или TextMate)
+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), в одном файле идущих друг за другом, я так и не понял.
+80
if (!getBaseContext().getResources().getConfiguration().locale.getLanguage().equals(((ApplicationController)getApplication()).lang) )
((ApplicationController)getApplication()).setLocale(((ApplicationController)getApplication()).lang);
Ехал дроид через дроид, видит дроид дроид дроид
+126
cnt_queue_files()->
Command = "ls "++code:lib_dir(messaging, priv)++" | grep -v ^l | wc -l",
case catch list_to_integer(string:strip(os:cmd(Command), right, $\n)) of
X when is_integer(X) -> X;
_ -> 0
end.
clear_queue_files()->
Command = "rm "++code:lib_dir(messaging, priv)++"/*",
os:cmd(Command).
create_empty_queue_file()->
Command = "touch "++code:lib_dir(messaging, priv)++"/~"++?COLD_HALT_EXCHANGE++".que",
os:cmd(Command).
Ну просто похапе какое-то.
+127
% restarter.erl
-module(restarter).
% Save it to restart the node!
% где-то в коде при запуске приложения
....
ok = sync:go(),
sync:onsync(fun(Mods) ->
case lists:member(restarter, Mods) of
true ->
lager:warning("Restarting node!"),
init:restart();
_ -> ok
end
end),
....
Клуб веселых и находчивых эрлангеров.
Придумал такую фичу: если мне во время разработки надо перезапустить тестовую ноду, я просто жму сохранить в открытом файле restarter.erl
Sync подхватывает пересохраненный файл, компилит его и вызывает коллбэк со списком измененных модулей. Собственно, если рестартер среди них, то нода перезапускается :)
+150
$up = mysql_fetch_array (mysql_query("SELECT name FROM locations WHERE id='p_".$x."_".($y-1)."_'"));
$down = mysql_fetch_array (mysql_query("SELECT name FROM locations WHERE id='p_".$x."_".($y+1)."_'"));
$right = mysql_fetch_array (mysql_query("SELECT name FROM locations WHERE id='p_".($x+1)."_".($y)."_'"));
$left = mysql_fetch_array (mysql_query("SELECT name FROM locations WHERE id='p_".($x-1)."_".($y)."_'"));
$lup = mysql_fetch_array (mysql_query("SELECT name FROM locations WHERE id='p_".($x-1)."_".($y-1)."_'"));
$rup = mysql_fetch_array (mysql_query("SELECT name FROM locations WHERE id='p_".($x+1)."_".($y-1)."_'"));
$rdown = mysql_fetch_array (mysql_query("SELECT name FROM locations WHERE id='p_".($x+1)."_".($y+1)."_'"));
$ldown = mysql_fetch_array (mysql_query("SELECT name FROM locations WHERE id='p_".($x-1)."_".($y+1)."_'"));
if (@$up["name"]) $up = 1; else $up=0;
if (@$down["name"]) $down = 1; else $down=0;
if (@$right["name"]) $right = 1; else $right=0;
if (@$left["name"]) $left = 1; else $left=0;
if (@$lup["name"]) $lup = 1; else $lup=0;
if (@$rup["name"]) $rup = 1; else $rup=0;
if (@$rdown["name"]) $rdown = 1; else $rdown=0;
if (@$ldown["name"]) $ldown = 1; else $ldown=0;
if ($_GET["go_nature"]=='up' and $up==1) $y-=1;
if ($_GET["go_nature"]=='down' and $down==1) $y+=1;
if ($_GET["go_nature"]=='left' and $left==1) $x-=1;
if ($_GET["go_nature"]=='right' and $right==1) $x+=1;
if ($_GET["go_nature"]=='lup' and $lup==1) $x-=1;
if ($_GET["go_nature"]=='rup' and $rup==1) $x+=1;
if ($_GET["go_nature"]=='lup' and $lup==1) $y-=1;
if ($_GET["go_nature"]=='rup' and $rup==1) $y-=1;
if ($_GET["go_nature"]=='rdown' and $rdown==1) $x+=1;
if ($_GET["go_nature"]=='ldown' and $ldown==1) $x-=1;
if ($_GET["go_nature"]=='rdown' and $rdown==1) $y+=1;
if ($_GET["go_nature"]=='ldown' and $ldown==1) $y+=1;
вксняшка
+79
if(VovaJSONparser.ParseText(d, text))
{
return d;
}
Вова, фас!