- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
bool retval = true;
while (someting) {
...
if (retval) retval = sendDataInternal(data);
else sendDataInternal(data);
}
return retval;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
bool retval = true;
while (someting) {
...
if (retval) retval = sendDataInternal(data);
else sendDataInternal(data);
}
return retval;
Ничто не остановит бульдозер.
+1
#define SPLICE(a,b) a##b
#define LL(a,b) SPLICE(a,b)
#define M(name) LL(NS,name)
#define NS ns1_
void M(somefunction)(){
}
#undef NS
#define NS ns2_
void M(somefunction)(){
}
#undef NS
#define NS ns3_
void M(somefunction)(){
}
#undef NS
неймспейсы в Си на препроцессоре
0
#include <stdio.h>
typedef int (*FUNC)();
FUNC test (int a, int b){
int ret(){
return a + b;
}
return ret;
}
int main(){
printf("%i\n", test(40, 2)());
return 0;
}
/* Тоже самое на JS */
function test(a, b){
function ret(){
return a + b;
}
return ret;
}
alert(test(40, 2)());
# Тоже самое на Python
def test(a, b):
def ret():
return a + b
return ret
print test(40, 2)()
Странно работает компилятор, версия: gcc version 4.7.2
$ gcc 1.c && ./a.out
42
$ gcc -O3 1.c && ./a.out
Segmentation fault
0
#include <iostream>
#include <type_traits>
#include <functional>
template <typename Function, typename... Args>
auto call(Function function, Args&&... args) {
return std::move(function)(std::forward<Args>(args)...);
}
class Foo {
public:
void say(int a) const { std::cout << "Foo::say(int a = " << a << ")\n"; }
};
int main() {
call(std::mem_fn(&Foo::say), Foo(), 42);
}
Ничего особенного. Просто ЙЦУКЕН!!!!111, как оно вообще работает?
0
<a title="<?php echo trans('Download')?>" class="tip-right" href="javascript:void('')" onclick="$('#form<?php echo $nu;?>').submit();"><i class="icon-download"></i></a>
<?php if($is_img && $src_thumb!="" && $file_array['extension']!="tiff" && $file_array['extension']!="tif"){ ?>
<a class="tip-right preview" title="<?php echo trans('Preview')?>" data-url="<?php echo $src;?>" data-toggle="lightbox" href="#previewLightbox">
<i class=" icon-eye-open"></i></a><?php }elseif(($is_video || $is_audio) && in_array($file_array['extension'],$jplayer_ext)){ ?>
Немножечко говнокода из глубин французского файлового менеджера.
И такого там...
−2
#include <iostream>
#include <typeinfo>
class S
{
public:
S* _next;
};
int main (int argc, char **argv)
{
for (S* sw1 = new S(), sw2 = sw1->_next;;)
{
std::cout << typeid(sw1).name() << std::endl;
std::cout << typeid(sw2).name() << std::endl;
break;
}
return 0;
}
какого хрена этот говнокод не хочет скомпилиться :)
0
#include <iostream>
template < typename T >
struct Static
{
T t;
};
template < typename T >
struct Test
{
static Static<Test<T>> t;
};
template < typename T >
Static< Test<T> > Test<T>::t;
int main (int argc, char **argv)
{
Test<int> t;
return 0;
}
Попробуйте скопилять этот код на G++ (даю подсказку - Test is fully defined type - потому что static не в ходит в размер структуры)
+1
var effects = {
linear: function(t) {
return t;
},
easeInQuad: function(t) {
return t * t;
},
easeOutQuad: function(t) {
return -t * (t - 2);
},
easeInOutQuad: function(t) {
if ((t /= 0.5) < 1) {
return 0.5 * t * t;
}
return -0.5 * ((--t) * (t - 2) - 1);
},
easeInCubic: function(t) {
return t * t * t;
},
easeOutCubic: function(t) {
return (t = t - 1) * t * t + 1;
},
easeInOutCubic: function(t) {
if ((t /= 0.5) < 1) {
return 0.5 * t * t * t;
}
return 0.5 * ((t -= 2) * t * t + 2);
},
easeInQuart: function(t) {
return t * t * t * t;
},
easeOutQuart: function(t) {
return -((t = t - 1) * t * t * t - 1);
},
easeInOutQuart: function(t) {
if ((t /= 0.5) < 1) {
return 0.5 * t * t * t * t;
}
return -0.5 * ((t -= 2) * t * t * t - 2);
},
easeInQuint: function(t) {
return t * t * t * t * t;
},
easeOutQuint: function(t) {
return (t = t - 1) * t * t * t * t + 1;
},
easeInOutQuint: function(t) {
if ((t /= 0.5) < 1) {
return 0.5 * t * t * t * t * t;
}
return 0.5 * ((t -= 2) * t * t * t * t + 2);
},
easeInSine: function(t) {
return -Math.cos(t * (Math.PI / 2)) + 1;
},
easeOutSine: function(t) {
return Math.sin(t * (Math.PI / 2));
},
easeInOutSine: function(t) {
return -0.5 * (Math.cos(Math.PI * t) - 1);
},
easeInExpo: function(t) {
return (t === 0) ? 0 : Math.pow(2, 10 * (t - 1));
},
easeOutExpo: function(t) {
return (t === 1) ? 1 : -Math.pow(2, -10 * t) + 1;
},
easeInOutExpo: function(t) {
if (t === 0) {
return 0;
}
if (t === 1) {
return 1;
}
if ((t /= 0.5) < 1) {
return 0.5 * Math.pow(2, 10 * (t - 1));
}
return 0.5 * (-Math.pow(2, -10 * --t) + 2);
},
...
/**
* Easing functions adapted from Robert Penner's easing equations.
* @namespace Chart.helpers.easingEffects
* @see http://www.robertpenner.com/easing/
*/
В общем это такая специальная параша, чтобы делать гладкую анимацию какой-то х****. Вопрос - на***а вообще нужна эта гладкая анимация, и почему эту х***ю не реализуют как набор неких встроенных в браузер функций чтобы их из этого жабаскрипта вызывать, чтобы эта хрень не тормозила? Меня б**** з****** эти ё***** сайты, обвешанные какой-то б******* х***** на жабаскрипте которая прыгает по всему экрану, кому вообще пришла в голову идея сделать подобную хрень? Поубивал бы этих е***** фронтендщиков с их х****й
http://easings.net/ru вот еще про эту хуиту.
+2
+ switch (fov) {
+ case 15: return size * 7.595754112725151;
+ case 30: return size * 3.732050807568878;
+ case 45: return size * 2.414213562373095;
+ case 60: return size * 1.732050807568877;
+ default: return size / Math.tan(fov / 2 * Math.PI / 180);
+ }
оптимизация!
0
bool NextLBYUpdate()
{
int tick = *(int*)((DWORD)G::LocalPlayer + Offsets.m_nTickBase);
float flServerTime = (float)(tick * I::Globals->interval_per_tick);
if (_DEBUGMODE_)
{
printf("%f\n", G::LocalPlayer->GetLowerBodyYaw());
}
if (OldLBY != G::LocalPlayer->GetLowerBodyYaw())
{
LBYBreakerTimer++;
OldLBY = G::LocalPlayer->GetLowerBodyYaw();
bSwitch = !bSwitch;
LastLBYUpdateTime = flServerTime;
}
if (CurrentVelocity(G::LocalPlayer) > 0.5)
{
LastLBYUpdateTime = flServerTime;
return false;
}
if ((LastLBYUpdateTime + 1 - (GetLatency() * 2) < flServerTime) && (G::LocalPlayer->GetFlags() & FL_ONGROUND))
{
if (LastLBYUpdateTime + 1.1 - (GetLatency() * 2) < flServerTime)
{
LastLBYUpdateTime += 1.1;
}
return true;
}
return false;
}
float GetLatency()
{
INetChannelInfo *nci = I::Engine->GetNetChannelInfo();
if (nci)
{
float Latency = nci->GetAvgLatency(FLOW_OUTGOING) + nci->GetAvgLatency(FLOW_INCOMING);
return Latency;
}
else
{
return 0.0f;
}
}
float GetOutgoingLatency()
{
INetChannelInfo *nci = I::Engine->GetNetChannelInfo();
if (nci)
{
float OutgoingLatency = nci->GetAvgLatency(FLOW_OUTGOING);
return OutgoingLatency;
}
else
{
return 0.0f;
}
}
float GetIncomingLatency()
{
INetChannelInfo *nci = I::Engine->GetNetChannelInfo();
if (nci)
{
float IncomingLatency = nci->GetAvgLatency(FLOW_INCOMING);
return IncomingLatency;
}
else
{
return 0.0f;
}
}
https://yougame.biz/threads/19903/