Skip to content

Instantly share code, notes, and snippets.

/* @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){
{-# LANGUAGE NoMonomorphismRestriction #-}
import Text.ParserCombinators.Parsec
empty = many (oneOf "\t\n\r ")
@dmitry-vsl
dmitry-vsl / gist:53ebed9ded50647cc947
Created January 28, 2015 20:29
Run command in tmux tab from vim
nnoremap <C-c><C-C> :wa\|call system("tmux send-keys -t right ./build C-m")<CR>
/* @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));
};

Use vim and chrome developer tools as REPl environment. Press Ctrl-C Ctrl-C to eval code right in chrome console.

@dmitry-vsl
dmitry-vsl / ref.rb
Last active August 29, 2015 14:10
Script to refactor requirejs(amd) modules to more convenient style
init
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
);
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))
Тестовое задание: Frontend Web Developer
Надо реализовать веб-страницу для просмотра картинок из Flickr Public Feed.
Программный интерфейс Flick Public Feed описан тут:
https://www.flickr.com/services/feeds/docs/photos_public
Страница представляет из себя список фотографий с датой создания, названием и
списком тегов.
@dmitry-vsl
dmitry-vsl / dlang_debounce
Created January 5, 2014 19:43
implementation of this function http://underscorejs.org/#debounce in D programming language (http://dlang.org)
#!/usr/bin/env rdmd
// implementation of this function http://underscorejs.org/#debounce
// in D programming language (http://dlang.org)
import std.stdio;
import std.datetime;
void test(double a){
writeln("Invoked debounced func with ", a);