-
Лучший говнокод
- В номинации:
-
- За время:
-
-
−109
- 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
- (void)countDown
{
NSDate *currentDate = [NSDate date];
NSTimeInterval timeInterval = ([currentDate timeIntervalSinceDate:startDate]);
NSDate *timerDate = [NSDate dateWithTimeIntervalSince1970:timeInterval];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"ss"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0.0]];
NSString *timeString=[dateFormatter stringFromDate:timerDate];
if ([timeString isEqualToString:@"02"])
{
[logoTimer invalidate];
logoTimer = nil;
// some other code
}
}
- (void)updateCounter
{
startDate = [NSDate dateWithTimeIntervalSinceNow:00];
logoTimer = [NSTimer scheduledTimerWithTimeInterval:0.1
target:self
selector:@selector(countDown)
userInfo:nil
repeats:YES];
}
Вот так незатейливо можно поставить задержку на 2 секунды
tyler,
19 Января 2013
-
+136
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
public override int GetHashCode()
{
if (this.FileName == null)
{
return base.GetHashCode();
}
return this.FileName.GetHashCode() + 13;
}
почему 13?
taburetka,
02 Января 2013
-
+141
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
//void wyslij(int pin, char mode[] = "open") { //было
void wyslij(int pin, int mode) { //стало
if (pin != -1)
{
if (mode == "open")
{
//...
else if ( (mode == "touch") && ( (error != 1) || (olej_error == 1) ) )
Кусок дипломной работы польского студента, код для ардуино. Выцарапано отсюда: http://vimeo.com/47656204, примерно с 1:15.
Xom94ok,
17 Ноября 2012
-
+129
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
-- Подготовка
(.-) :: ot -> (ot -> rt) -> rt
object .- method = method object
to_string () self = show self
my_array = [1..]
-- ООП в действии
main = putStrLn( my_array.-take(10).-drop(5).-to_string() )
Хаскелл и ООП.
Fai,
07 Ноября 2012
-
+124
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
data = load('ex1data1.txt');
X = data(:, 1); y = data(:, 2);
m = length(y); % number of training examples
X = [ones(m, 1), data(:,1)]; % Add a column of ones to x
theta = zeros(2, 1); % initialize fitting parameters
% Some gradient descent settings
iterations = 1500;
alpha = 0.01;
function J = computeCost(X, y, theta)
m = length(y); % number of training examples
hypothesis = theta' * X';
J = 1 / (2 * m) * sum((hypothesis' - y) .^ 2);
endfunction
% compute and display initial cost
computeCost(X, y, theta)
Язык: Матлаб / Октава.
Что происходит: из массива создается матрица путем добавления еще одного такого же массива полностью заполненного единицами, а потом эта матрица умножается на вектор из двух элементов (первая колонка, соответственно, умножается на первый элемент вектора, вторая - на второй). Т.е. это равносильно вызову функции вида y(x) = Kx + b для всех членов исходного массива X. По сути происходит следующее: y(x_0, x_1) = K * x_1 + b * x_0, где x_0 всегда равен единице.
Источник разглашать не буду.
wvxvw,
11 Сентября 2012
-
+128
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
rotate n xs = b ++ a
where n' = n `mod` (length xs)
(a, b) = splitAt ((length xs) - n') xs
rotateAmount xs = _ra 0 ((length xs) - 1) (listArray (0, ((length xs) - 1)) xs)
where _ra s e ys = if (e - s) == 1
then (if ((ys ! s) < (ys ! e)) then s else e) -- base case
else let h = ys ! s -- first item
l = ys ! e -- last item
mi = s + ((e - s) `div` 2) -- middle index
m = ys ! mi -- middle item
in if (h < l)
then s -- return start index
else if (h > m)
then _ra s mi ys
else _ra mi e ys
A “rotated array” is an array of integers in ascending order, after which for every element i, it has been moved to element (i + n) mod sizeOfList. Write a function that takes a rotated array and, in less-than-linear time, returns n (the amount of rotation). http://techguyinmidtown.com/2008/07/05/my-answers-to-the-microsoft-interview-questions
FAKYOUINTIRNEAT,
10 Августа 2012
-
+74
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
reader = new BufferedReader(new FileReader(file));
//null means file end
while ((tempString = reader.readLine()) != null) {
if(tempString !=null && tempString.indexOf('=')>0){
sheet.addCell(new Label(KEY_COLUMN,++ROW, tempString.substring(0,tempString.indexOf('='))));
sheet.addCell(new Label(ENGLISH_COLUMN,ROW, tempString.substring(tempString.indexOf('=')+1)));
}
}
reader.close();
Вот так мы парсим файл *.properties в Java.
roman-kashitsyn,
03 Июля 2012
-
−55
Компилится.
http://ideone.com/yPgoq
HaskellGovno,
13 Июня 2012
-
−30
- 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
BOOL CIniFile::LoadIniFile()
{
CString csBuff;
CFile oIniFile;
if (oIniFile.Open(csIniFileName, CFile::modeRead))
{
ULONGLONG lenReal = oIniFile.GetLength();
DWORD dwLen = (DWORD) lenReal;
if (lenReal > UINT_MAX)
{
dwLen = UINT_MAX;
TRACE("ERROR: CIniFile::LoadIniFile(); CFIle::GetLength() > UINT_MAX\n;");
ASSERT(0);
}
if (!dwLen)
return FALSE;
boost::scoped_array <char> cBuffer(new char[dwLen]);
oIniFile.Read(cBuffer.get(), dwLen);
LoadIniFromBuffer(cBuffer.get(), dwLen);
oIniFile.Close();
if (GetCountRecords())
return TRUE;
}
return FALSE;
}
boost::scoped_array... nuff said =(
kovyl2404,
05 Июня 2012
-
+68
- 1
- 2
- 3
- 4
...... HTML .....
if(isset($_GET["page"])){ $page = $_GET["page"].".php"; echo $_GET['page'];} else { $page = "main.php"; }
if(file_exists("./pages/$page")){ include "./pages/$page"; }else{ include "./pages/404.php"; }
...... HTML .....
Говно сайт http://lovegay.su/
good_web_master,
28 Мая 2012