- 1
- 2
- 3
- 4
- 5
- 6
function DateFromDBToHr($date)
{
$datetime = explode(" ", $date);
$dates = explode("-", $datetime[0]);
return (intval($dates[0])) ? date("d-M-Y", mktime(0, 0, 0, $dates[1], $dates[2], $dates[0])) : false;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+159
function DateFromDBToHr($date)
{
$datetime = explode(" ", $date);
$dates = explode("-", $datetime[0]);
return (intval($dates[0])) ? date("d-M-Y", mktime(0, 0, 0, $dates[1], $dates[2], $dates[0])) : false;
}
про то, что форматировать дату можно в запросе или про существование strtotime автор даже не догадывается
+158
(function(){ if(!window.adToken) { window.adToken = Math.floor(Math.random() * 999999999999999999); }
var d = new Date();
var url = (location.protocol=='https:'?'https://base.kiwi.kz/?':'http://base.kiwi.kz/?');
url += 'rnd=' + Math.floor(Math.random() * 99999999999);
url += '&slot_id=25';
url += '&type=js';
url += '&t=' + parseInt(((d.getTime() - (d.getTimezoneOffset() * 60)) / 1000));
url += '&token=' + window.adToken;
url += '&r=' + window.location;
var js = '<sc' + 'ript src="' + url + '"></sc' + 'ript>';
document.write(js);
}());
sc' + 'ript ?
+120
public static string GetRedirectUrl(string userName, bool createPersistentCookie)
{
if (userName == null)
{
return null;
}
return GetReturnUrl(true);
}
из рефлектора, класс FormsAuthentication
ахеренная роль у параметров userName и createPersistentCookie
+168
class TalentsWindow : public PopupWindow {
render::Sprite* m_background_sprite, *m_header_sprite, *m_fucking_sprite;
...
...
};
...
TalentsWindow::TalentsWindow()
{
...
m_fucking_sprite = m_sprites.addSprite(render::SpriteRect(NOINITIALIZE)
.setTop(591.0f)
.setLeft(500.0f)
.setWidth(411.0f)
.setHeight(140.0f),
m_tex,
0.85f
);
m_fucking_sprite->setPosition(math::float2(818.0f, 50.0f));
m_fucking_sprite->idiot = true;
...
}
Самодокументирующий код.
+134
private static void GetUserData(User user)
{
if (user == null)
return;
var firm = user.Firm;
if (firm == null)
return;
}
Бессмысленно и беспощадно.
−137
<?php
if($argc<2) exit(0);
print_r($tmp);
for($i=1;$i<=$argc;$i++)readdir_rec($argv[$i]);
function readdir_rec($path){
$dir = opendir($path);
global $size;
while($d = readdir($dir)){
if ($d == '.' || $d == '..') continue;
if (is_file($path.'/'.$d)){
echo $path."/".$d."\n";
}
else if (is_dir($path.'/'.$d)) readdir_rec($path.'/'.$d);
}
}
?>
#!/bin/bash
c=0;
declare -a fls;
for fl in `php /home/markus/bin/ps2.php $*`
do
let c++;
fls[$c]=$fl;
done
for((i=0;i<=${#fls[@]}-1;i++))
{
for((i2=$i+1;i2<=${#fls[@]};i2++))
{
echo "${fls[$i]} ${fls[$i2]}";
diff -acBi --brief ${fls[$i]} ${fls[$i2]}
}
}
Находит одинаковые файлы по содержанию
−126
#!/bin/bash
c=0;
declare -a fls;
cat $*| while read line
do
# echo "line $line №$c"
fls[$c]=$line;
let c++;
for((i=0;i<=${#fls[@]}-1;i++))
{
for((i2=$i+1;i2<=${#fls[@]};i2++))
{
# echo "${fls[$i]} ${fls[$i2]}";
if [ ${fls[$i]} = "${fls[$i2]}" ];then
echo "Zeile $i ist gleich Zeile $i2";
#else
# echo "Строка $i не равна строке $i2";
fi
}
}
done
Находит одинаковые строки в файле
+195
for($j=0;$j<23000000;$j++); //пауза ~3 сек
Ну как вам? :)
+154
<?php
require_once('MultiAutoload.php');
class Dispatcher {
private $handle;
function __construct($event_handle) {
$this->handle = $event_handle;
}
function handleEvent() {
$name = 'Handler_'.$this->handle;
if (class_exists($name)) {
$handler_obj = new $name($this->handle);
$response = $handler_obj->secureHandler();
return $response;
}
else {
throw new Exception('Event handling is impossible!');
}
}
}
?>
Немного экзотики: PHP в стиле Win32! Говно за собой не сразу увидел,
но когда "пришло озарение" было смешно.
+127
public IQueryable<AuditEntry> ViewAudit()
{
var items = _operationEntities.AuditItems.AsQueryable();
return items.Select((item) => new AuditEntry()
{
OperationID = item.Id,
CreationTime = item.CreationTime,
Description = item.AuditItemType.StringFormat.Replace(
"{0}", item.InsertionStrings.Where((x) => x.StringId == 0).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
"{1}", item.InsertionStrings.Where((x) => x.StringId == 1).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
"{2}", item.InsertionStrings.Where((x) => x.StringId == 2).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
"{3}", item.InsertionStrings.Where((x) => x.StringId == 3).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
"{4}", item.InsertionStrings.Where((x) => x.StringId == 4).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
"{5}", item.InsertionStrings.Where((x) => x.StringId == 5).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
"{6}", item.InsertionStrings.Where((x) => x.StringId == 6).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
"{7}", item.InsertionStrings.Where((x) => x.StringId == 7).Select((x) => x.String).FirstOrDefault() ?? String.Empty),
CreatedBy = item.CreatedBy,
OperationType = item.AuditItemType.MessageType.Name,
OperationCategory = item.AuditItemType.AuditCategory.Name,
});
}
Паровозик. Реализация string.Format() в виде linq-запроса