- 1
Пиздец-оффтоп #23
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
Пиздец-оффтоп #23
#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
#17: https://govnokod.ru/27346 https://govnokod.xyz/_27346
#18: https://govnokod.ru/27374 https://govnokod.xyz/_27374
#19: https://govnokod.ru/27468 https://govnokod.xyz/_27468
#20: https://govnokod.ru/27469 https://govnokod.xyz/_27469
#21: https://govnokod.ru/27479 https://govnokod.xyz/_27479
#22: https://govnokod.ru/27485 https://govnokod.xyz/_27485
+1
<?php
// bitrix/modules/main/classes/mysql/database.php:: 176
if(!$result)
{
.......
if(!$bIgnoreErrors)
{
.......
if(file_exists($_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/php_interface/dbquery_error.php"))
include($_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/php_interface/dbquery_error.php");
elseif(file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/dbquery_error.php"))
include($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/dbquery_error.php");
else
die("MySQL Query Error!");
die();
}
return false;
}
// bitrix/modules/main/include/dbquery_error.php
<br>
<table>
//верстка html страницы со вставками переменных через <?= ?>
</table>
Исключения? Не, не слышали. Пусть конечный разработчик голову ломает, почему он не может отловить MySQL Query Error [1062] Duplicate entry ......
+1
s=79; cur=[s//2,s//2]; prio=[[0,1],[1,0],[0,-1],[-1,0]]
spiral = [[0 for i in range(0,s)] for l in range(0,s)]
for cor in enumerate([[0,0]]+[prio[c] for c in [int(c) for c in ''.join([str(p%4)*((p+2)//2) for p in range(0,s**2//2)])]][:s**2-1],start=1):
n=cor[0];cur=[cur[0]+cor[1][0],cur[1]+cor[1][1]];spiral[cur[0]][cur[1]]=n
for c in spiral: print(str(('{:>'+str(len(str(s**2))+1)+'}')*len(c)).format(*c))
А теперь попробуй повтори этот шедевр своими трясущимися ручками-веточками на своём С++
+2
namespace fooX.bar.baz {
export class A {
foo() {
glb1++
}
}
export function b() {
glb1++
glb1++
}
}
import bz = fooX.bar.baz
import AA = fooX.bar.baz.A
function testImports() {
glb1 = 0
bz.b()
let x = new AA()
x.foo()
assert(glb1 == 3, "imports")
}
function main()
{
testImports()
}
Даже и не знаю, что вам тут еще наговнокодить... вот работаю над неймспейсами ..
−1
const gearIcon = new Vivus(
'gears',
{
type: 'delayed',
duration: 200
}
);
+2
public static int booleanToInt(Boolean value) {
int res;
if (value == null) {
res = 0;
} else {
if (value) {
res = 1;
} else {
res = 0;
}
}
return res;
}
Добро пожаловать к нам в индийскую школу программирования!
+1
// https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/global/qglobal.h?h=v5.13.1#n1017
#if __cplusplus >= 201703L
// Use C++17 if statement with initializer. User's code ends up in a else so
// scoping of different ifs is not broken
#define Q_FOREACH(variable, container) \
for (auto _container_ = QtPrivate::qMakeForeachContainer(container); \
_container_.i != _container_.e; ++_container_.i) \
if (variable = *_container_.i; false) {} else
#else
// Explanation of the control word:
// - it's initialized to 1
// - that means both the inner and outer loops start
// - if there were no breaks, at the end of the inner loop, it's set to 0, which
// causes it to exit (the inner loop is run exactly once)
// - at the end of the outer loop, it's inverted, so it becomes 1 again, allowing
// the outer loop to continue executing
// - if there was a break inside the inner loop, it will exit with control still
// set to 1; in that case, the outer loop will invert it to 0 and will exit too
#define Q_FOREACH(variable, container) \
for (auto _container_ = QtPrivate::qMakeForeachContainer(container); \
_container_.control && _container_.i != _container_.e; \
++_container_.i, _container_.control ^= 1) \
for (variable = *_container_.i; _container_.control; _container_.control = 0)
#endif
А можно ли свой foreach сделать через какую-нибудь шаблонопарашу? Или тут, как обычно, нужна гомоиконность?
0
Пиздец-оффтоп #22
#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
#17: https://govnokod.ru/27346 https://govnokod.xyz/_27346
#18: https://govnokod.ru/27374 https://govnokod.xyz/_27374
#19: https://govnokod.ru/27468 https://govnokod.xyz/_27468
#20: https://govnokod.ru/27469 https://govnokod.xyz/_27469
#21: https://govnokod.ru/27479 https://govnokod.xyz/_27479
+1
IT Оффтоп #97
#67: https://govnokod.ru/27049 https://govnokod.xyz/_27049
#68: https://govnokod.ru/27061 https://govnokod.xyz/_27061
#69: https://govnokod.ru/27071 https://govnokod.xyz/_27071
#70: https://govnokod.ru/27097 https://govnokod.xyz/_27097
#71: https://govnokod.ru/27115 https://govnokod.xyz/_27115
#72: https://govnokod.ru/27120 https://govnokod.xyz/_27120
#73: https://govnokod.ru/27136 https://govnokod.xyz/_27136
#74: https://govnokod.ru/27160 https://govnokod.xyz/_27160
#75: https://govnokod.ru/27166 https://govnokod.xyz/_27166
#76: https://govnokod.ru/27168 https://govnokod.xyz/_27168
#77: https://govnokod.ru/27186 https://govnokod.xyz/_27186
#78: https://govnokod.ru/27219 https://govnokod.xyz/_27219
#79: https://govnokod.ru/27254 https://govnokod.xyz/_27254
#80: https://govnokod.ru/27270 https://govnokod.xyz/_27270
#81: https://govnokod.ru/27280 https://govnokod.xyz/_27280
#82: https://govnokod.ru/27284 https://govnokod.xyz/_27284
#83: https://govnokod.ru/27296 https://govnokod.xyz/_27296
#84: https://govnokod.ru/27336 https://govnokod.xyz/_27336
#85: https://govnokod.ru/27381 https://govnokod.xyz/_27381
#86: https://govnokod.ru/27405 https://govnokod.xyz/_27405
#87: https://govnokod.ru/27429 https://govnokod.xyz/_27429
#88: https://govnokod.ru/27432 https://govnokod.xyz/_27432
#89: https://govnokod.ru/27435 https://govnokod.xyz/_27435
#90: https://govnokod.ru/27439 https://govnokod.xyz/_27439
#91: https://govnokod.ru/27449 https://govnokod.xyz/_27449
#92: https://govnokod.ru/27460 https://govnokod.xyz/_27460
#93: https://govnokod.ru/27463 https://govnokod.xyz/_27463
#94: https://govnokod.ru/27466 https://govnokod.xyz/_27466
#95: https://govnokod.ru/27473 https://govnokod.xyz/_27473
#96: https://govnokod.ru/27478 https://govnokod.xyz/_27478
+5
#include <unistd.h>
#include <stdio.h>
#include <limits.h>
template<size_t Size> struct static_string {char data[Size];};
template<size_t ... Indexes>struct index_sequence {};
template<size_t Size, size_t ... Indexes>
constexpr static_string<sizeof ... (Indexes) + 1> make_static_string(const static_string<Size>& str,index_sequence<Indexes ...>) {return {str.data[Indexes] ..., '\0'};}
constexpr static_string<1> make_static_string() {return {'\0'};}
template<size_t Size, size_t ... Indexes>
struct make_index_sequence : make_index_sequence<Size - 1, Size - 1, Indexes ...> {};
template<size_t Size>
constexpr static_string<Size> make_static_string(const char (& str)[Size]) {return make_static_string(str, make_index_sequence<Size - 1>{});}
template<size_t ... Indexes>
struct make_index_sequence<0, Indexes ...> : index_sequence<Indexes ...> {};
template<size_t Size, size_t ... Indexes>
constexpr static_string<sizeof ... (Indexes) + 1> make_static_string(const char (& str)[Size],index_sequence<Indexes ...>) {return {str[Indexes] ..., '\0'};}
template<size_t Size>
constexpr size_t static_string_find(const static_string<Size>& str, char ch, size_t from, size_t nth) {return Size < 2 || from >= Size - 1 ? UINT_MAX :str.data[from] != ch ? static_string_find(str, ch, from + 1, nth) :nth > 0 ? static_string_find(str, ch, from + 1, nth - 1) : from;}
template<size_t Size>
constexpr size_t static_string_find_0(const static_string<Size>& str, char ch, size_t from, size_t nth) {return Size < 2 || from >= Size - 1 ? 0 : str.data[from] != ch ? static_string_find_0(str, ch, from + 1, nth) :nth > 0 ? static_string_find(str, ch, from + 1, nth - 1) : from;}
template<size_t Size1, size_t ... Indexes1, size_t Size2, size_t ... Indexes2>
constexpr static_string<Size1 + Size2 - 1> static_string_concat_2(const static_string<Size1>& str1, index_sequence<Indexes1 ...>,const static_string<Size2>& str2, index_sequence<Indexes2 ...>) {return {str1.data[Indexes1] ..., str2.data[Indexes2] ..., '\0'};}
template<size_t Size1, size_t Size2>
constexpr static_string<Size1 + Size2 - 1> static_string_concat_2(const static_string<Size1>& str1, const static_string<Size2>& str2) {return static_string_concat_2(str1, make_index_sequence<Size1 - 1>{},str2, make_index_sequence<Size2 - 1>{});}
template<size_t Begin, size_t End, size_t ... Indexes>
struct make_index_subsequence : make_index_subsequence<Begin, End - 1, End - 1, Indexes ...> {};
template<size_t Pos, size_t ... Indexes>
struct make_index_subsequence<Pos, Pos, Indexes ...> : index_sequence<Indexes ...> {};
template<size_t Begin, size_t End, size_t Size>
constexpr static_string<End - Begin + 1> static_string_substring(const static_string<Size>& str) {return make_static_string(str, make_index_subsequence<Begin, End>{});}
template<size_t Begin, size_t Size>
constexpr static_string<Size - Begin> static_string_suffix(const static_string<Size>& str) {return static_string_substring<Begin, Size - 1>(str);}
#define remove_underscore(arg) ([] () __attribute__((always_inline)) {constexpr auto a = static_string_find(make_static_string(arg),'_',0,0) == UINT_MAX? make_static_string(arg):static_string_concat_2(static_string_concat_2(static_string_substring<0,static_string_find_0(make_static_string(arg),'_',0,0)>(make_static_string(arg)),static_string_suffix<static_string_find_0(make_static_string(arg),'_',0,0)+1>(make_static_string(arg))),make_static_string("\0"));return a;}().data)
int main()
{
puts(remove_underscore("_testtest"));
puts(remove_underscore("test_test"));
puts(remove_underscore("testtest_"));
}
Убогий constexpr в c++11