Skip to content

Instantly share code, notes, and snippets.

View madx's full-sized avatar

François Vaux madx

View GitHub Profile
bit $ ./bit ls
./bit: no issues yet.
bit $ ./bit open
>> This is my first issue
[some editing in your favorite editor]
./bit: created issue 1.
bit $ ./bit open
[some editing again]
>> Another one
./bit: created issue 2.
@madx
madx / to_filter.rb
Created November 4, 2009 09:40
Transform a text query to a Sequel filter
def to_filter(query)
query.split(/ +/).map { |chunk|
case chunk
when /^by:(.+)/
{:author => $~[1]}
when /^is:(.+)/
{:status => $~[1]}
else
:title.like("%#{chunk}%")
end
require 'fileutils'
# ShitStorm libs
require File.join(File.dirname(__FILE__), '..', 'lib', 'shitstorm')
include ShitStorm
# Swap to test DB
db_file = File.join(File.dirname(__FILE__), 'test.db')[2..-1]
migrations_dir = File.join(File.dirname(__FILE__), '..', 'migrations')
class SplitLog < Sequel::Migration
def up
alter_table :comments do
add_foreign_key :entry_id, :entries
end
alter_table :entries do
drop_column :url
add_column :author, String
end
@madx
madx / honk.rb
Created December 17, 2009 16:26
require 'time'
require 'pathname'
module Honk
extend self
attr_reader :posts, :tags
@posts = []
@tags = {}
@madx
madx / git-dot
Created February 4, 2010 18:16
Generate graphs from a git repository
#!/usr/bin/env ruby
class Grapher
class << self
Props = {
:branch => '[shape=box,style=filled,fillcolor="#ccffcc",color="#003300"]',
:commit => '[style=filled,fillcolor="#ffffcc",color="#663333"]',
:ref => '',
:relation => '[dir=back,color="#545443"]',
~ $ df -h
Sys. de fich. Tail. Occ. Disp. %Occ. Monté sur
/dev/sda1 6,5G 6,0G 183M 98% /
[...]
# Looks like I'm running short of space :D
# Step 1:
~ $ sudo gem1.8 cleanup
[... lots of text ...]
create or replace function acte_possible
(code in varchar2, day in date, creneau_min in number)
return number
is
nb_actes number;
cursor services_ouverts is
select s.NumService
from Service s
left join EstOuvert eo on s.NumService = eo.NumService
left join EstCompetent ec on s.NumService = ec.NumService
void sgf_putc(OFILE* file, char c) {
assert (file->mode == WRITE_MODE);
if ((file->ptr != 0) && ((file->ptr % BLOCK_SIZE) == 0)) {
sgf_append_block (file);
}
file->buffer[ (file->ptr % BLOCK_SIZE) ] = c;
file->ptr++;
}
080495b0 <sgf_remove>:
80495b0: 55 push %ebp
80495b1: 89 e5 mov %esp,%ebp
80495b3: 81 ec 98 00 00 00 sub $0x98,%esp
80495b9: 8d 85 78 ff ff ff lea -0x88(%ebp),%eax
80495bf: 89 44 24 04 mov %eax,0x4(%esp)
80495c3: 8b 45 08 mov 0x8(%ebp),%eax
80495c6: 89 04 24 mov %eax,(%esp)
80495c9: e8 6e f4 ff ff call 8048a3c <read_block>
80495ce: c7 44 24 04 ff ff ff movl $0xffffffff,0x4(%esp)