Skip to content

Instantly share code, notes, and snippets.

@NIA
NIA / newyear2013.rb
Last active December 10, 2015 10:08
A funny function that congratulates everybody with 'happy new 1357002013'th UNIX timestamp'... well, in Russian.
# encoding: utf-8
#
# Prerequisites:
# sudo gem install colorize
#
# Example usage:
# $ irb -r './newyear2013.rb'
# irb(main):001:0> congratulate! :everybody
#
require 'colorize'
@NIA
NIA / ConsoleLoop.scala
Created December 25, 2012 15:22
Creating help text from map of commands
val commands = ListMap(
"updates" -> "show the last updates",
"help" -> "that is, print this text",
"exit" -> "nuff said, quit the program",
"upupup" -> "Tumc tumc tumc"
)
val helpTabStop = 8
val helpText = "Commands list:\n" + commands.collect({
case (cmd, desc) => cmd + " "*(helpTabStop - cmd.length) + "- " + desc
}).mkString("\n")
@NIA
NIA / gist:4358648
Last active December 10, 2015 01:34
Demonstrates how implicit parameters can be scoped in Scala
class Jedi(val name: String, val force: Double) {
override def toString = name + " with force " + force
}
def findMostPowerfulOf(jedies: Set[Jedi]) = {
implicit val jediOrdering = Ordering by { x:Jedi => x.force }
jedies.max
}
def findLastNameOf(jedies: Set[Jedi]) = {
implicit val jediOrdering = Ordering by { x:Jedi => x.name }
jedies.max
@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 / gist:4244563
Created December 9, 2012 12:00
map syntax compared between Scala and C#
// "Scala": XElement.Load(xmlFileName).Descendants("element") map { _.Attribute(xmlAttribute).Value }
// Query syntax
items = from element in XElement.Load(xmlFileName).Descendants("element") select element.Attribute(xmlAttribute).Value;
// Extension method syntax
items = XElement.Load(xmlFileName).Descendants("element").Select( element => element.Attribute(xmlAttribute).Value);
@NIA
NIA / 2007-Sep7-final-song-freestyle.md
Created May 30, 2012 06:46
Финалка команды Sep7 в 2007 году

Светлой памяти Алексея Чернова, нашего Капитана

// Песня на мотив Blur “Song 2”


Пусть крыша едет не спеша,

Ведь все бывает в ФэМэШа

ты слышишь арию пельменя
он в закипающей воде
поёт что раньше был холодным
и чёрствым но пришла любовь
--------------------------------------------
-- dedicated to M. J. --
-- --
-- Multiplier: two 4-bit int -> 8-bit int --
-- (c) Ivan Novikov aka The Mooonlighter --
-- Novosibirsk State University, 2011 --
--------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
@NIA
NIA / education-2011-09-21.txt
Created September 20, 2011 15:13
Words for English quiz (2011-09-21, from text "An education for life?")
cope in an adult life вживаться во взрослую жизнь
add up суммировать (деньги)
fill in заполнять анкеты
look up numbers in telephone directories сверять телефонные номера
pay a living wage платить прожиточный минимум
peer into the future всматриваться в будущее
obsolete устаревший
basic skills основные умения
work for a living зарабатывать на жизнь
earn daily bread зарабатывать на хлеб насущный
AssemblyCellRendererFactoryRegistry *factories = browser->getCellRendererRegistry();
AssemblyCellRendererFactory *f = factories->getFactoryById(AssemblyCellRendererFactory::ALL_NUCLEOTIDES);
SAFE_POINT(f != NULL, "AssemblyCellRendererFactory::ALL_NUCLEOTIDES not found!",);
cellRenderer.reset(f->create());