- 1
$v = (((bool) $v) ? true : false);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+83
$v = (((bool) $v) ? true : false);
+71
<?php
session_start();
$uploadName = 'test';
if (isset($_GET['ajax'])) {
if (isset($_SESSION["upload_progress_$uploadName"])) {
$progress = $_SESSION["upload_progress_$uploadName"];
$percent = round(100 * $progress['bytes_processed'] / $progress['content_length']);
$text1 = iconv("CP1251", "UTF-8", "Общий прогресс загрузки: ");
$text2 = iconv("CP1251", "UTF-8", "Загружается файл: ");
$text3 = iconv("CP1251", "UTF-8", "Общее время загрузки: ");
$text4 = iconv("CP1251", "UTF-8", "Скорость загрузки: ");
$text5 = iconv("CP1251", "UTF-8", " сек. ");
$text6 = iconv("CP1251", "UTF-8", " Мбайт. ");
echo '<HTML><HEAD><title>Upload</title><meta name="keywords"><meta name="description" ><meta http-equiv="content-type" content="text/html;charset=windows-1251"></HEAD><BODY>';
$pos1 = $percent * 4;
$pos2 = 400 - $pos1;
echo '<div style="background: #00ff00; width: '.$pos1.'; height: 10px; border: solid 1px black; "></div><div style="background: #ffe4e1; width: '.$pos2.'px; height: 10px; position: relative; left: '.$pos1.'px; top: -12px; border: solid 1px black;"></div>';
echo '<div align="center" style="width: 400;">';
echo '<b>'.$text1.$percent.'%<br>';
$t3 = time() - $progress[start_time];
echo $text3.$t3.$text5.'<br>';
if ($t3 < 1 ) { $t3 = 1; }
$speed = (($progress[bytes_processed] / $t3) / 1024) / 1024;
echo $text4.$formatted = sprintf ("%01.2f", $speed).$text6.'</b><br>';
for($i=0;$i<count($progress[files]);$i++){ echo $text2.$progress[files][$i][name].'<br>'; }
echo '</div>';
} else {
echo '<div align="center" style="width: 400;">no uploading</div>';
}
exit;
} elseif (isset($_GET['frame'])) { ?>
<div align="center"><form align="center" action="" method="POST" enctype="multipart/form-data">
<input type="hidden" name="<?=ini_get("session.upload_progress.name")?>"
value="<?=$uploadName?>" />
<input type="file" name="file[]" multiple="true"/><input value="Загрузить" type="submit" /></form></div>
<?php
if($_FILES){
for($i=0;$i<count($_FILES["file"]["name"]);$i++){
if(is_uploaded_file($_FILES["file"]["tmp_name"][$i])){
move_uploaded_file($_FILES["file"]["tmp_name"][$i], "upload/".$_FILES["file"]["name"][$i]);
}
}
echo '<div align="center">загружено</div>';
}
?>
<?php } else { ?>
<HTML><HEAD><title>Upload</title><meta name="keywords"><meta name="description" ><meta http-equiv="content-type" content="text/html;charset=windows-1251">
</HEAD><BODY><div align="center" style="width: 400;"><H3>Загрузчик файлоф на сайт</H3>требования: PHP 5.4, Firefox 3,6 и выше</div>
<iframe src="?frame" height="70" width="400" align="center" frameborder="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" scrolling="no" style="overflow:visible"></iframe>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script>
$(function() {
setInterval(function() {
$.get('?ajax', function(data) {
$('#ajax').html(data);
});
}, 500);
});
</script>
<div id="ajax"></div>
<?php }
...
+157
var c = 'function' === typeof o.pop ? [] : {};
+111
{$APPTYPE CONSOLE}
{$R *.res}
type
TFTest = class
public
B: string;
function Add(S: string = ''): TFTest;
constructor Create(T: TFTest); overload;
end;
function TFTest.Add(S: string): TFTest;
begin
B := B + S;
Exit(Self);
end;
var
A: TFTest;
constructor TFTest.Create(T: TFTest);
begin
B := T.B;
end;
begin
writeln(TFTest.Create.Add('0')
.Create((TFTest.Create(TFTest.Create(((((((TFTest.Create(TFTest.Create).Add('0')).Add('1').Create.Add('2')
.Add as TObject).Create) as TFTest.ClassParent) as TFTest).Create).Add('3')).Add.Add('4').Create).Add('5')).Add('6')
).Add('7').B);
readln;
end.
Кто правильно обьяснит этот код, получит... ничего получит :)
+142
class Program
{
static void Main()
{
A a = new A();
E e = new E();
e = (E)(D)(C)(B)(A)a; //обычная конвертация =)
}
}
class A { }
class B : A { }
class C : B { }
class D : C { }
class E : D { }
Обычная явная конвертация =)
+101
Thread thread = new Thread(delegate() {
Thread subThread = new Thread(delegate() {
Thread subsubThread = new Thread(delegate() {
Console.WriteLine("Hello World! Best version of first console propgram :)");
Console.ReadLine();
});
});
});
Лучшая версия первой консольной программы)
+115
foreach (var sheet in paper.Decomposed)
{
if (ct > 0 && sheet.Equals(paper.Decomposed[ct]))
{
paper.PaperPrice += paperPrice;
paper.PrintingPrice += printingPrice;
paper.PlatesPrice += platesPrice;
ct++;
continue;
}
ct++;
...
}
+150
function (post, hash) {
if (!vk.id || cur.viewAsBox) return;
var icon = ge('like_icon' + post),
my = hasClass(icon, hasClass(icon, 'fw_like_icon') ? 'fw_my_like' : 'my_like'),
matches = post.match(/(-?\d+)(_?)(photo|video|note|topic|wall_reply|note_reply|photo_comment|video_comment|topic_post|)(\d+)/),
like_obj = (matches[3] || 'wall') + matches[1] + '_' + matches[4],
ref = cur.wallType ? (cur.wallType == 'feed' ? 'feed_' + cur.section : ('wall_' + (cur.onepost ? 'one' : (!(cur.wallType || '').indexOf('full_') ? 'full' : 'page')))) : cur.module;
ajax.post('like.php', {act: 'a_do_' + (my ? 'un' : '') + 'like', 'object': like_obj, hash: hash, wall: 1, from: ref}, {
onDone: wall.likeUpdate.pbind(post, !my)
});
var count = val(ge('like_real_count_wall' + post) || ge('like_count' + post));
wall.likeUpdate(post, !my, intval(count) + (my ? -1 : 1));
if (cur.onWallLike) {
cur.onWallLike();
}
}
Зачем посоны из контакта пишут такой говно-код? Куда смотрит Паша?
−148
if([value objectForKey:fTimestamp] == [NSNull null]){
objectData.Timestamp = [[value objectForKey:fTimestamp]intValue];
}else{
objectData.Timestamp = 0;
}
В зарелизинной версии проекта было.
А я сидел и думал, почему половина полей из базы маппятся в нули в классы сущностей...
+164
/* выравниваем высотку блока контента, чтобы совпадал с клеточками бэкграунда */
$('#center>div').each(function(){
$(this).height(function(i,val){
if(val<200){return 200;}
if(val<401){return 401;}
if(val<602){return 602;}
if(val<803){return 803;}
if(val<1004){return 1004;}
if(val<1205){return 1205;}
if(val<1406){return 1406;}
if(val<1607){return 1607;}
if(val<1808){return 1808;}
if(val<2009){return 2009;}
if(val<2210){return 2210;}
if(val<2411){return 2411;}
if(val<2612){return 2612;}
if(val<2813){return 2813;}
if(val<3014){return 3014;}
});
});
Это была первая и вероятно последняя попытка разгрузить штатных программистов, отдав часть несложной работы фрилансерам :)