- 1
Пиздец-оффтоп #17
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
Пиздец-оффтоп #17
#1: https://govnokod.ru/26503 https://govnokod.xyz/_26503
#2: https://govnokod.ru/26541 https://govnokod.xyz/_26541
#3: https://govnokod.ru/26583 https://govnokod.xyz/_26583
#4: https://govnokod.ru/26689 https://govnokod.xyz/_26689
#5: https://govnokod.ru/26784 https://govnokod.xyz/_26784
#5: https://govnokod.ru/26839 https://govnokod.xyz/_26839
#6: https://govnokod.ru/26986 https://govnokod.xyz/_26986
#7: https://govnokod.ru/27007 https://govnokod.xyz/_27007
#8: https://govnokod.ru/27023 https://govnokod.xyz/_27023
#9: https://govnokod.ru/27098 https://govnokod.xyz/_27098
#10: https://govnokod.ru/27125 https://govnokod.xyz/_27125
#11: https://govnokod.ru/27129 https://govnokod.xyz/_27129
#12: https://govnokod.ru/27184 https://govnokod.xyz/_27184
#13: https://govnokod.ru/27286 https://govnokod.xyz/_27286
#14: https://govnokod.ru/27298 https://govnokod.xyz/_27298
#15: https://govnokod.ru/27322 https://govnokod.xyz/_27322
#16: https://govnokod.ru/27328 https://govnokod.xyz/_27328
+1
#include <stdio.h>
#include <stdlib.h>
#define SPLICE(a,b) SPLICE_1(a,b)
#define SPLICE_1(a,b) SPLICE_2(a,b)
#define SPLICE_2(a,b) a##b
#define PP_ARG_N( \
_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, \
_11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \
_21, _22, _23, _24, _25, _26, _27, _28, _29, _30, \
_31, _32, _33, _34, _35, _36, _37, _38, _39, _40, \
_41, _42, _43, _44, _45, _46, _47, _48, _49, _50, \
_51, _52, _53, _54, _55, _56, _57, _58, _59, _60, \
_61, _62, _63, N, ...) N
/* Note 63 is removed */
#define PP_RSEQ_N() \
62, 61, 60, \
59, 58, 57, 56, 55, 54, 53, 52, 51, 50, \
49, 48, 47, 46, 45, 44, 43, 42, 41, 40, \
39, 38, 37, 36, 35, 34, 33, 32, 31, 30, \
29, 28, 27, 26, 25, 24, 23, 22, 21, 20, \
19, 18, 17, 16, 15, 14, 13, 12, 11, 10, \
9, 8, 7, 6, 5, 4, 3, 2, 1, 0
#define PP_NARG_(...) PP_ARG_N(__VA_ARGS__)
/* Note dummy first argument _ and ##__VA_ARGS__ instead of __VA_ARGS__ */
#define PP_NARG(...) PP_NARG_(_, ##__VA_ARGS__, PP_RSEQ_N())
#define FIND_NONNULL_1(RES) \
((RES = (char *)(NULL)))
#define FIND_NONNULL_2(RES, VAR) \
((RES = (char *)(VAR)))
#define FIND_NONNULL_3(RES, VAR, ...) \
(((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_2(RES,__VA_ARGS__))
#define FIND_NONNULL_4(RES, VAR, ...) \
(((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_3(RES,__VA_ARGS__))
#define FIND_NONNULL_5(RES, VAR, ...) \
(((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_4(RES,__VA_ARGS__))
#define FIND_NONNULL_6(RES, VAR, ...) \
(((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_5(RES,__VA_ARGS__))
#define FIND_NONNULL_7(RES, VAR, ...) \
(((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_6(RES,__VA_ARGS__))
#define FIND_NONNULL_8(RES, VAR, ...) \
(((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_7(RES,__VA_ARGS__))
#define FIND_NONNULL_9(RES, VAR, ...) \
(((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_8(RES,__VA_ARGS__))
#define FIND_NONNULL_10(RES, VAR, ...) \
(((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_9(RES,__VA_ARGS__))
#define FIND_NONNULL_11(RES, VAR, ...) \
(((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_10(RES,__VA_ARGS__))
#define FIND_NONNULL_12(RES, VAR, ...) \
(((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_11(RES,__VA_ARGS__))
// etc ...
#define FIND_NONNULLS_(N, ...) \
SPLICE(FIND_NONNULL_, N)(__VA_ARGS__)
#define FIND_NONNULLS(...) \
({ \
char *FIND_NONNULLS; \
FIND_NONNULLS_(PP_NARG(FIND_NONNULLS, __VA_ARGS__), FIND_NONNULLS, __VA_ARGS__); \
FIND_NONNULLS; \
})
char *side_effect_null(void)
{
printf("!!null!!\n");
return NULL;
}
char *side_effect_test(void)
{
printf("!!test!!\n");
return "test";
}
int main(void)
{
printf( "result:%s\n", FIND_NONNULLS(0,side_effect_null(),0,side_effect_test(),0,0,side_effect_test(),"govno", side_effect_test()) );
return EXIT_SUCCESS;
}
Это типа как short-circuit evaluation чтоб по цепочке хрень возвращающую строку вызывать, и там те функции хуйпойми сколько аргументов могут принимать (но там может быть константа, тогда естественно нихрена не надо вызывать) пока оно не вернет не-NULL. Как только вернуло не-NULL то вернуть это и дальше ничего не вызывать, а то там сайд эффекты всякие ненужные будут. А если не-NULL так и не нашло, вернуть NULL
+3
// https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
int main(void)
{
char *a = "petuh";
if(({bool ret = 0;if(a[0]=='p')if(a[1]=='e')if(a[2]=='t')if(a[3]=='u')if(a[4]=='h')ret=1;ret;}))
{
puts(a);
}
return EXIT_SUCCESS;
}
Интересное расширение.
0
Питушня #14
#1: https://govnokod.ru/26692 https://govnokod.xyz/_26692
#2: https://govnokod.ru/26891 https://govnokod.xyz/_26891
#3: https://govnokod.ru/26893 https://govnokod.xyz/_26893
#4: https://govnokod.ru/26935 https://govnokod.xyz/_26935
#5: (vanished) https://govnokod.xyz/_26954
#6: (vanished) https://govnokod.xyz/_26956
#7: https://govnokod.ru/26964 https://govnokod.xyz/_26964
#8: https://govnokod.ru/26966 https://govnokod.xyz/_26966
#9: https://govnokod.ru/27017 https://govnokod.xyz/_27017
#10: https://govnokod.ru/27045 https://govnokod.xyz/_27045
#11: https://govnokod.ru/27058 https://govnokod.xyz/_27058
#12: https://govnokod.ru/27182 https://govnokod.xyz/_27182
#13: https://govnokod.ru/27260 https://govnokod.xyz/_27260
0
function validateUSDate( strValue )
{
var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
if(!objRegExp.test(strValue))
return false; //doesn't match pattern, bad date
else
{
var strSeparator = strValue.substring(2,3); //find date separator
var arrayDate = strValue.split(strSeparator); //split date into month, day, year
//create a lookup for months not equal to Feb.
var arrayLookup = { '01' : 31,'03' : 31, '04' : 30,'05' : 31,'06' : 30,'07' : 31,
'08' : 31,'09' : 30,'10' : 31,'11' : 30,'12' : 31};
var intDay = (arrayDate[1]);
//check if month value and day value agree
if(arrayLookup[arrayDate[0]] != null)
{
if(intDay <= arrayLookup[arrayDate[0]] && intDay != 0)
return true; //found in lookup table, good date
}
//check for February
var intYear = parseInt(arrayDate[2]);
var intMonth = parseInt(arrayDate[0]);
if( ((intYear % 4 == 0 && intDay <= 29) || (intYear % 4 != 0 && intDay <=28)) && intDay !=0)
return true; //Feb. had valid number of days
}
return false; //any other values, bad date
}
А вот этот шедевр ещё и работает...
0
function isNumeric(str) //for non-numeric fields
{
var FlagS=0, FlagN=0;
var str1=new Array();
for(var i=0;i<str.length;i++) //convert string to a char array
{
str1[i]=str.charAt(i);
}
for(i=0;i<str1.length;i++) //check for digits
{
if(str1[i]>='0'&&str1[i]<='9' )
{
FlagN=1;
}
}
if(FlagS==1||FlagN==1) //give a final decision
{
FlagS=FlagN=0;
return true;
}
}
Красота по-индийски. FlagS не понадобился, ну и хер с ним :)
+1
void printParser(const wchar_t *fileName, const wchar_t *str, boolean showLineCharPos)
{
ts::Parser parser;
auto sourceFile = parser.parseSourceFile(fileName, str, ScriptTarget::Latest);
ts::FuncT<> visitNode;
ts::ArrayFuncT<> visitArray;
auto intent = 0;
visitNode = [&](ts::Node child) -> ts::Node {
for (auto i = 0; i < intent; i++)
{
std::cout << "\t";
}
std::cout << "Node: " << wtoc(parser.syntaxKindString(child).c_str()) << " @ [ " << child->pos << " - " << child->_end << " ]" << std::endl;
intent++;
ts::forEachChild(child, visitNode, visitArray);
intent--;
return undefined;
};
visitArray = [&](ts::NodeArray<ts::Node> array) -> ts::Node {
for (auto node : array)
{
visitNode(node);
}
return undefined;
};
auto result = ts::forEachChild(sourceFile.as<ts::Node>(), visitNode, visitArray);
}
спортировал TypeScript парсер в C++ и ахренел от обьема работы :)
+1
def ForQueryInAddr(query, addr):
global listed, primalsource
print("Searcing in: "+addr)
html = requests.get(addr,proxies=proxies).text
if (query.lower() in html.lower()):
print("==============================================")
print("Query found in: "+addr)
print("==============================================")
if ("<html>" in html or "<head>" in html):
data = PyQuery(html)
links = data('a')
for link in links:
ahref = link.attrib['href']
#print("Found: "+ahref)
if (ahref not in listed):
if (ahref[0].lower() == "h"):
if (primalsource in ahref):
if (ahref[-3:].lower() not in filetypes and ahref[-4:].lower() not in filetypes and ahref[-5:].lower() not in filetypes):
listed.append(ahref)
ForQueryInAddr(query, ahref)
https://github.com/Dev1lroot/OnionSearch/blob/master/main.py
0
А вы знали, что вязанная бабушкина жилетка с оленями даёт +25 к навыку программирования?
0
public function addMoney($name, $amount, $type)
{
$checkExist = $this->checkUserMoney($name);
$checkExist = ($checkExist != '<b>(Ico)</b> <h11 style=\"color: red\">Произошла ошибка!</h11> <br/>') ? true : false;
$name_uuid = $this->genUUID($name);
if ($this->version == '1.12.2' AND $this->plugin != 'iconomy')
{
if ($checkExist)
{
if ($type == 'add')
{
$queryText = ($this->plugin == 'economylite') ? "UPDATE `economyliteplayers` SET `balance` = `balance` + '$amount' WHERE `uuid` = '$name_uuid' AND `currency` = 'economylite:coin'"
: "UPDATE `{$this->table}` SET `money` = `money` + '$amount' WHERE `player_name` = '$name'";
} else
{
$queryText = ($this->plugin == 'economylite') ? "UPDATE `economyliteplayers` SET `balance` = '$amount' WHERE `uuid` = '$name_uuid' AND `currency` = 'economylite:coin'"
: "UPDATE `{$this->table}` SET `money` = '$amount' WHERE `player_name` = '$name'";
}
} else
{
$queryText = ($this->plugin == 'economylite') ? "INSERT INTO `economyliteplayers` (`uuid`, `balance`, `currency`) VALUES ('$name_uuid', '$amount', 'economylite:coin')"
: "INSERT INTO `{$this->table}` (`player_uuid`, `player_name`, `money`, `sync_complete`, `last_seen`) VALUES ('$name_uuid', '$name', '$amount', 'true', '0')";
}
} else
{
if ($checkExist)
{
$queryText = ($type == 'add') ? "UPDATE `{$this->table}` SET `balance` = `balance` + $amount WHERE `username` = '$name'"
: "UPDATE `{$this->table}` SET `balance` = $amount WHERE `username` = '$name'";
} else
{
$queryText = "INSERT INTO `{$this->table}` (`username`, `balance`) VALUES ('$name', $amount)";
}
}
echo $queryText;
$data = siteQuery($queryText, 'query', $this->mysqli);
$text = ($data != NULL) ? "<b>(Ico)</b> <h11 style=\"color: green\">Игроку $name успешно начисленно: $amount эмеральдов!</h11> <br/>"
: '<b>(Ico)</b> <h11 style="color: red">Произошла ошибка!</h11> <br/>';
return $text;
}
public function checkUserMoney($name)
{
$name_uuid = $this->genUUID($name);
if ($this->version == '1.12.2' AND $this->plugin != 'iconomy')
{
$queryText = ($this->plugin == 'economylite') ? "SELECT `balance` FROM `economyliteplayers` WHERE `uuid` = '{$name_uuid}' AND `currency` = 'economylite:coin'"
: "SELECT `money` as 'balance' FROM `{$this->table}` WHERE `player_name` = '{$name}'";
} else
{
$queryText = "SELECT `balance` FROM `{$this->table}` WHERE `username` = '{$name}'";
}
$data = siteQuery($queryText, 'assoc', $this->mysqli);
$text = ($data != NULL) ? "<b>(Ico)</b> <h11 style=\"color: green\">Балланс игрока $name: {$data['balance']} эмеральдов!</h11> <br/>"
: '<b>(Ico)</b> <h11 style=\"color: red\">Произошла ошибка!</h11> <br/>';
return $text;
}
Этот говнокод кодил наш сотрудник https://vk.com/valiev_off, здесь вы можете наблюдать мастерские SQL запросы под тернарным соусом