- 1
- 2
- 3
- 4
- 5
- 6
- 7
private function _fileExists($file)
{
if(file_exists(self::FILE_PATH . $file)) {
return true;
}
return false;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+147
private function _fileExists($file)
{
if(file_exists(self::FILE_PATH . $file)) {
return true;
}
return false;
}
Нашел в одном из проектов.
+181
#include "iostream"
using namespace std;
enum {MaxFucktorial=13};
static int fucks[MaxFucktorial+1];
template<const int ValuePosition, const int Value>
struct initFuckedValue
{
enum {CurrentValue=Value*ValuePosition};
static void fuckUp(void)
{
fucks[ValuePosition]=CurrentValue;
initFuckedValue<ValuePosition+1, CurrentValue>::fuckUp();
};
};
template<const int Value>
struct initFuckedValue<MaxFucktorial, Value>
{
static void fuckUp(void){};
};
void InitFucks(void)
{
fucks[0]=1;
initFuckedValue<1,1>::fuckUp();
};
int _tmain(int argc, _TCHAR* argv[])
{
cout<<"Введите аргумент факториала: "<<endl;
InitFucks();
int fuckArg=0;
cin>>fuckArg;
cout<<"Начинаем считать факториал..."<<endl
<<"Подсчёт факториала успешно завершён. ОК."<<endl
<<"Результат: "<<fucks[fuckArg]<<endl;
cin>>fuckArg;
return 0;
}
Решил запостить всё. Жемчужена.
Мой знакомый, молодой преподаватель-аспирант из института пришёл однажды расстроенный. Спрашиваю у него: "Что случилось?"
-- "Один мой первокурсник, когда я дал ему задание посчитать факториал через рекурсию принёс мне какую-то непонятную компилирующуюся галиматью. И считает она уж слишком быстро... Это какая-то программа обманка. Вообщем я ему поставил 2."
Да, это лаба. ^_^
+159
$get = dbcom('SELECT * FROM downloads ORDER BY views DESC;');
$i = 1;
while($row = mysql_fetch_array($get))
{
if($i == 1)
{
$p['v'] = $row['views'];
}
if($row['reports'] != 0)
{
$t['rep']++;
}
$t['dl'] += $row['views'];
$i = 0;
}
DDLCMS is a COMMERCIAL grade content management system for DDL site owners.
при 400к записях в downloads немножно все в ОЗУ не помещалось.
+89
// qsort.inc:
procedure SortRow(var A: array of T);
procedure sort(l,r: integer);
var
i,j: integer;
x,y: T;
begin
i := l;
j := r;
x := a[random(r-l+1)+l];
repeat
while LESS(a[i],x) do inc(i);
while LESS(x,a[j]) do dec(j);
if i<=j then begin
y := a[i];
a[i] := a[j];
a[j] := y;
inc(i);
dec(j);
end;
until i>=j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end;
begin
Sort(Low(A), High(A));
end;
// unit1.pas
T = TPoint;
function LESS(const a,b: T): boolean;
begin
result := a.x<b.x;
end;
{$I qsort.inc}
var
a: array of TPoint;
begin
...
SortRow(a);
...
end;
Я использую шаблоны в Дельфи-7 ололо.
+153
function read($fields = null, $id = null) {
$this->validationErrors = array();
if ($id != null) {
$this->id = $id;
}
$id = $this->id;
if (is_array($this->id)) {
$id = $this->id[0];
}
if ($id !== null && $id !== false) {
$this->data = $this->find(array($this->alias.'.'.$this->primaryKey => $id), $fields);
return $this->data;
} else {
return false;
}
}
И ещё cakePHP (самый-самый фреймворк, даже в говнокоде впереди планеты всей).
+147
if ($this->alias === null) {
$this->alias = (isset($alias) ? $alias : $this->name);
}
Это cakePHP. Вот так вот в нём модель узнаёт свой alias.
+147
Если вам нужно запустить скрипт написанный на jQuery по окончанию загрузки страницы
$(document).ready( function(){
// ну и тут ваш код
});
Преимущество это метода, в том, что он исполняет скрипт по окончанию загрузки кода страницы, НЕ включая флеш баннеры и видео.
Увидел на одном сайте, который "учит" jQuery
+131
copy /b *.mpg FullMovie.mpg
1. Open a blank text file.
2. Type copy /b *.mpg FullMovie.mpg
3. Save the file with a .Bat extension.
Let's say you saved the text file as Joiner.Bat.
4. Now Copy and Paste this Joiner.Bat file in a folder which contains more than one mpg files.
5. Double click the Joiner.Bat file.
−131
РегламентированнаяОтчетность.ПередОткрытиемФормыРегламентированногоОтчета(ЭтаФорма, Отказ);
////Вызывается перед открытием, а потом видим:
Процедура ПередОткрытиемФормыРегламентированногоОтчета(Форма, Отказ) Экспорт
Отказ = Ложь;
КонецПроцедуры
+139
bool aiccu_os_install(void)
{
/* Check if IPv6 support is available */
if (access("/proc/net/if_inet6", F_OK))
{
/* Doing the modprobe doesn't guarantee success unfortunately */
(void)system("modprobe -q ipv6 2>/dev/null >/dev/null");
/* Thus test it again */
if (access("/proc/net/if_inet6", F_OK))
{
dolog(LOG_ERR, "No IPv6 Stack found! Please check your kernel and module configuration\n");
return false;
}
}
/* Try to load modules (SIT tunnel, TUN/TAP)
* They can be kernel builtins and there is no easy
* way to check if they are loaded/built except for
* trying to use them and fail at that point
*/
(void)system("modprobe -q sit 2>/dev/null >/dev/null");
(void)system("modprobe -q tun 2>/dev/null >/dev/null");
return true;
}