Skip to content

Instantly share code, notes, and snippets.

View blacktaxi's full-sized avatar
🇺🇦
russia is a terrorist state, russians are a terrorist nation

Serhii Yavnyi blacktaxi

🇺🇦
russia is a terrorist state, russians are a terrorist nation
View GitHub Profile
@blacktaxi
blacktaxi / __hooks__.py
Created July 28, 2013 09:32
Super-hack to enable hamlish-jinja templates in Wok.
from hamlish_jinja import HamlishTagExtension
from jinja2.environment import load_extensions
def enable_haml(page):
env = page.__class__.tmpl_env
env.extensions = load_extensions(env, [HamlishTagExtension])
hooks = {
'page.meta.pre': [enable_haml]
}
@blacktaxi
blacktaxi / .gitconfig
Created May 13, 2013 13:01
My .gitconfig.
[color]
ui = true
[format]
pretty = oneline
[core]
autocrlf = true
[alias]
# basic stuff
st = status -s
s = status -s
@blacktaxi
blacktaxi / silly.fs
Last active December 15, 2015 21:29
F# quine
(fun x -> printfn "%s @%A" x <| x.Replace("\"", "\"\"")) @"(fun x -> printfn ""%s @%A"" x <| x.Replace(""\"""", ""\""\""""))"
@blacktaxi
blacktaxi / win8thinborder.reg
Created April 1, 2013 13:11
Thin window borders in win8
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics]
"PaddedBorderWidth"="0"
@blacktaxi
blacktaxi / reboot-wifi.ps1
Created March 26, 2013 11:45
Wi-Fi adapter restart script. Change "6205" to your adapter name.
echo "Restarting Wi-Fi adapter..."
$a = get-wmiobject -class Win32_NetworkAdapter | Where-Object {$_.Name -like "*6205*"}
echo "Disabling..."
$a.Disable()
sleep 1
echo "Enabling..."
@blacktaxi
blacktaxi / gist:aa8a9190d8eff09b1847
Created March 22, 2013 23:03
Scala, pattern matching and Seq <-> List variance.
scala> def withList[T](x: List[T]) = x match { case Seq(1, 2, 3) => 1 }
withList: [T](x: List[T])Int
scala> withList(List(1, 2, 3))
res6: Int = 1
scala> withList(Seq(1, 2, 3))
<console>:9: error: type mismatch;
found : Seq[Int]
required: List[?]
@blacktaxi
blacktaxi / hslint.py
Created February 27, 2013 11:08
Haskell lint script for Emacs.
#!python
'''Haskell lint script for Emacs.
Translated from this: https://gist.github.com/1241073
'''
from __future__ import print_function
import sys
import subprocess
import re
@blacktaxi
blacktaxi / RxMouseTracking.cs
Last active December 12, 2015 10:48
Tracking whether mouse pointer is inside a rectangle with .NET Rx.
private void Form1_Load(object sender, EventArgs e)
{
// get an observable for mouse move event
var mouseMove = Observable.FromEventPattern<MouseEventHandler, MouseEventArgs>(
x => this.MouseMove += x, x => this.MouseMove -= x);
// our rectangle
var rect = new Rectangle(50, 50, 50, 50);
// create event stream transformation
@blacktaxi
blacktaxi / AsyncParallel.fs
Last active December 12, 2015 03:18
Parallel async computation combinator
// This operator is used in the slides for this talk: http://fwaris.wordpress.com/2013/01/31/unraveling-the-mystery-of-monads/
// I haven't seen all the slides yet but I took a shot on implementing it myself.
let (<||>) a b = async {
let! a = Async.StartChild a
let! b = Async.StartChild b
let! ar = a
let! br = b
@blacktaxi
blacktaxi / SomethingViewModel.fs
Last active December 11, 2015 18:28
Base WPF ViewModel in F#
type SomethingViewModel() as this =
inherit ViewModelBase()
let (<<+) (_ : unit) (e : Microsoft.FSharp.Quotations.Expr) =
this.OnPropertyChanged e
let mutable somePropertyValue = ""
member x.SomeProperty
with get() = somePropertyValue
and set value = (somePropertyValue <- value) <<+ <@ x.SomeProperty @>