Skip to content

Instantly share code, notes, and snippets.

@manveru
manveru / beat.nim
Created January 9, 2011 15:45
Get current Beat with Nimrod
import times, os
"TZ".putEnv("CET")
var time = getTime().getLocalTime
echo((time.hour.float * (1000.0 / 24.0)) +
(time.minute.float * (1000.0 / 1440.0)) +
(time.second.float * (1000.0 / 86400.0)))
require 'ramaze'
class Main < Ramaze::Controller
layout :html5
def index
%q(
<form method="post" action="#{r :result}">
<input type="text" name="foo">
<input type="submit">
@manveru
manveru / reia-git-pkgbuild.sh
Created December 15, 2010 18:03
Updated PKGBUILD for reia-git
# Contributor: Friedrich Weber <[email protected]>
# Contributor: Michael Fellinger <[email protected]>
pkgname=reia-git
pkgver=20101216
pkgrel=2
pkgdesc="A Ruby/Python-like scripting language for the Erlang virtual machine (BEAM)"
arch=('any')
url="http://reia-lang.org/"
license=('MIT')
depends=('erlang')
@manveru
manveru / treetop_example.rb
Created November 24, 2010 12:44
Minimal treetop example
require 'treetop'
grammar = Treetop.load_from_string(DATA.read)
parser = MyGrammarParser.new
p parser.parse(" a = 1 \n b = 2 \n").value
__END__
grammar MyGrammar
rule main
pair* {
# Encoding: BINARY
require "digest/md5"
abort "usage #$0 path1 [path2] [path3] ..." if ARGV.empty?
hashes = Hash.new{|h,k| h[k] = [] }
roots = ARGV.map{|arg| File.expand_path(arg) }.uniq
roots.each do |root|
glob = File.join(root, '/**/*')
require 'ostruct'
require 'benchmark'
N = 200_000
string = "Hello, Kitty"
o = OpenStruct.new(hello: string)
S = Struct.new(:hello)
s = S.new(string)
@manveru
manveru / x
Created October 27, 2010 04:41
#!/bin/bash
#----------------------------------------------------
# Version: 0.2.4.0
# Author: Florian "Bluewind" Pritz <[email protected]>
#
# Licensed under WTFPL v2
# (see COPYING for full license text)
#---------------------------------------------------
# Extract an archive based on the mime type
#----------------------------------------------------
open Printf
open String
let bottles n = match n with
| 0 -> "no more bottles of beer"
| 1 -> "1 bottle of beer"
| n -> sprintf "%d bottles of beer" n
;;
let rec song n = match n with
# Contributor: unexist <[email protected]>
# Contributor: Xilon <[email protected]>
pkgname="subtle-hg"
pkgver=2222
pkgrel=1
pkgdesc="A grid-based manual tiling window manager with a strong focus on easy but customizable look and feel"
arch=("i686" "x86_64")
url="http://subtle.subforge.org"
license=("GPL")
depends=("libx11" "ruby" "ruby-curb" "ruby-minitar")
# Battery sublet file
# Created with sur-0.1
configure :battery do |s|
s.interval = 60
s.full = 0
# Path
s.now = []
s.status = []