Skip to content

Instantly share code, notes, and snippets.

#!/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:
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,
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);
$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] } ] } ] }
class Listing
markdown :title, :description
end
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")
#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) { \
#!/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]}"
#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){
@hugopeixoto
hugopeixoto / upstart example
Created September 24, 2014 14:54
upstart example
# daemon-name - registration service
#
description "registration service"
start on (local-filesystems and runlevel [2345])
stop on runlevel [06]
setuid v11registration-runner
setgid v11registration-runner