This file contains 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
/* to compile: | |
valac --pkg gio-2.0 clem_info.vala | |
example of usage: | |
clem_info '${artist} - ${title}; elapsed: ${elapsed}/${time}' | |
*/ | |
[DBus (name = "org.freedesktop.MediaPlayer")] | |
interface Player : Object { | |
public abstract HashTable<string, Variant> GetMetadata() throws IOError; |
This file contains 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
require 'numtheory' # gem install ruby-numtheory | |
def product(arr) | |
def rec_product(n, step, arr) | |
return arr[n] if step > n | |
newstep = step << 1 | |
t = rec_product(n, newstep, arr) * | |
rec_product(n-step, newstep, arr) | |
return t | |
end |
This file contains 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
# -*- coding: utf-8 -*- | |
from urllib2 import urlopen | |
import re | |
import time | |
class DegreeProgramInfo: | |
regexp = re.compile( | |
r"\d</td>\s*<td>\s*(\d+)</td>\s*(?:<td>[^<]*</td>\s*){5}<td>([^<]+)</td>", | |
re.MULTILINE | re.UNICODE) | |
def __init__(self, id, name, url, places): |
This file contains 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
template <typename... T> struct type {}; | |
struct A{}; struct B{}; struct C{}; struct D{}; struct E{}; struct F{}; | |
struct G{}; struct H{}; struct I{}; struct J{}; struct K{}; struct L{}; | |
struct M{}; struct N{}; struct O{}; struct P{}; | |
typedef type<A, B, type<C, D>, type<E, F, type<G, H>, I, J>, | |
type<type<type<K, type<L>>, M>, N>, O, P> init; | |
typedef type<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P> expected; |
This file contains 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
#!/usr/bin/env python | |
import xml.etree.ElementTree | |
# in order for this script to work, manually do the following: | |
# 1) delete extraneous 'uppername="PUID"' at line 205 of cinterface.xml | |
# 2) delete '------------ ... ----' lines (there're 2 of them) | |
def un_camel(text): # slightly modified piece of code from StackOverflow.com | |
result, length = "", len(text) | |
for pos in range(length): |
This file contains 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
// It turns out that combination of std.conv.emplace and FFI::MemoryPointer.new | |
// can make our life much easier (at least, for structs). | |
// See example at https://gist.github.com/2337729 | |
extern (C) void* malloc(size_t sz); | |
extern (C) void free(void *p); | |
class DefaultMemoryManagement { | |
mixin template memoryManagement() {} | |
} |
This file contains 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
test: test_c.o test_d.o | |
cc -shared -m32 test_c.o test_d.o -o test.so -lphobos2 | |
test_c.o: test.c | |
gcc -c -m32 test.c -o test_c.o | |
test_d.o: test.d | |
dmd -c -m32 test.d -oftest_d.o |
This file contains 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
test: test_c.o test_d.o | |
gcc -m32 -g test_d.o test_c.o -o test.so -lphobos2 -lrt -shared -lpthread | |
test_c.o: test.c | |
gcc -c -g -m32 test.c -o test_c.o -fPIC | |
test_d.o: test.d | |
dmd -c -m32 -g test.d -oftest_d.o -fPIC |
This file contains 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
module cinterface; | |
import std.traits; | |
import std.string; | |
import std.conv; | |
import std.range; | |
import std.typetuple; | |
import std.algorithm; | |
import std.ascii; |
This file contains 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
module bgzfrange; | |
import std.stream; | |
struct BgzfBlock { | |
// field types are as in the specification | |
// ushort ~ uint16_t, char ~ uint8_t, uint ~ uint32_t | |
public ushort bsize; | |
public char[] compressed_data = void; | |
public uint crc32; |
OlderNewer