-
+139
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
for (int i = 0; i < 100; i++)
{
string s = i.ToString();
if (s.Length == 1)
{
s = "00" + s;
}
if (s.Length == 2)
{
s = "0" + s;
}
Console.WriteLine(s);
}
Из рабочего проекта. Парень не слышал про string.Format("{0:000}", i)
pewpew,
28 Февраля 2013
-
+81
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
public String isThisScreenWithHdpiDensity() {
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
switch (metrics.densityDpi) {
case DisplayMetrics.DENSITY_LOW:
return "ldpi";
case DisplayMetrics.DENSITY_MEDIUM:
return "mdpi";
case DisplayMetrics.DENSITY_HIGH:
return "hdpi";
}
return "xhdpi";
}
...
if (isThisScreenWithHdpiDensity().equals("hdpi")) {
lpTabPane.height = 65;
}
if (isThisScreenWithHdpiDensity().equals("mdpi")) {
lpUpperPane.height = 70;
}
if (isThisScreenWithHdpiDensity().equals("ldpi")) {
lpTabPane.height = 32;
}
if (isThisScreenWithHdpiDensity().equals("xhdpi")) {
}
Перегоним константу в стрингу, а потом проверим ее equals. Отлично!
danikula,
28 Февраля 2013
-
+8
- 1
- 2
#define I_HATE_MACRO2(BEGIN__, END__) BEGIN__##END__
#define CONCAT_MACRO(BEGIN__, END__) I_HATE_MACRO2(BEGIN__,END__)
LispGovno,
28 Февраля 2013
-
+113
- 1
- 2
- 3
public static void assertAlmostEquals(final double actual, final double expected) {
Assert.assertTrue(Math.abs(actual - expected) < 0.000001);
}
someone,
28 Февраля 2013
-
+119
- 1
Dummy commit for the sake of documentation (previous commit was made without a message)
someone,
28 Февраля 2013
-
−169
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
DECLARE @IsPerson BIT
,@ContactTypeID INT
SET @ContactTypeID = CASE WHEN @IsPerson = 0 THEN 3 ELSE 4 END
IF (LEN(ISNULL(@FirstName,'')) <= 0 AND LEN(ISNULL(@LastName,'')) <= 0 AND (LEN(@EntityName) > 0 OR LEN(@TradingAs) > 0))
BEGIN
SET @IsPerson = 0
END
ELSE
BEGIN
SET @IsPerson = 1
END
Такая себе Stored Procedure...
Magic numbers - это всё фигня. Меня всегда интересовало, почему тип контакта всегда 4?
И, да, строки идут именно в такой очерёдности.
kore_sar,
28 Февраля 2013
-
+155
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
//...
else if (data.indexOf('none') == -1)
{
// Экспорт в работе
// Повторять запрос раз в nSec секунд.
nSec = 3;
document.getElementById("export_loading").show();
setTimeout("loadFile({{subject_id}}, '')", nSec*1000);
}
//...
<div class='loader' id="export_loading" style="visibility: hidden; display: inline-block; text-align: center; margin-right: 13px;"><img src='/app/images/loading.gif'/> идёт формирование списка авторов</div>
<div id="messages_container" style="visibility: hidden; padding: 0px 30px 0 35px;">
</div>
Чувак вообще прикалывается)
greevex,
27 Февраля 2013
-
+146
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
class Step {
public function xxx($arg1, $arg2 = NULL) {
};
}
class FirstStep extends Step {
public function xxx($arg3, $arg1 = NULL, $arg2 = NULL) {
};
}
В очередной раз подтверждает что пхп - гамно!
А автору кода вообще линейкой по пальцам, куда, как, зачем менять сигнатуру да и еще не правильно!!!
И это в проэкте каторый стоит 15000Евро
v_anonym,
27 Февраля 2013
-
−160
- 1
- 2
- 3
Процедура ЗАЕБАШИТЬЧТОБВСЕРАБОТАЛО ()
СООБЩИТЬ("Так не бывает!");
КонецПроцедуры
Из реального проекта крупного торгового дома.
infolex,
27 Февраля 2013
-
−116
- 1
- 2
for (var i:int = 0; i < _dropCount;_dropCount--)
// todo
Cpp,
26 Февраля 2013