- 1
- 2
for (j = 0; j < NUM_DMA_BUFFERS; j++)
*(int *)dev->channel[0].virtDma[j] = 0x1235+j;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+136
for (j = 0; j < NUM_DMA_BUFFERS; j++)
*(int *)dev->channel[0].virtDma[j] = 0x1235+j;
ЯННП
+51
template<class T, size_t N>
constexpr size_t sa(T (&)[N])
{
return N;
};
static std::memory_order mmo[] =
{
memory_order_relaxed,
memory_order_consume,
memory_order_acquire,
memory_order_release,
memory_order_acq_rel,
memory_order_seq_cst
};
std::memory_order current_program_memory_order()
{
return mmo[rand()%sa(mmo)];
}
void current_program_memory_barier()
{
std::atomic_thread_fence(current_program_memory_order());
}
+102
public class Permuter {
private static void permute(int n, char[] a) {
if (n == 0) {
System.out.println(String.valueOf(a)) ;}
else {
for (int i = 0; i <= n; i++) {
permute(n-1, a) ;
swap(a, n % 2 == 0 ? i : 0, n) ;}}}
private static void swap(char[] a, int i, int j) {
char saved = a[i] ;
a[i] = a[j] ;
a[j] = saved ;}}
"I finally figured out how to get those pesky semicolons and curly braces out of my Java code"
+161
there is a reason why opencart is the no.1 most used ecommerce solution in places like china and india, its the easiest code base to understand!
--
many apps servers! what does that mean? you mean different applications running from the same framework?
you build each application starting from the index.php file and include what ever library classes you require.
--
"I agree with you that it's harder to write simple code, because REPEATING CODE IS HARD TO DEBUG HARD TO READ AND TO CORRECT. so it makes you waste a lot of time."
this is what search and replace is for!
Создатель опенкарта (Daniel Kerr) исходит на говно, много мякотки
http://www.techchattr.com/never-use-opencart#comment-1151857248
+160
foreach (scandir(DIR.'app'.SLASH.'lib') as $filename) {
$path = DIR.'app'.SLASH.'lib'.SLASH.$filename;
if (is_file($path) && substr($filename,strlen($filename)-4,4)=='.php') {
require_once($path);
}
}
foreach (scandir(DIR.'app'.SLASH.'models') as $filename) {
$path = DIR.'app'.SLASH.'models'.SLASH.$filename;
if (is_file($path) && substr($filename,strlen($filename)-4,4)=='.php') {
require_once($path);
}
}
foreach (scandir(DIR.'app'.SLASH.'ext') as $filename) {
$path = DIR.'app'.SLASH.'ext'.SLASH.$filename;
if (is_file($path) && substr($filename,strlen($filename)-4,4)=='.php') {
require_once($path);
}
}
Начался разбор проблемы со слов заказчика - "сайт долго грузится"
+132
@echo off
setlocal EnableDelayedExpansion
setlocal EnableExtensions
set /a _2=20
set /a _1=600
set /a _0=800
call :mandelbrot _3 0 _0 _1 _2
echo | set /p ^=!_3!
goto :EOF
:mandelbrot
set width_%~2=!%~3!
set height_%~2=!%~4!
set max_%~2=!%~5!
set /a row_%~2=0
:WHILE_6
if !row_%~2! LSS !height_%~2! (
set /a col=0
:WHILE_5
if !col! LSS !width_%~2! (
set /a c_re=^(^(^(!col! - ^(!width_%~2! / 2^)^) * 4^) / !width_%~2!^)
set /a c_im=^(^(^(!row_%~2! - ^(!height_%~2! / 2^)^) * 4^) / !width_%~2!^)
set /a x=0
set /a y=0
set /a iteration=0
set /a _9_%~2=0
if !iteration! LSS !max_%~2! (
set /a _8_%~2=1
) else (
set /a _8_%~2=0
)
set /a _18_%~2=^(1 + %~2^)
call :or _19_%~2 !_18_%~2! _8_%~2 _9_%~2
set _10_%~2=!_19_%~2!
set /a _4_%~2=2
set _3_%~2=!y!
set /a _20_%~2=^(1 + %~2^)
call :pow _21_%~2 !_20_%~2! _3_%~2 _4_%~2
set _5_%~2=!_21_%~2!
set /a _1_%~2=2
set _0_%~2=!x!
set /a _22_%~2=^(1 + %~2^)
call :pow _23_%~2 !_22_%~2! _0_%~2 _1_%~2
set _2_%~2=!_23_%~2!
set /a _24_%~2=^(1 + %~2^)
call :plus _25_%~2 !_24_%~2! _2_%~2 _5_%~2
set _6_%~2=!_25_%~2!
if !_6_%~2! LEQ 4 (
set /a _7_%~2=1
) else (
set /a _7_%~2=0
)
set /a _26_%~2=^(1 + %~2^)
call :and _27_%~2 !_26_%~2! _7_%~2 _10_%~2
set _11_%~2=!_27_%~2!
:WHILE_4
if !_11_%~2! EQU 1 (
set /a x_new=^(^(^(!x! * !x!^) - ^(!y! * !y!^)^) + !c_re!^)
set /a y=^(^(^(2 * !x!^) * !y!^) + !c_im!^)
set x=!x_new!
set /a iteration=^(!iteration! + 1^)
goto WHILE_4
)
if !iteration! LSS !max_%~2! (
set _14_%~2=!white!
set _13_%~2=!row_%~2!
set _12_%~2=!col!
set /a _30_%~2=^(1 + %~2^)
call :putpixel _31_%~2 !_30_%~2! _12_%~2 _13_%~2 _14_%~2
echo | set /p ^=!_31_%~2!
) else (
set _17_%~2=!black!
set _16_%~2=!row_%~2!
set _15_%~2=!col!
set /a _28_%~2=^(1 + %~2^)
call :putpixel _29_%~2 !_28_%~2! _15_%~2 _16_%~2 _17_%~2
echo | set /p ^=!_29_%~2!
)
set /a col=^(!col! + 1^)
goto WHILE_5
)
set /a row_%~2=^(!row_%~2! + 1^)
goto WHILE_6
)
goto :EOF
:and
set a_%~2=!%~3!
set b_%~2=!%~4!
rem emulation of &&
if !a_%~2! EQU 1 (
if !b_%~2! EQU 1 (
set %~1=1
goto :EOF
)
)
set %~1=0
goto :EOF
Мандельброт (без записи в картинку) на Batch
+54
class SpinLock
{
std::atomic_flag lck;
public:
SpinLock(){
unlock();
}
__forceinline void lock(){
while (lck.test_and_set(std::memory_order_acquire)){
}
}
__forceinline void unlock(){
lck.clear(std::memory_order_release);
}
};
−115
def checkio(res):
#bruteforce LOL
if res[0][0] == res[1][0] == res[2][0] == "X":
return "X"
if res[0][1] == res[1][1] == res[2][1] == "X":
return "X"
if res[0][2] == res[1][2] == res[2][2] == "X":
return "X"
if res[0][0] == res[0][1] == res[0][2] == "X":
return "X"
if res[1][0] == res[1][1] == res[1][2] == "X":
return "X"
if res[2][0] == res[2][1] == res[2][2] == "X":
return "X"
if res[0][0] == res[1][1] == res[2][2] == "X":
return "X"
if res[0][2] == res[1][1] == res[2][0] == "X":
return "X"
if res[0][0] == res[1][0] == res[2][0] == "O":
return "O"
if res[0][1] == res[1][1] == res[2][1] == "O":
return "O"
if res[0][2] == res[1][2] == res[2][2] == "O":
return "O"
if res[0][0] == res[0][1] == res[0][2] == "O":
return "O"
if res[1][0] == res[1][1] == res[1][2] == "O":
return "O"
if res[2][0] == res[2][1] == res[2][2] == "O":
return "O"
if res[0][0] == res[1][1] == res[2][2] == "O":
return "O"
if res[0][2] == res[1][1] == res[2][0] == "O":
return "O"
return "D"
Определить результат игры в крестики нолики.
+101
char buf[4096];
*((char*)&buf[14]) = 0x30;
Запись значения в массив (такой способ обращения к элементу массива тщательно соблюдается на протяжении всех 25000 строк кода проекта)
+158
this.addItem = function(item) {
if (item.id == null & item.Name != null & item.Name != '') {
item.id = uid++;
items.push(item);
$window.sessionStorage.setItem('items', JSON.stringify(items));
} else {
for (i in items) {
if (items[i].id == item.id) {
items[i] = item;
}
}
}
}