-
+129
- 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
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
#region Work with massive slovo
public string sFileNameMassiveSlovar = "";
public bool flChangeSlovo = false;
public int nCountSavedSlovo { get; private set; }
public int nCountAllSlovo { get; private set; }
public int nCountAddSlovo { get; private set; }
public void ClearMassiveSlovo()
{
slovo = slovo.Select(n => (byte)0).ToArray();
}
public int GetCountAllSlovo()
{
int npock = nLengthSlovo;
return slovo.Where((n, index) => index % npock == 0 && n != 0).Count();
}
public bool WriteMassiveSlovo()
{
bool res = false;
FileStream fs = null;
try
{
fs = File.Open(sFileNameMassiveSlovar, FileMode.Create, FileAccess.Write);
if (fs != null)
{
fs.Write(slovo, 0, nSizeMassiveSlova);
}
res = true;
}
catch (Exception e1)
{
res = false;
System.Windows.Forms.MessageBox.Show(e1.Message);
}
finally
{
if (fs != null) fs.Close();
}
return res;
}
#endregion
just_nameless,
14 Октября 2013
-
+171
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
public abstract class BaseDateTime
extends AbstractDateTime
implements ReadableDateTime, Serializable {
/** The millis from 1970-01-01T00:00:00Z */
private volatile long iMillis;
/** The chronology to use */
private volatile Chronology iChronology;
/////////////////////////////////////////////////////////////////
/*
* DateTime is thread-safe and immutable, provided that the Chronology is as well.
* All standard Chronology classes supplied are thread-safe and immutable.
*
* @see MutableDateTime
*/
public final class DateTime
extends BaseDateTime
Любителям joda-time.
Cмущает меня этот volatile, который приходит в немутабельный класс от родителя.
3.14159265,
14 Октября 2013
-
+150
- 1
- 2
- 3
- 4
public static function getDeferredSubsCardExpirationDate($date) {
$ts = strtotime($date);
return mktime(date('H', $ts), date('i', $ts), date('s', $ts), date('m', $ts), date('d', $ts), date('Y', $ts) + Constants::GIFT_CARD_EXPIRATION_PERIOD);
}
ОУКЕЙ
Sc0rp10,
14 Октября 2013
-
+123
- 1
list($ignore, $ignore, $ignore, $ignore,$ignore, $ignore, $radius, $ignore) = get_location_data($request['location']);
someone,
14 Октября 2013
-
+114
- 1
- 2
- 3
- 4
- 5
- 6
// Validate that numrical values exist for either Children or Adults and that either/or have a value of 1 or more
if (is_numric($_SESSION['f_adults']) and $_SESSION['f_adults'] >0 or is_numric($_SESSION['f_children']) and $_SESSION['f_children'] >0) {
$_SESSION['valid_amount'] = true;
} else {
$_SESSION['valid_amount'] = false;
}
Случайно нашёл. Без комментариев.
пруфлинк: http://www.dreamincode.net/forums/topic/172078-is-numeric-problem/
Dg_INC,
13 Октября 2013
-
+74
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
public class Encoder {
public static void encode(final OutputStream out, Node node) throws IOException {
node.accept(new NodeVisitor() {
@Override
public void string(StringNode node) {
byte[] value = node.toByteArray();
out.write(Integer.toString(value.length).getBytes(Constants.CHARSET));
out.write(':');
out.write(value);
}
// ... другие методы для других типов нод ...
}
}
}
Решил поменять в паре-тройке модулей пачки ифов на паттерн visitor... И получил пинка от жабы ;(
write() кидает IOException, а значит и метод string() в анонимном классе тоже должен кидать, и метод string() в интерфейсе NodeVisitor тоже... Но ведь соседним посетителям этот IOException нахер не сдался...
Checked exceptions - зло.
bormand,
12 Октября 2013
-
+152
- 1
$smarty->assign('main_body_style', 'style="' . (((CONF_SHOPPING_CART_VIEW == 2) || ($cart_view == CARTVIEW_FRAME)) ? '' : 'background:#FFFFFF;') . 'min-width:auto;width:auto;_width:auto;"');
Из контроллера.
WebAsyst.
invision70,
12 Октября 2013
-
+129
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
product:
.LFB34:
.cfi_startproc
xor eax, eax
test esi, esi
je .L7
lea eax, [rsi-1]
mov edi, edi
add rax, 1
imul rax, rdi
.L7:
rep
ret
.cfi_endproc
Оптимизациия умножения через рекурсию. Сишный код:
inline unsigned long int product_0(const unsigned int a, const unsigned int b, const unsigned long int tmp)
{
if (b == 0) return tmp;
return product_0(a, b-1, tmp+a);
}
unsigned long int product(const unsigned int a, const unsigned int b)
{
return product_0(a, b, 0);
}
Распознать умножение (imul) в этой рекурсивной хрени компилятор смог, но при этом как-то через жопу, нагенерировав при этом много лишнего говна.
gcc version 4.5.1
j123123,
12 Октября 2013
-
+141
- 1
- 2
- 3
- 4
Мартышка и слон решили укоротить удава. Слон говорит "А давайте ему ебало отрежем"
-Мартышка: нет, без ебала он не выживет, нужно хвост отрезать, но докуда?
Слон: до ебала
АХАХАХАХАХАХАХА
Не говнокод, просто забавно
PragramistOtBoga,
12 Октября 2013
-
−148
Не говнокод, просто забавно
__proto__,
12 Октября 2013