Use vim and chrome developer tools as REPl environment. Press Ctrl-C Ctrl-C to eval code right in chrome console.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
coffeelint=./node_modules/coffeelint/bin/coffeelint -f coffeelint.json | |
coffee=./node_modules/coffee-script/bin/coffee | |
handlebars=./node_modules/handlebars/bin/handlebars | |
COFFEE=$(shell find app -type f -name '*.coffee') | |
JS=$(patsubst app/%.coffee, public/js/%.js, $(COFFEE)) | |
SCSS=$(shell find stylesheets -type f -name '*.scss') | |
CSS=$(patsubst stylesheets/%.scss, public/css/%.css, $(SCSS)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drop table if exists genre cascade; | |
drop table if exists song cascade; | |
drop table if exists users cascade; | |
drop table if exists listened_song cascade; | |
create table genre( | |
id serial primary key, | |
name text not null | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
init |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @flow */ | |
// http://flowtype.org/ | |
class DumbPromise<T>{ | |
value: T; | |
constructor(value:T){ | |
this.value = value; | |
}; | |
then<Y>(f:(x:T)=>Y): DumbPromise<Y> { | |
return new DumbPromise(f(this.value)); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nnoremap <C-c><C-C> :wa\|call system("tmux send-keys -t right ./build C-m")<CR> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE NoMonomorphismRestriction #-} | |
import Text.ParserCombinators.Parsec | |
empty = many (oneOf "\t\n\r ") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @flow */ | |
type ParseContext = {string: string; position: number;}; | |
type Error = {reason: string; position: number}; | |
type Result<T> = {value: ?T; error: ?Error}; | |
type Parser<T> = (c:ParseContext) => [ParseContext, Result<T>]; | |
function then<T,U>(p: Parser<T>, f: (t: T) => Parser<U>): Parser<U>{ | |
return function(cxt){ | |
var [newCxt, result] = p(cxt); | |
if(result.value != null){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Две параллельные транзакции, одна слева, другая справа. | |
Каждая проверяет количество активных пользователей, | |
убеждается что оно не превышает лимит, и вставляет нового пользователя. В некоторых БД реализация такой функциональности потребовала бы явной блокировки таблицы перед запросом select count(*), но только не в постгресе | |
test=# test=# begin transaction; | |
test=# begin transaction; BEGIN | |
BEGIN test=# select count(*) from u where status='active'; | |
test=# select count(*) from u where status = 'active'; count | |
count ------- | |
------- 6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Создаем pipe номер 1 (можно любой номер указать) с ограничением 10Kb/s | |
sudo ipfw pipe 1 config bw 10Kbytes/s | |
Создаем правило номер 10 (любой номер можно указать), которое вешает пайп номер 1 на исходящий канал от моей к машине к virtual box | |
sudo ipfw 10 add pipe 1 ip from me to 192.168.15.15 out | |
Удаляем правило номер 10 | |
sudo ipfw delete 10 |