- 1
- 2
- 3
- 4
#define loopv(v) for(int i = 0; i<(v).length(); i++)
#define loopvj(v) for(int j = 0; j<(v).length(); j++)
#define loopvk(v) for(int k = 0; k<(v).length(); k++)
#define loopvrev(v) for(int i = (v).length()-1; i>=0; i--)
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+168
#define loopv(v) for(int i = 0; i<(v).length(); i++)
#define loopvj(v) for(int j = 0; j<(v).length(); j++)
#define loopvk(v) for(int k = 0; k<(v).length(); k++)
#define loopvrev(v) for(int i = (v).length()-1; i>=0; i--)
Может я чего недопонимаю?
Это из Cube 2: Sauerbraten
+168
function m($s, $re)
{
return preg_match($re, $s);
}
Из какого-то движка такая вот функа в файле function.php
+168
$(document).ready(function(){
$("table.h100").parent('td').each(function(){
$(this).children('table.h100').css({'height' : $(this).height()});
});
});
Говнокод умер - да здравствует говнокод! :)
+168
if(substr($_SERVER['QUERY_STRING'],0,9)==='act=const')
Вот так мы получаем GET данные из адресной строки
+168
function format_number($param) {
$array_number = explode('.', $param);
if (!isset($array_number[1])) {
echo $array_number[0].'.00';
} else {
echo $param;
}
}
Я задал ПХПисту задачку, чтобы он выводил цифры в таблице с 2 знаками после запятой.
+168
define('Min2Sec',60);
define('Hour2Sec',3600);
define('Day2Sec',86400);
define('int','integer');
define('real','float');
define('bool','boolean');
define('str','string');
define('mix','array');
define('intmix','int_mix');
define('realmix','real_mix');
define('boolmix','bool_mix');
define('strmix','str_mix');
define('obj','object');
define('nil','null');
Из ядра одной русской CMS, писал видимо Pascal'ист
+168
// Saves options to localStorage.
function save_options() {
if(document.getElementById("rate").checked == true) {localStorage["rate"] = 1;}
else{localStorage["rate"] = 0;}
if(document.getElementById("transparentmenu").checked == true) {localStorage["transparentmenu"] = 1;}
else{localStorage["transparentmenu"] = 0;}
if(document.getElementById("sidebarfix").checked == true) {localStorage["sidebarfix"] = 1;}
else{localStorage["sidebarfix"] = 0;}
if(document.getElementById("menufix").checked == true) {localStorage["menufix"] = 1;}
else{localStorage["menufix"] = 0;}
if(document.getElementById("away").checked == true) {localStorage["away"] = 1;}
else{localStorage["away"] = 0;}
if(document.getElementById("music").checked == true) {localStorage["music"] = 1;}
else{localStorage["music"] = 0;}
if(document.getElementById("smiles").checked == true) {localStorage["smiles"] = 1;}
else{localStorage["smiles"] = 0;}
if(document.getElementById("chat").checked == true) {localStorage["chat"] = 1;}
else{localStorage["chat"] = 0;}
if(document.getElementById("wide").checked == true) {localStorage["wide"] = 1;}
else{localStorage["wide"] = 0;}
if(document.getElementById("oblivionbook").checked == true) {localStorage["oblivionbook"] = 1;}
else{localStorage["oblivionbook"] = 0;}
if(document.getElementById("darkblue").checked == true) {localStorage["darkblue"] = 1;}
else{localStorage["darkblue"] = 0;}
if(document.getElementById("mailcollor").checked == true) {localStorage["mailcollor"] = 1;}
else{localStorage["mailcollor"] = 0;}
if(document.getElementById("savetext").checked == true) {localStorage["savetext"] = 1;}
else{localStorage["savetext"] = 0;}
if(document.getElementById("groupsalign").checked == true) {localStorage["groupsalign"] = 1;}
else{localStorage["groupsalign"] = 0;}
if(document.getElementById("vkcom").checked == true) {localStorage["vkcom"] = 1;}
else{localStorage["vkcom"] = 0;}
if(document.getElementById("messege").checked == true) {localStorage["messege"] = 1;}
else{localStorage["messege"] = 0;}
if(document.getElementById("ads").checked == true) {localStorage["ads"] = 1;}
else{localStorage["ads"] = 0;}
if(document.getElementById("lmessege").checked == true) {localStorage["lmessege"] = 1;}
else{localStorage["lmessege"] = 0;}
if(document.getElementById("video").checked == true) {localStorage["video"] = 1;}
else{localStorage["video"] = 0;}
if(document.getElementById("stylewow").checked == true) {localStorage["stylewow"] = 1;}
else{localStorage["stylewow"] = 0;}
if(document.getElementById("rayman").checked == true) {localStorage["rayman"] = 1;}
else{localStorage["rayman"] = 0;}
if(document.getElementById("styletf2").checked == true) {localStorage["styletf2"] = 1;}
else{localStorage["styletf2"] = 0;}
if(document.getElementById("stylestandard").checked == true) {localStorage["stylestandard"] = 1;}
else{localStorage["stylestandard"] = 0;}
if(document.getElementById("stylewinter").checked == true) {localStorage["stylewinter"] = 1;}
else{localStorage["stylewinter"] = 0;}
if(document.getElementById("stylewide").checked == true) {localStorage["stylewide"] = 1;}
else{localStorage["stylewide"] = 0;}
if(document.getElementById("styledarkforest").checked == true) {localStorage["styledarkforest"] = 1;}
else{localStorage["styledarkforest"] = 0;}
if(document.getElementById("stylegray").checked == true) {localStorage["stylegray"] = 1;}
else{localStorage["stylegray"] = 0;}
if(document.getElementById("styledarkkde").checked == true) {localStorage["styledarkkde"] = 1;}
else{localStorage["styledarkkde"] = 0;}
if(document.getElementById("friendsonline").checked == true) {localStorage["friendsonline"] = 1;}
else {localStorage["friendsonline"] = 0;}
if(document.getElementById("removeheader").checked == true) {localStorage["removeheader"] = 1;}
else {localStorage["removeheader"] = 0;}
}
Сохранение настроек в одном расширении для Google Chrome. Восстановление такого же плана...
+168
###########################################################################################################
# Проверка переменных
###########################################################################################################
function check($str) {
$str = htmlentities(trim($str), ENT_QUOTES, 'UTF-8');
$str = nl2br($str);
$str = strtr($str, array (
chr(0)=> '',
chr(1)=> '',
chr(2)=> '',
chr(3)=> '',
chr(4)=> '',
chr(5)=> '',
chr(6)=> '',
chr(7)=> '',
chr(8)=> '',
chr(9)=> '',
chr(10)=> '',
chr(11)=> '',
chr(12)=> '',
chr(13)=> '',
chr(14)=> '',
chr(15)=> '',
chr(16)=> '',
chr(17)=> '',
chr(18)=> '',
chr(19)=> '',
chr(20)=> '',
chr(21)=> '',
chr(22)=> '',
chr(23)=> '',
chr(24)=> '',
chr(25)=> '',
chr(26)=> '',
chr(27)=> '',
chr(28)=> '',
chr(29)=> '',
chr(30)=> '',
chr(31)=> ''
));
$str = str_replace("\'", "'", $str);
$str = str_replace('\\', "\", $str);
$str = str_replace("|", "I", $str);
$str = str_replace("||", "I", $str);
$str = str_replace("/\\\$/", "$", $str);
$str = mysql_real_escape_string($str);
return $str;
}
Лепота)
+168
if (isAdmin($user)) {echo "<a href=/admin.php>Администрирование</a>";}
else echo "хуй! ";
логинизация на сайте продакшн:)
+168
CMakeString& operator<<(DWORD dwNum)
{
DWORD dwTemp = dwNum;
int iCnt=1; // name lookup of 'iCnt' changed for new ISO 'for' scoping
for( ; (dwTemp/=10) != 0; iCnt++ )
;
m_str.resize(m_str.size() + iCnt);
tsprintf(&(*m_str.begin()), _T("%s%u"), m_str.c_str(), dwNum);
return *this;
}
Взято из http://www.codeproject.com/KB/IP/ftpclientclass.aspx