- 1
strcat(strcpy(malloc(strlen(argv[0]) + sizeof(".track")), argv[0]), ".track")
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+141
strcat(strcpy(malloc(strlen(argv[0]) + sizeof(".track")), argv[0]), ".track")
+72
public class Командир {
private String имя;
private ПоходНаГерманию поход;
public Командир(String имя) {
this.имя = имя;
поход = new ПоходНаГерманию();
}
public Богатство пойтиВпоход()
throws НеПолучилосьException {
return поход.сходить();
}
}
больше русской жабы тут http://www.spring-source.ru/docs_simple.php?type=manual&theme=docs_s imple&docs_simple=chap01_p03
+95
static void Main(string[] args)
{
Func<int, int> m = delegate(int a)
{
Func<int, int> c = x => x / 2;
return a * c(a);
};
Console.WriteLine(m(10));
Console.ReadKey();
}
Нестандартный подход
+94
combinations.AddRange(combinations4);
combinations.AddRange(from combination5 in combinations5
where
(from combination4 in combinations4
where
(from c4class in combination4.Classes
where !combination5.Classes.Contains(c4class)
select c4class).Count() == 0
select combination4).Count() == 0
select combination5);
Теперь у меня есть ачивка "сделать через LINQ не смотря ни на что".
Тому, кто поймёт, что же здесь происходит - достанется воображаемый пряник.
+156
function(dateToAdjust) {
dateToAdjust = new Date(dateToAdjust);
var offsetMs = dateToAdjust.getTimezoneOffset() * 60000;
return new Date(dateToAdjust.getTime() - offsetMs);
}
даты в js, люблю их даже больше чем в php
+137
// For a portable version of timegm(), set the TZ environment variable to
// UTC, call mktime(3) and restore the value of TZ. Something like
#include <time.h>
#include <stdlib.h>
time_t
my_timegm(struct tm *tm)
{
time_t ret;
char *tz;
tz = getenv("TZ");
if (tz)
tz = strdup(tz);
setenv("TZ", "", 1);
tzset();
ret = mktime(tm);
if (tz) {
setenv("TZ", tz, 1);
free(tz);
} else
unsetenv("TZ");
tzset();
return ret;
}
Цитата из man timegm. Сборка unix timestamp из компонент (год, месяц и т.п.).
Удобно, наглядно, потокобезопасно.
+50
if ( !log.append(log_line) )
log.append("Can't append to log");
+54
// We now have a locale string, but the global locale can be changed by
// another thread. If we allow this thread's locale to be updated before we're done
// with this string, it might be freed from under us.
// Call versions of the wide-to-MB-char conversions that do not update the current thread's
// locale.
//...
/*
* Note that we are using a risky trick here. We are adding this
* locale to an existing threadlocinfo struct, and thus starting
* the locale's refcount with the same value as the whole struct.
* That means all code which modifies both threadlocinfo::refcount
* and threadlocinfo::lc_category[]::refcount in structs that are
* potentially shared across threads must make those modifications
* under _SETLOCALE_LOCK. Otherwise, there's a race condition
* for some other thread modifying threadlocinfo::refcount after
* we load it but before we store it to refcount.
*/
MS VS 2013 CRT
+157
function calcHTime($stt) {
$secs = time() - $stt;
$h = (int) ($secs / 3600);
$m = (int) (($secs - ($h * 3600)) / 60);
$s = (int) ($secs - ($h * 3600) - ($m * 60));
return sprintf("%02d:%02d:%02d", $h, $m, $s);
}
+159
function time(){
var vr=new Date();
var hour=vr.getHours();
var min=vr.getMinutes();
var sec=vr.getSeconds();
if (sec<=9) {
if (min<=9) {
if (hour<=9) {
document.forms[0].elements[0].value = "0" + hour +":"+ "0" + min +":"+ "0" + sec;
}
else {
document.forms[0].elements[0].value = hour +":"+ "0" + min +":"+ "0" + sec;
}
}
else {
if (hour<=9) {
document.forms[0].elements[0].value = "0" + hour +":"+ min +":"+ "0" + sec;
}
else {
document.forms[0].elements[0].value = hour +":"+ min +":"+ "0" + sec;
}
}
}
else {
if (min<=9) {
if (hour<=9) {
document.forms[0].elements[0].value = "0" + hour +":"+ "0" + min +":"+ sec;
}
else {
document.forms[0].elements[0].value = hour +":"+ "0" + min +":"+ sec;
}
}
else {
if (hour<=9) {
document.forms[0].elements[0].value = "0" + hour +":"+ min +":"+ sec;
}
else {
document.forms[0].elements[0].value = hour +":"+ min +":"+ sec;
}
}
}
setTimeout("time()",1000);
}
Вот такой вот toString().