Skip to content

Instantly share code, notes, and snippets.

@NIA
NIA / JournalTest.java
Created March 13, 2011 15:23
Мне самому не нравятся такие тесты, но...?
@Test
public void testAccountsInitialization() {
AccountTree.Account expenses;
assertNotNull( expenses = findAccount("expenses", journal.getRootAccounts()) );
assertNotNull( findAccount("food", expenses.getChildren()) );
}
@Test
public void testTransactionsInitialization() throws Exception {
List<Transaction> ts = journal.getTransactions();
(* Ваня: я решил набросать свой вариант программы и на нём показать, как всё
делается. Можешь сохранить его на будущее как далеко не идеальный, но неплохой
пример для подражания.*)
(* Ваня: первый совет: в коде очень полезны комментарии. Если ты делаешь
что-то неочевидное в какой-то строчке, поясни это в комментарии рядышком. Я
покажу тебе примеры полезных комментариев ниже. Чтобы ты не путал мои советы с
комментариями к коду, советы я пишу в круглых скобках и начинаю со своего
имени, а комментарии - в фигурных скобках. Так что если захочешь использовать
этот код, советы удаляй, они только для тебя, а комментарии оставь: они
% вставка картинки: \figure{file}{описание}
\newcommand{\includefigure}[2]{
\begin{figure}[!htb]
\center{\includegraphics{#1}}
\caption{#2} \label{fig:#1}
\end{figure}
}
let $PATH .= ';E:\Program Files\Git\bin\'
runtime vimrc
@NIA
NIA / run.sh
Created February 27, 2011 05:34 — forked from cypok/run.sh
#!/bin/sh
git submodule add git://github.com/tpope/vim-rails.git bundle/rails
git submodule add git://github.com/msanders/snipmate.vim.git bundle/snipmate
git submodule add git://github.com/vim-scripts/bufexplorer.zip bundle/bufexplorer
git submodule add git://github.com/scrooloose/nerdcommenter.git bundle/nerdcommenter
git submodule add git://github.com/scrooloose/nerdtree.git bundle/nerdtree
git submodule add git://github.com/tpope/vim-surround.git bundle/surround
git submodule add git://github.com/tpope/vim-cucumber.git bundle/cucumber
git submodule add git://github.com/tpope/vim-haml.git bundle/haml
3 + 2 + 1 + 2 + 3 +
1 + 3 + 4 + 2 + 1 +
2 + 4 + 1 + 4 + 2 +
1 + 2 + 4 + 3 + 1 +
3 + 2 + 1 + 2 + 3
@NIA
NIA / gist:801844
Created January 29, 2011 13:49
parse JSON double to Double (null allowed), catching optional NumberFormatException
public static Double parseDouble(String string) throws ParseException {
if("null".equals(string)) {
return null;
}
try {
return Double.parseDouble(string);
} catch (NumberFormatException e) {
throw new ParseException("Unparseable double: " + string, 0);
}
@NIA
NIA / gist:801810
Created January 29, 2011 13:05
parsing JSON data to Calendar
private static final String dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"; // 2011-01-29T00:02:08+06:00
public static Calendar parseDate(String strDate) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat, Locale.US);
Calendar cal = Calendar.getInstance();
cal.setTime(sdf.parse(strDate));
return cal;
}
@NIA
NIA / morality-2010-11-12.txt
Created November 11, 2010 16:37
Слова из трёх текстов про мораль (Slotin, Text A, Text B)
incident/accident/case случай
distinguished выдающийся, знаменитый
faith вера
conduct поведение
ascent восхождение, подъём
bright яркий, блестящий, умный
daring дерзкий
be concerned with/deal with заниматься, интересоваться
sustain поддерживать (горение, реакцию)
explosive взрывчатка
@NIA
NIA / translate.html
Created October 31, 2010 18:39
Подфигачил пример по Google Translate API для перевода на русский
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>
</head>
<body>
<form name="f" id="f" action="#" onsubmit="translate(); return false;"><textarea name="text" rows="4" cols="60">Enter text here</textarea><br /><br /><input type="submit" value="Перевести на русский" onfocus="this.blur();" /><br /><br /><textarea name="translation" rows="4" cols="60" onfocus="this.select();" readonly="true"></textarea></form><br /><script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript">google.load("language", "1"); function translate() {var originaltext=document.forms["f"].text.value; google.language.translate(originaltext, "", "ru", function(result) { document.forms["f"].translation.value = (result.error)?("Error: "+result.error.message):result.translation; }); } </script>
</body>
</html>