- 1
- 2
// Получаем объект логгера
$this->logger = nvCommandLogger::getInstance();
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+148
// Получаем объект логгера
$this->logger = nvCommandLogger::getInstance();
Спасибо, Кэп!
+163
Example #3 preg_replace_callback() using recursive structure to handle encapsulated BB code
<?php
$input = "plain [indent] deep [indent] deeper [/indent] deep [/indent] plain";
function parseTagsRecursive($input)
{
$regex = '#\[indent]((?:[^[]|\[(?!/?indent])|(?R))+)\[/indent]#';
if (is_array($input)) {
$input = '<div style="margin-left: 10px">'.$input[1].'</div>';
}
return preg_replace_callback($regex, 'parseTagsRecursive', $input);
}
$output = parseTagsRecursive($input);
echo $output;
?>
Не знаю, баян или нет. Поиском не смог найти preg_replace_callback на этом сайте.
В таком недлинном коде есть очень аппетитное дерьмецо (кроме языка). Если в качестве $input взять строку подлиннее, то интерпретатор, как Чак Норрис, сосчитает до бесконечности. Исправляется добавлением одного символа к коду.
+164
//Пришел
$in_h = "10";
//Ушел
$exit_h = "19";
//Для определения, ушел после полуночи или до
$metka = date(a);
if ($metka == "pm") {
echo ("24" - $in_h)-("24" - $exit_h);
}
else if ($metka == "am")
{
echo "am";
echo "24" - $in_h + $exit_h;
вычисление времени, проведенного на работе..
+79
boolean direct = !Boolean.FALSE.equals(directParam);
boolean demoAgency = !direct;
+150
function rustrtolower($s)
{
$from = array("А","Б","В","Г","Д","Е","Ё","Ж","З","И","Й","К","Л","М","Н","О","П","Р","С","Т","У","Ф","Х","Ц","Ч","Ш","Щ","Ъ","Ы","Ь","Э","Ю","Я","A","B","C","D","E","F","G","H","I","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","J");
$to = array("а","б","в","г","д","е","ё","ж","з","и","й","к","л","м","н","о","п","р","с","т","у","ф","х","ц","ч","ш","щ","ъ","ы","ь","э","ю","я","a","b","c","d","e","f","g","h","i","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","j");
return str_replace($from, $to, $s);
}
+151
var GetUrl = /\[(.*)\]/g.exec("$SECTION_NAME$")[1].replace(/\-/i, '~').replace(/\-/i, '~');
фу ;(
+155
if($inc == true){
$counter_val = $cat[$this->FileCounterKey] + 1;
}else{
$counter_val = $cat[$this->FileCounterKey] - 1;
}
Класс деревьев в одной русской CMS. Метод пересчитывает кол-во файлов в категории после добавления/удаления.
+75
<% ServicePackage servicePackage = null; %>
<% char fi [] = {'g', 'v', 'p'}; %>
<% int ni [] = {3, 7, 11}; %>
<% for(int i = 0; i < fi.length; i++)
for(int j = 1; j <= ni[i]; j++)
{
String id = "", name = null, brief = null, price = null;
id += (char)fi[i];
if (j >= 10)
id += (char)('0' + j / 10);
id += (char)('0' + j % 10);
servicePackage = AllServicePackages.map.get(id);
if (servicePackage != null)
{
name = servicePackage.getName();
brief = servicePackage.getBrief();
price = servicePackage.getPrise();
}
%>
<% } %>
Автору хотелось перебрать все эл-ты map'а.
−120
if( (ori == UIInterfaceOrientationLandscapeLeft) || (ori == UIInterfaceOrientationLandscapeRight))
{
// Some code
}
else if(ori==UIInterfaceOrientationPortrait || ori==UIInterfaceOrientationPortraitUpsideDown)
{
// Some other code
}
else {
// God mode on!
}
Реальный проект после индусов... Что движет этими людьми я не понимаю...
+166
// say this is some existing structure. And we want to use
// a list. We can tell it that the next pointer
// is apple::next.
struct apple {
int data;
apple * next;
};
// simple example of a minimal intrusive list. Could specify the
// member pointer as template argument too, if we wanted:
// template<typename E, E *E::*next_ptr>
template<typename E>
struct List {
List(E *E::*next_ptr):head(0), next_ptr(next_ptr) { }
void add(E &e) {
// access its next pointer by the member pointer
e.*next_ptr = head;
head = &e;
}
E * head;
E *E::*next_ptr;
};
int main() {
List<apple> lst(&apple::next);
apple a;
lst.add(a);
}
c++ страшный язык :) (часть вторая)
C++: Pointer to class data member: http://stackoverflow.com/questions/670734/c-pointer-to-class-data-member
Такие конструкции "E *E::*next_ptr;" без подготовки не осилить.