- 1
- 2
- 3
- 4
- 5
- 6
- 7
@SuppressWarnings("deprecation")
static long startHourInMS() {
final Date date = new Date();
date.setMinutes(0);
date.setSeconds(0);
return date.getTime();
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+71
@SuppressWarnings("deprecation")
static long startHourInMS() {
final Date date = new Date();
date.setMinutes(0);
date.setSeconds(0);
return date.getTime();
}
Where the Time Stood Still...
+141
if (value != null)
{
bool boolValue = (Boolean)value;
switch (boolValue)
{
case true:
return true;
case false:
return false;
}
}
Конвертер для CheckBox в WPF
+57
$format = $_[3]; # Format object
# Check for a format object
if (isset($_[3])) {
$ixfe = $format->get_xf_index();
} else {
$ixfe = 0x0F;
}
Сначала присвоить, а потом проверить наличие - это сильно!
Найдено в class.writeexcel_worksheet.inc.php - классе для заботы с .xls
+72
if (style == null || (style != null && !style.isEnabled())) {
throw new IllegalStateException();
}
if (style != null) {
do something . . .
}
−80
Dim centerX As Integer
Dim centerY As Integer
Dim radius As Integer
Private Sub Form_Activate()
centerX = 100
centerY = 100
radius = 50
End Sub
Private Sub Timer1_Timer()
Randomize
Dim x As Integer
Dim y As Integer
Dim i As Integer
Dim diff As Integer
For i = 0 To 100
Me.ForeColor = RGB(200, 0, 0)
x = centerX + (radius * Rnd)
y = centerY + (radius * Rnd)
diff = Sqr(((centerX - x) ^ 2) + ((centerY - y) ^ 2))
If (Abs(radius - diff) < 2) Then
Me.PSet (x, y)
End If
Me.ForeColor = RGB(100, 0, 0)
x = centerX - (radius * Rnd)
y = centerY + (radius * Rnd)
diff = Sqr(((centerX - x) ^ 2) + ((centerY - y) ^ 2))
If (Abs(radius - diff) = 0) Then
Me.PSet (x, y)
End If
x = centerX + (radius * Rnd)
y = centerY - (radius * Rnd)
diff = Sqr(((centerX - x) ^ 2) + ((centerY - y) ^ 2))
If (Abs(radius - diff) = 0) Then
Me.PSet (x, y)
End If
Me.ForeColor = RGB(0, 100, 0)
x = centerX - (radius * Rnd)
y = centerY - (radius * Rnd)
diff = Sqr(((centerX - x) ^ 2) + ((centerY - y) ^ 2))
If (Abs(radius - diff) > 2) Then
Me.PSet (x, y)
End If
Next i
End Sub
Извиняюсь за длину.
История происхождения: в одном древнем ВБ-шном говнопроекте сомнительного происхождения эта вещь выполняла роль постепенной прорисовки "логотипа" в окне "О программе". Отрезал сам сабж.
Вот как работает: http://tinyurl.com/ck3npah
+238
JMP $END
−96
while true
do
if [ $variable -le $null ]; then #### if then 1
vmm=`expr $vmm + 1`
if [ $vmm -eq `expr 13` ]; then
vmm=`expr 1`
fi
imm=`expr $imm - 1`
if [ $imm -eq $null ]; then
imm=`expr 12` vyy=`expr $vyy + 1`
fi
idd=`expr ${month[$imm]} + $variable`
if [ $idd -gt $null ]; then
if [ $imm -lt 10 ]; then
imm=0$imm
fi
if [ $idd -lt 10 ]; then
idd=0$idd
fi
calc_date=`expr $current_year - $vyy`$imm$idd
break;
else #### else 1
variable=`expr ${month[$imm]} + $variable`
fi
else
if [ $imm -lt 10 ]; then
vmm=0$imm
else
vmm=$imm
fi
if [ $variable -lt 10 ]; then
variable=0$variable
fi
calc_date=`expr $current_year - $vyy`$vmm$variable
break;
fi
done
echo $calc_date
#Альтернативный (нормальный) вариант
calc_date=`perl -e 'use POSIX;print strftime "%Y%m%d",localtime time-'$period*86400';'`
Дата и время в нужном формате
+66
if ($dt && $eventtype != 5 && $eventtype != 7) {
$sql_cond = " and b.datefrom='$dt'";
}
if ($eventtype == 5 || $eventtype == 7) {
if (!$dt || $dt == "0") {
$w = date("w");
$mon_dl = 7 - $w;
for ($j = 0; $j <= (7 - $w); $j++) {
$d = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + $j, date("Y")));
$dates .= ($dates ? "," . $d : $d);
}
if ($dates) $sql_cond .= " and b.datefrom in ($dates)";
}
if ($dt == "1") {
$w = date("w");
if ($w == 0) {
$monday = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y")));
} else {
$monday = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + (7 - $w) + 1, date("Y")));
}
for ($j = 0; $j <= 6; $j++) {
$d = date("Ymd", mktime(0, 0, 0, substr($monday, 4, 2), substr($monday, 6, 2) + $j, substr($monday, 0, 4)));
$dates .= ($dates ? "," . $d : $d);
}
if ($dates) $sql_cond .= " and b.datefrom in ($dates)";
}
if ($dt == "2") {
$w = date("w");
if ($w == 0) {
$monday = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y")));
} else {
$monday = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + (7 - $w) + 1, date("Y")));
}
for ($j = 7; $j <= 13; $j++) {
$d = date("Ymd", mktime(0, 0, 0, substr($monday, 4, 2), substr($monday, 6, 2) + $j, substr($monday, 0, 4)));
$dates .= ($dates ? "," . $d : $d);
}
if ($dates) $sql_cond .= " and b.datefrom in ($dates)";
}
}
я потерял сон.
+119
/**
* crane looks like this: ("----" - fork, "ssss" - stand, "xxx" - crane rail)
*
* ----- .pos2 __/0/ ----- | sssss | sssss | xxx | ----- distance between stands .pos1 __|/distance/ ----- sssss
* sssss xxx xxx xxx xxx xxx xxx
*
* so if pos2 defined - it will be the second fork; BUT! if the flag "draw second stand" defined - that will draw or
* not draw the stand for pos1...
*
* if there is just one fork but two TUs to handle is possible:
*
* xxx ________ .pos1 .pos2 ________ sssss sssss xxx xxx xxx
*/
−104
+ (NSArray *)findAll {
return [self findWithPredicate: [NSPredicate predicateWithFormat:@"1 = 1"]
limit: 0];
}
Таки да, все объекты.