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/python | |
def roots(n): | |
for a in range(0, n): | |
if (a*a) % n == 1: | |
yield a | |
def prime(n): | |
for a in range(2, n): | |
if n % a == 0: |
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
extern crate rustc_serialize; | |
extern crate byteorder; | |
use std::io; | |
use std::io::Read; | |
use rustc_serialize::hex::ToHex; | |
use byteorder::{BigEndian, ReadBytesExt}; | |
struct IndexHeader { | |
version : u32, |
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
size_t | |
readlines(FILE* in, char ***items) { | |
char buf[BUFSIZ], *p; | |
size_t i, size = 0; | |
/* read each line from stdin and add it to the item list */ | |
for(i = 0; fgets(buf, sizeof buf, in); i++) { | |
if(i+1 >= size / sizeof **items) | |
if(!(*items = realloc(*items, (size += BUFSIZ)))) | |
die("cannot realloc %u bytes:", size); |
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
$cond = -> (b,y,n) { b ? y : n } | |
$any = -> (e) { -> (p) { e.any? &p } } | |
$all = -> (e) { -> (p) { e.all? &p } } | |
$make_value = ->(mho) { ->(obj) { ->(k,v) { $cond[k == :or, mho[v], ->(obj) { obj[k] == v }][obj] } } } | |
$applier = ->(reducer) { ->(mho) { ->(query) { ->(obj) { reducer[query][$make_value[mho][obj]] } } } } | |
$ycombinator = ->(f) { ->(x) { x[x] }[ ->(x) { f[->(y) { x[x][y] } ] } ] } |
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
class Listing | |
markdown :title, :description | |
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
namespace :po do | |
desc "TODO" | |
task :create, [:name, :path] => :environment do |t, args| | |
r = Repository.create!(name: args[:name], path: File.expand_path(args[:path])) | |
tr_st = ActiveRecord::Base.connection.raw_connection.prepare( | |
"INSERT INTO translations (translation_file_id, msgid, msgstr, created_at, updated_at) VALUES(?, ?, ?, ?, ?);") | |
# 2012-03-19 08:00:16.463415 | |
now = Time.now.strftime("%Y-%m-%d %H:%M:%S.%6N") |
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
#include <stdio.h> | |
#include <gettext-po.h> | |
#include <string.h> | |
#include <sqlite3.h> | |
#include <time.h> | |
#define ERROR_CHECK_KEEP(code, message) \ | |
{ \ | |
int v = (code); \ | |
if (v != 0) { \ |
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
#!/bin/bash | |
curl --silent http://www.debian.org/international/l10n/po-debconf/pt | | |
grep 'href="http://i18n.debian.org/material/po/.*.po.gz">pt.po</a>' | | |
sed -e 's/.*name="\([^"]*\)".*href="\([^"]*\)".*/\1 \2/' | | |
while read line | |
do | |
a=( $line ) | |
name="${a[0]}" | |
url="${a[1]}" |
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
#include <stdio.h> | |
struct fish_key_store { | |
void* data; | |
int (*getter) (void*, const char*, char*, size_t); | |
int (*setter) (void*, const char*, const char*); | |
}; | |
struct fish_key_store fish_key_store_make (void* data, void* getter, void* setter) { | |
return (struct fish_key_store){ |
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
# daemon-name - registration service | |
# | |
description "registration service" | |
start on (local-filesystems and runlevel [2345]) | |
stop on runlevel [06] | |
setuid v11registration-runner | |
setgid v11registration-runner |