Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View vlasovskikh's full-sized avatar

Andrey Vlasovskikh vlasovskikh

View GitHub Profile
@vlasovskikh
vlasovskikh / tweetread.py
Created June 1, 2014 23:26
Actor-based CLI Twitter client example for using asyncio
# Copyright (c) 2014 Andrey Vlasovskikh
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@vlasovskikh
vlasovskikh / pday.erl
Created September 13, 2013 13:20
Programmers day in Erlang
-module(pday).
-export([main/1, pday/1, ordinal_to_date/2, date_to_string/1]).
ordinal_to_date(Year, N) ->
{Month, Day} = submod(N, months(Year)),
{Year, Month + 1, Day}.
date_to_string({Year, Month, Day}) ->
// Is it possible to shorten collection->array conversion in Kotlin?
fun f(): Array<String> {
val xs = setOf("foo", "bar")
return xs.toArray(Array(xs.size, { "" }))
}
@vlasovskikh
vlasovskikh / ideavim-test-example.feature
Created January 30, 2013 09:29
IdeaVim test example
Given the following buffer in the <Normal mode>:
"""
123<caret>456
123789
"""
When I type:
"""
cw, abc, <Esc>, hhj, .
"""
Then the buffer should contain:
@vlasovskikh
vlasovskikh / ObjectAlgebra.kt
Created August 10, 2012 00:56
Object algebra approach to the Expression problem in Kotlin
/**
* Object algebra approach to the Expression problem in Kotlin.
*
* See also <http://lambda-the-ultimate.org/node/4572>.
*/
// Cannot put this fun inside main() in Kotlin M2
fun exp2plus3<A>(f: IntAlg<A>): A = f.add(f.lit(2), f.lit(3))
fun main(args : Array<String>) {
@vlasovskikh
vlasovskikh / local.coffee
Created July 23, 2011 12:02
Local vars in CoffeeScript are nonlocal sometimes
f = ->
x = 2
x = 1
> console.debug "x = #{ x }"
x = 1
> console.debug "f() = #{ f() }"
f() = 2
@vlasovskikh
vlasovskikh / iks.coffee
Created June 23, 2011 10:51
Combinatory logic in CoffeeScript, JavaScript, and Python
I = (x) -> x
S = (f) -> (g) -> (x) -> (f x) (g x)
K = (x) -> (y) -> x
@vlasovskikh
vlasovskikh / pacnew
Created June 7, 2011 21:29
See graphical diff between your old and .pacnew configs, delete .pacnew if needed
#!/usr/bin/env python
# Author: Andrey Vlasovskikh
# License: MIT
import sys
import os
import subprocess
def main():
@vlasovskikh
vlasovskikh / README.md
Created February 4, 2011 14:02
Funny GCC Warning for FP Programmers

Funny GCC Warning for FP Programmers

(via [zakharov][1])

Consider the following program:

$ cat > tmp.c << EOF
> struct S {

> int x;

@vlasovskikh
vlasovskikh / vp-googlevideo
Created September 1, 2010 21:28
Tool for watching Google Video hosted videos with mplayer
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2010 Andrey Vlasovskikh
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to