- 1
$page->WantsChildren();
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+147
$page->WantsChildren();
в раздел "юмор", что ли?
обнаружил забавный метод в
cms made simple
почему бы не "isLeaf"
+957
string lText = string.Format("{0} - VaR, Holding period: {1} days: {2}", new string[] { aConfidenceLevel.ToString("p", lNumberFormat), aHoldingPeriod.ToString(), mVARCalculator.GetVaR(aConfidenceLevel, aHoldingPeriod).ToString("n", lNumberFormat) });
Лауреат конкурса "Отформатируй мою строку 2011". Первородный грех VB, лихо заквашенный на голландских дрожжах, не даёт автору обрести просветление в этом жестоком мире.
+132
movq (%rdi), %rdi # this.11_6->_M_impl._M_start, D.49210
testq %rdi, %rdi # D.49210
je .L1 #,
jmp _ZdlPv #
.p2align 5,,7
.p2align 3
.L1:
rep
ret
Говнокод от компилятора g++-4.5.2
Почему нельзя было сделать так:
movq (%rdi), %rdi # this.11_6->_M_impl._M_start, D.49210
testq %rdi, %rdi # D.49210
jne _ZdlPv #,
rep
ret
Не понимаю...
+171
if (@$_REQUEST['send'])
{
Header("Location: /index.php");
exit();
$username = $_REQUEST['username'];
$message = $_REQUEST['message'];
$a = new message();
$a->connectdb();
$a->addpost($username, $message) or die(mysql_error());
$a->view();
}
"Поправил вот так, работает вроде нормально", - автор.
Источник: http://www.askdev.ru/question/6646/%D0%9F%D0%BE%D1%87%D0%B5%D0%BC%D1%83-%D0%BD%D0%B5-%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%B0%D0% B5%D1%82-%D1%80%D0%B5%D0%B4%D0%B8%D1%80%D0%B5%D0% BA%D1%82/new/#answer12608,comment21490
+154
type
число=ineger;
плюс_число=word;
эконом=shortint;
плюс_эконом=byte;
моар=longint;
граммар=real;
йцукен=char;
йцуукеен=string;
холивар=boolean;
+163
Файл 1 :
<?php
for ($i=0; $i<10; $i++) // Моё примечение - вонять начинает отсюда
{
include "delstr.php";
include "razdel2.php";
include "gendat.php";
include "dopismain.php";
}
Файл delstr.php:
<?php
$num_stroka = 7; //Удалим 7 строку из файла
$file = file("gendat.php"); // Считываем весь файл в массив
for($i = 0; $i < sizeof($file); $i++)
if($i == $num_stroka) unset($file[$i]);
$fp = fopen("gendat.php", "w");
fputs($fp, implode("", $file));
fclose($fp);
?>
Файл razdel2.php:
<?php
$sl = file('ancorrzd.txt');
$sm = $sl[array_rand($sl, 1)];
$datam = $sm;
$file = fopen ("rzd.txt","w");
$str = "$datam";
fputs ( $file, $str);
fclose ($file);
$dataC = trim(file_get_contents ("rzd.txt"));
$data="\$dataCata='$dataC';";
$file = 'gendat.php';
$array=file( $file );
$array[7]= $data; //строка в которой нужно изменить значение $data
file_put_contents( $file, $array );
?>
Файл gendat.php:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
ini_set('session.auto_start', '1');
//ini_set('upload_tmp_dir', 'c:\tmp');
set_time_limit(120);
@session_start();
$dataCata='xfgjcfyi';
$txtFile = 'result.txt'; // файл с текстом
$ancorFile = 'ancor.txt'; // файл с заголовками
$tplFile = 'template.txt'; // файл шаблона .dat файлов
$mainTplFile= 'maintemplate.txt'; // Шаблон файла со ссылками
$datDir = "articles/$dataCata"; // директория для .dat файлов
$datExt = 'dat'; // расширение .dat файлов
$mainFile = 'main.dat'; // Файл со ссылками на .dat файлы
$srcCharset = 'cp1251'; // Кодировка исходных файлов
$destCharset = 'cp1251'; // Кодировка файлов на выходе
$scriptCharset = 'utf-8'; // Кодировка скрипта
$blockLength = 4000; // Максимальный размер блока в байтах из файла с текстом
$file = fopen ("engine/menu.php","a");
$str = "<li><a href=\"/$dataCata/\">$dataCata</a></li>";
if ( !$file )
{
echo("Ошибка открытия файла");
}
else
{
fputs ( $file, $str);
}
fclose ($file);
if ($srcCharset == 'utf-8') $blockLength *= 2;
$blockLength = $blockLength % 2 > 0 ? $blockLength+1 : $blockLength;
if ( !is_dir($datDir) ) mkdir($datDir, 0777, true);
$hMain = NULL;
if ( !(@$hMain = fopen($mainFile, 'w+')) ) die("Невозможно создать файл $mainFile<br/>\b");
$hText = fopen($txtFile, 'r');
$ancors = explode("\n", $srcCharset == $scriptCharset ? file_get_contents($ancorFile) : iconv($srcCharset, $scriptCharset, file_get_contents($ancorFile)));
$template = $srcCharset == $scriptCharset ? file_get_contents($tplFile, 'r') : iconv( $srcCharset, $scriptCharset, file_get_contents($tplFile, 'r') ); // читаем шаблон
$content = '';
while ($content = fread($hText, $blockLength)) {
$fname = genName();
if (@$hDat = fopen("$datDir/$fname.$datExt", 'w')) {
$ancor = trim($ancors[rand(0, count($ancors)-1)]);
$content = $srcCharset == $scriptCharset ? trim($content) : iconv($srcCharset, $scriptCharset, trim($content));
// Генерим dat файлы по шаблону
$thisTpl = preg_replace("/(<!--.*?Kan_title.*?-->).*?(<!--.*?Kan_title.*?-->)/uism", "$1\n$ancor\n$2", $template);
$thisTpl = preg_replace("/(<!--.*?Kan_content.*?-->).*?(<!--.*?Kan_content.*?-->)/uism", "$1\n$content\n$2", $thisTpl);
$thisTpl = $scriptCharset == $destCharset ? $thisTpl : iconv( $scriptCharset, $destCharset, $thisTpl );
if (fwrite($hDat, $thisTpl)) {
echo "Файл $dataCata/$fname.$datExt записан<br/>\n";
$html = "
<loc><a href=\"/$dataCata/$fname.html\">$ancor</a></loc>\n";
fwrite($hMain, iconv($scriptCharset, $destCharset, $html));
} else { echo "Ошибка записи в файл $dataCata/$fname.$datExt<br/>\n"; }
} else {
echo "Не могу записать в файл $dataCata/$fname.$datExt<br/>\n";
}
}
// Генерация уникального имени
function genName() {
return substr(md5(uniqid(rand(), true)), 0, rand(7, 13));
}
?>
Человек интересуется, почему цикл выполняется только 1 раз. Ему посоветовали разместить лучше свой код тут, но по-моему, делать это самостоятельно у него желания нет, решил помочь. Пруфлинк - http://forum.searchengines.ru/showthread.php?t=643176
−96
import os
import codecs
from xml.dom import minidom
dir = 'C:\\Users\\pee\\AppData\\Roaming\\Thunderbird\\Profiles\\your_profile_here.default\\extensions'
target = 'install.rdf'
TB_id = '{3550f703-e582-4d05-9a08-453d09bdfdc6}'
maxVer = '5.*'
# open file, parse xml, find Thunderbird ID, change maxVersion, save file
def verchanger(rdf):
found = False
print(rdf)
xmldoc = minidom.parse(rdf)
idlist = xmldoc.getElementsByTagName("em:id")
for i in idlist:
if i._get_firstChild().nodeValue == TB_id:
print('Thunderbird ID was founded in em:id node with index ', idlist.index(i)+1)
print(i.parentNode.getElementsByTagName("em:maxVersion")[0]._get_firstChild().nodeValue)
if i.parentNode.getElementsByTagName("em:maxVersion")[0]._get_firstChild().nodeValue == maxVer:
print('file already updated, skipping')
break
else:
found = True
i.parentNode.getElementsByTagName("em:maxVersion")[0]._get_firstChild().nodeValue = maxVer
print('new value is: ', i.parentNode.getElementsByTagName("em:maxVersion")[0]._get_firstChild().nodeValue )
if found:
xmldoc.writexml(codecs.open(rdf,'w','utf-8'), encoding='utf-8')
# get list of files with full paths
filelist = [dir + '\\' + x + '\\' + target for x in os.listdir(dir)]
for i in filelist:
verchanger(i)
Мой первый говнокод :)
Проходит по папке с расширениями Thunderbird, изменяя требуемую минимальную версию плагина на железно заданную maxVer. Вынужденно наговнокодено после обновления ТБ на версию 5.
Прошу разобрать по косточкам, я Питон только изучаю. Дочитал Лутца до классов, почти всё накопал с помощью Гугля .
−120
if( (ori == UIInterfaceOrientationLandscapeLeft) || (ori == UIInterfaceOrientationLandscapeRight))
{
// Some code
}
else if(ori==UIInterfaceOrientationPortrait || ori==UIInterfaceOrientationPortraitUpsideDown)
{
// Some other code
}
else {
// God mode on!
}
Реальный проект после индусов... Что движет этими людьми я не понимаю...
+109
if (File.Exists(local)) {
if (Connect()) {
if (ftpConnection.Exists(remote)) {
//code
}
}
}
+147
uint32_t getuint32(char *p){
return (*p<<24)|(*(p+1)<<16)|(*(p+2)<<8)|(*(p+3));
}