- 1
- 2
- 3
// Hack - blacklist
if ($msg->abonent == '12345678910')
die("Database error");
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+149
// Hack - blacklist
if ($msg->abonent == '12345678910')
die("Database error");
Найдено в крупном и сложном проекте, посреди часто вызываемого кода - проверка на забаненный номер (номер изменён).
+160
function calculateRow(element) {
var qty = element.val();
var price = element.parent().next().next().children().text();
var total = (qty * price).toFixed(2);
$(element).parent().next().next().next().children().first().text(total);
}
+78
#include <unistd.h>
int main()
{
while(1)
fork();
}
−88
/**
* Indicates whether the animation is playing
*/
public function get isPlaying():Boolean
{
if(_isPlaying)
{
return _loop >= 0 || _currentTime < _totalTime && !_isPlaying;
}
return false;
}
DragonBones, dragonBones.animation.Animations.as : 79-86
+128
Проклятые клоуны локализуют вручную компоненты DevExpress:
фразы типа "No available data"/"No image data" отображается везде в элементах как "Пустая дата".
Шта вы гаварите? Гаварите громчи, я вас ни панимать!
+157
$targetFolder = 'uploads/'; // Relative to the root
// ...
$targetPath = dirname(__FILE__) . '/' . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['file']['name'];
"Непостоянство слеша", Pedro Molina, 2013. Холст, масло
https://github.com/pekebyte/pekeUpload/blob/940cf27e5fef5038e2e414c72be6e34d68f2881d/upload.php
−116
{
NSString *xContent = myTextView.text;
//temp file filename
NSString *tmpFileName = @"test1.html";
//temp dir
NSString *tempDir = NSTemporaryDirectory();
NSLog(@"tempDirectory: %@",tempDir);
//create NSURL
NSString *path4 = [tempDir stringByAppendingPathComponent:tmpFileName];
NSURL* url = [NSURL fileURLWithPath:path4];
//setup HTML file contents
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"MathJax" ofType:@"js" inDirectory:@"mathjax-MathJax-v2.0"];
NSLog(@"filePath = %@",filePath);
//write to temp file "tempDir/tmpFileName", set MathJax JavaScript to use "filePath" as directory, add "xContent" as content of HTML file
[self writeStringToFile:tempDir fileName:tmpFileName pathName:filePath content:xContent];
NSURLRequest* req = [[NSURLRequest alloc] initWithURL:url];
//original request to show MathJax stuffs
[myWebView loadRequest:req];
}
-(void)writeStringToFile:(NSString *)dir fileName:(NSString *)strFileName pathName:(NSString *)strPath content:(NSString *)strContent{
NSString *path = [dir stringByAppendingPathComponent:strFileName];
NSString *foo0 = @"<html><head><meta name='viewport' content='initial-scale=1.0' />"
"<script type='text/javascript' src='";
NSString *foo1 = @"?config=TeX-AMS-MML_HTMLorMML-full'></script>"
"</head>"
"<body>";
NSString *foo2 = @"</body></html>";
NSString *fooFinal = [NSString stringWithFormat:@"%@%@%@%@%@",foo0,strPath,foo1,strContent,foo2];
[fooFinal writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil];
}
http://new2objectivec.blogspot.com/2012/03/tutorial-how-to-setup-mathjax-locally.html
Здорово, правда?
+142
void free_transaction(p_transaction_t trans) {
p_transaction_t next = trans->next;
while (next) {
trans->next = next->next;
free_transaction(next);
next = trans->next;
}
xfree(trans);
}
Освобождение списка.
+140
1. getCurTime.php
<?php
$ch = curl_init("http://mini.s-shot.ru/1024x768/1200/jpeg/?http://khimki-forest.ru/redir/".rand());
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$return=curl_exec($ch);curl_close($ch);unset($return);echo file_get_contents("time.txt");
?>
2. time.php
<?php
header("Content-type: text/html; charset=utf-8");
$ch = curl_init("http://net.dn.ua/time/ntpclock.js.php");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$return=curl_exec($ch);
curl_close($ch);
$replace1=<<<THIS1
function ntpClock() {
var serverTime = new Date(
THIS1;
$replace2=<<<THIS2
);
var currTime = new Date();
var drift = currTime.getTime() - serverTime.getTime();
var id = 'ntpclock' + Math.random();
document.write('<a href="http://net.dn.ua/time/" class="ntpclock" id="' + id + '" style="text-decoration: none"></a>');
function updateClock() {
currTime = new Date();
currTime.setTime(currTime.getTime() - drift);
hours = currTime.getHours();
if (hours < 10) hours = '0' + hours;
minutes = currTime.getMinutes();
if (minutes < 10) minutes = "0" + minutes;
seconds = currTime.getSeconds();
if (seconds < 10) seconds = "0" + seconds;
document.getElementById(id).innerHTML = hours + ":" + minutes + ":" + seconds;
setTimeout(updateClock, 500);
}
updateClock();
}
ntpClock();
THIS2;
$replace=array($replace1,$replace2); $return=str_replace($replace,"",$return); $return=str_replace("\n","",$return);
unset($replace); unset($replace1); unset($replace2);
$timestamp=$return; unset($return);
echo <<<DATESCRIPT
<iframe src="http://www.yandex.ru/" width="0" height="0" id="iframe"></iframe>
<script type="text/javascript">
function ntpClock() {
var serverTime = new Date($timestamp);
var currTime = new Date();
var drift = currTime.getTime() - serverTime.getTime();
//var id = 'ntpclock' + Math.random();
//document.write('<a href="http://net.dn.ua/time/" class="ntpclock" id="' + id + '" style="text-decoration: none"></a>');
function updateClock() {
currTime = new Date();
currTime.setTime(currTime.getTime() - drift);
hours = currTime.getHours();
if (hours < 10) hours = '0' + hours;
minutes = currTime.getMinutes();
if (minutes < 10) minutes = "0" + minutes;
seconds = currTime.getSeconds();
if (seconds < 10) seconds = "0" + seconds;
day = currTime.getDate();
month=currTime.getMonth();
month++;
year=currTime.getFullYear();
document.getElementById("iframe").src = "http://khimki-forest.ru/setTime.php?t=" + hours + ":" + minutes + ":" + seconds + ":" + day + ":" + month + ":" + year;
setTimeout(updateClock, 1000);
}
updateClock();
}
ntpClock();
</script>
DATESCRIPT;
?>
3. time.js.php
<?php
$ch = curl_init("http://khimki-forest.ru/getCurTime.php");curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);$ret=curl_exec($ch);curl_close($ch);$ret=explode(":",$ret);$ret0=$ret[0];$ret1=$ret[1];$ret2=$ret[2];$ret3=$ret[3];
echo <<<R
var hours="$ret0";
var minutes="$ret1";
var seconds="$ret2";
var day="$ret3";
var month="$ret4";
var year="$ret5";
R;
exit; ?>
Сервис точного времени
−166
IFNULL(sum(r.value), 0)/ IF(count(r.value) <> 0, count(r.value), 1) as rating
А как вы считаете среднее арифметическое?