Skip to content

Instantly share code, notes, and snippets.

@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>
@NIA
NIA / diagram.png
Last active October 20, 2021 09:55
A simple class diagram using LaTeX+TikZ+tikz-uml.sty
diagram.png
@NIA
NIA / PreprocessorTest.cs
Created February 8, 2018 14:20
Test case for Consulo C# preprocessor
namespace config {
class Quix{}
#define FOO_BAR
#if FOO_BAR
// active block
class FooBar{
}
@NIA
NIA / read-format-write.cpp
Last active February 2, 2016 10:14
qt data piping example
#include <QObject>
class Receiver : public QObject {
Q_OBJECT
// ...
signals:
void bytesReceived(QByteArray b);
// ...
}
@NIA
NIA / select2dropdown.js
Created December 10, 2012 17:23
Convert .select elements to Bootstrap Dropdown Group
/*!
* Convert .select elements to Bootstrap Dropdown Group
* Assumes jQuery and Bootstrap scripts already linked
*
* Expected markup:
*
* <div id="someId" data-name="someName" class="select someClass">
* <div class="option selected" data-value="1"> Item 1 <i class="icon-ok"></i></div>
* <div class="option" data-value="2"> Item 2 <span>some html</span></div>
* <div class="option" data-value="3"> Item 3 <img src="little.img"></div>
@NIA
NIA / signs.txt
Created January 11, 2016 06:54
Frequently used typography symbols (not accessible from Windows keyboard)
Useful symbols:
~~~~~~~~~~~~~~
–—‒ - dash (en/em/figure)
“”«» - quotes (english/russian)
©®™ - copyright
←↑→↓ - arrows
↖↗↘↙ - arrows giagonal
⇐⇑⇒⇓⇔⇕ - arrows double
×⋅ - multiplication
… - ellipsis
@NIA
NIA / truecolor.rb
Last active December 25, 2015 09:19
Simple colorizer of tests output: given test program printing true or false for test passing, it paints "true" green and "false" red
#!/usr/bin/env ruby
# Usage example: echo 'use "hw1test.sml";' | sml | truecolor.rb
require 'colorize'
# HA HA HA I USE GLOBAL VARIABLES
$failed = 0
$passed = 0
while line = gets
@NIA
NIA / Main.scala
Last active December 25, 2015 01:39
Getting time diffs using https://github.com/scalaj/scalaj-time (JodaTime wrapper for scala)
// locate this in src/main/scala/ to compile with sbt
import org.joda.time.Period
import org.joda.time.format.PeriodFormat
import org.scala_tools.time.Imports._
object Main extends App {
def periodDiff(t1: Period)(t2: Period) = PeriodFormat.getDefault print (t1 - t2).normalizedStandard
println( periodDiff(2.hours + 14.minutes + 39.seconds)(1.hour + 32.minutes + 43.seconds) )
@NIA
NIA / gist:5662466
Last active December 17, 2015 19:39
Наброски по Чёрным дырам
\url{http://www.krugosvet.ru/enc/nauka_i_tehnika/astronomiya/CHERNAYA_DIRA.html}
ЧЕРНАЯ ДЫРА – область пространства, в которой гравитационное притяжение настолько сильно, что ни вещество,
ни излучение не могут эту область покинуть. Для находящихся там тел вторая космическая скорость (скорость убегания)
должна была бы превышать скорость света, что невозможно, поскольку ни вещество, ни излучение не могут двигаться быстрее
света. Поэтому из черной дыры ничто не может вылететь. Границу области, за которую не выходит свет, называют
«горизонтом событий», или просто «горизонтом» черной дыры.
\section{История}
Основные этапы \url{https://ru.wikipedia.org/wiki/Чёрная_дыра}
@NIA
NIA / koans_solved_output.txt
Last active December 15, 2015 11:17
Scala Koans (Dec 2015)
[info] Koans: (http://scalakoans.webfactional.com)
[info] AboutAsserts:
[info] - asserts can take a boolean argument
[info] - asserts can include a message
[info] - true and false values can be compared with should matchers
[info] - booleans in asserts can test equality
[info] - sometimes we expect you to fill in the values
[info] AboutValAndVar:
[info] - Vars are variables, and may be reassigned
[info] - vals are values, and may not be reassigned, analogous to final in Java