Skip to content

Instantly share code, notes, and snippets.

View flaviut's full-sized avatar

Flaviu Tamas flaviut

View GitHub Profile
proc box*[T](val: T): ref T =
new result
result[] = val
@flaviut
flaviut / -
Created October 3, 2014 21:24
#!/bin/fish
echo '' > ./.borderlands_winid
while true;
wmctrl -l | grep 'Borderlands' | cut -f 1 -d ' ' > /tmp/bl_new_winid_pt1
sort -u /tmp/bl_new_winid_pt1 .borderlands_winid > /tmp/borderlands_winid_new
mv /tmp/borderlands_winid_new ./.borderlands_winid
for id in (cat ./.borderlands_winid);
xdotool windowmap $id;
@flaviut
flaviut / -
Created September 24, 2014 21:49
1
1
1
2
3
4
1
2
1
2
@flaviut
flaviut / a.pdf
Last active August 29, 2015 14:05
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import parseutils, pegs, myutils, strutils, re
type
Url* = object
scheme*, hostname*: String
port*: Option[Int]
username*, password*: Option[String]
path*: String
parameters*, fragments*: Option[String]
import unsigned
type
FArray* {.unchecked.} [T] = array[0..1, T]
PArray*[T] = ref FArray[T]
proc box*[T](val: T): ref T =
new result
result[] = val
type FArray* {.unchecked.} [T] = array[0..0, T]
converter array2FArray[I, T](arr: array[I, T]): FArray[T] =
var arr = arr
return cast[FArray[T]](addr arr)
let x: FArray[int] = [1,2,3,4,5]
echo(x[5])
proc isSeq[T](v: seq[T]): bool =
return true
proc isSeq[T](v: T): bool =
return false
let foo = @[1, 2]
let fo1 = "ad"
echo fo1.isSeq
echo foo.isSeq
proc array[I, OT, NT](arr: array[I, OT]): array[I, NT] =
for i, v in arr:
result[i] = NT(i)
let a = array[0..1, int, float]([1, 2])
echo(repr(a))