- 1
- 2
HTTP referer (originally a misspelling of referrer) is an HTTP header field that identifies the address of the webpage
(i.e. the URI or IRI) that linked to the resource being requested.
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+133
HTTP referer (originally a misspelling of referrer) is an HTTP header field that identifies the address of the webpage
(i.e. the URI or IRI) that linked to the resource being requested.
Originally a misspelling of referrer...
+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
+126
// На самом деле это пока только псевдокод. Real code will be on C/C++
//Lock-free non blocking and anatomic operation only if IP was changed
// IN SHARED MEMORY
non_atomic_in_shmem bad_IP_flag_non_atomic_in_shmem[64][16]; // in real code it will be uint64_t array[16] and bits operations with it
some_ip_class IPs_non_atomic_in_shmem[64][16] //
std::atomic<uint64_t> version_holder_atomic_in_shmem[64][16]; // it is debatable "whether to do it the Atomic" but for reinsurance
// IN WRITER PROCESS
void worker_reassign_IP_by_num(new_IP, back_end_server_ID, num)
if bad_IP_flag_non_atomic_in_shmem[back_end_server_ID][num] // in real code this check will be not here but will have same sense
version_holder_atomic_in_shmem[back_end_server_ID][num] ++ //it is increment of atomic var version and version become NOT even
__sync_synchronize(); //TODO may be we can use something better here ?
IPs_non_atomic_in_shmem[back_end_server_ID][num] = new_IP //it copy assignment
__sync_synchronize(); //TODO may be we can use something better here ?
version_holder_atomic_in_shmem[back_end_server_ID][num] ++ //it is increment of atomic var version and version become even
__sync_synchronize(); //TODO may be we can use something better here ?
bad_IP_flag_non_atomic_in_shmem[back_end_server_ID][num] = 0
// IN READER PROCESS
some_ip_class get_valid_ip_by_num(back_end_server_ID,num){
//TODO version_holder is atomic for now, may we do it non atomic? I think YES. Are any arguments in opposites?
// Instead of atomic can we possible use volatile?
uint64_t version_before = version_holder_atomic_in_shmem[back_end_server_ID][num] //it is atomic copy assignment
//if (version_befor & 1) // is not even it will work too instead of checking flags
// but checking flags it is less expensive operation than checking version because the version var is atomic
if bad_IP_flag_non_atomic_in_shmem //
return 0;
some_ip_class ip = IPs_non_atomic_in_shmem[back_end_server_ID][num]
uint64_t version_after = version_holder_atomic_in_shmem[back_end_server_ID][num] // it is atomic copy assignment
if version_before != version_after // versions is not sames
// we may add extra check of version evenest but it will cost us 1 slow atomic operation and excessively
//OR (version_after & 1) //or versions is not even ip is not correct
return 0
return ip
}
some_ip_class get_valid_ip(back_end_server_ID)
while(time_not_expaired) {
for (n=0; n<16; n++){
some_ip_class ip = get_valid_ip_by_num(back_end_server_ID, n)
if ip
return ip
}
//"it will never happened" "if it happened and time expired do something but it is problems on the back end servers site"
//”it is similar situation with situation when back end server just down ”
}
return 0 // or some server_down_ip ;)
some_ip_class check_or_get_new_ip( curent_ip, back_end_server_ID, num)
if NOT bad_IP_flag_non_atomic_in_shmem
if current_ip == shmem_array_of_IP_non_atomic[back_end_server_ID][num] // maybe need copy but I think it's not necessary
return current_ip
Задача: есть reader(ы) Это процессы 20 - 30 -64, которые обращаются к web-серверу. У web-сервера может быть несколько ip (не больше 16). Переодически (1 раз в ~30 секунд) пара (1-2) IP может отвалиться и вместо них может появится пара 1-2 новых. reader обнаружив bad IP выставляет флаг bad_IP_flag. Writer (только 1 единственный процесс не reader) Переодически (1 раз в ~1 сек) проверяет флаг, увидев bad_IP_flag запускает DNS-lookup который длиться примерно (30mks - 1s). Обновляет массив ip Readers при попытке соединиться проверяют не стал ли IP плохим если стал пробуют другой из массива Но суть не в этом Суть в том как безопасно работать с shared memory? Где что не так в предложенной задумке?
+130
Subroutine HBomb(x,ia,ib)
Dimension x(*)
c Generate some exeption...
x(ia*ib)=1.0
x(ia*(-ib))=1.0
x(1)=7.0/(ia+ib)
Return
End
Серьёзный квантовохимический пакет, между прочим.
Выше по течению этот кусок кода вызывали через call hbomb(x, 1000, -1000)
+127
wct
http://habrahabr.ru/post/250713/
+127
http://i.gyazo.com/dd1b407b6ea528e59de2966e49d4cb82.png
Юзабилити)))
+129
@servers(['web' => '[email protected]'])
<?php
$repo = '[email protected]:webbox/lb.git';
$release_dir = '/home/admin/web/releases';
$app_dir = '/home/admin/web/likebox-dev/public_html';
$release = 'release_' . date('YmdHis');
?>
@macro('deploy', ['on' => 'web'])
fetch_repo
run_composer
update_permissions
update_symlinks
@endmacro
@task('fetch_repo')
[ -d {{ $release_dir }} ] || mkdir {{ $release_dir }};
cd {{ $release_dir }};
git clone {{ $repo }} {{ $release }};
@endtask
@task('run_composer')
cd {{ $release_dir }}/{{ $release }};
composer install --prefer-dist;
@endtask
@task('update_permissions')
cd {{ $release_dir }};
chgrp -R www-data {{ $release }};
chmod -R ug+rwx {{ $release }};
@endtask
@task('update_symlinks')
ln -nfs {{ $release_dir }}/{{ $release }} {{ $app_dir }};
chgrp -h www-data {{ $app_dir }};
@endtask
Гит не нужен =)
+133
STEAMROOT="$(cd "${0%/*}" && echo $PWD)")
...
rm -rf "$STEAMROOT/"*
http://www.opennet.ru/opennews/art.shtml?num=41469
эпик фейл
#юмор
#идиоты
+137
Чуваки! Ну не надо постить уныние. Да, тупой goto, или куча вложенных ifов, или тупой css - это клёво, но в остроумии поупражняться особо желающих, как правило, не бывает - а ведь комменты ценны более всего.
Я бы тут ещё паучка нарисовал, но я уже в пижаме.
алсо, никто не работал с j2me-polish? (да, я некрофил)
+138
{
"result":
{
"session":"f759ca20-****-****-****-273ffc13a26d",
"version":"1.0"
},
"status":
{
"error":"ok",
"errorMessage":""
}
}
takoy vot error