Skip to content

Instantly share code, notes, and snippets.

View glejeune's full-sized avatar

Gregoire Lejeune glejeune

View GitHub Profile
// shortcut.m
//
// compile:
// gcc shortcut.m -o shortcut.bundle -g -framework Foundation -framework Carbon -dynamiclib -fobjc-gc -arch i386 -arch x86_64
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <Carbon/Carbon.h>
@interface Shortcut : NSObject
require "rubygems"
require "graphviz"
g = GraphViz::new( "G", :type => "graph" )
n1 = g.add_node( "A" )
n2 = g.add_node( "B" )
n3 = g.add_node( "C" )
e1 = g.add_edge( n1, n2 )
e1[:dir] = 'forward'
e2 = g.add_edge( n1, n3 )
IoGraphViz
gv := IoGraphViz clone with("G")
hello := gv addNode("hello", nil)
world := gv addNode("world", nil)
gv addEdge(hello, world)
options := Map clone do(
@glejeune
glejeune / lisp.rb
Created September 2, 2010 09:35 — forked from dahlia/lisp.rb
# 30 minutes Lisp in Ruby
# Hong MinHee <http://dahlia.kr/>
#
# This Lisp implementation does not provide a s-expression reader.
# Instead, it uses Ruby syntax like following code:
#
# [:def, :factorial,
# [:lambda, [:n],
# [:if, [:"=", :n, 1],
# 1,
@glejeune
glejeune / gist:664178
Created November 5, 2010 13:43
Execute with Root privileges
- (void)execute:(NSString *)cmd {
NSString *appScript = [NSString stringWithFormat:@"do shell script \"%@\" with administrator privileges", cmd];
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:appScript];
NSDictionary *errorInfo = nil;
NSAppleEventDescriptor *data = [script executeAndReturnError:&errorInfo];
if( data == nil ) {
// Hum... Something happend, dude!
NSLog(@"ERROR : %@", [errorInfo objectForKey:NSAppleScriptErrorMessage]);
} else {
@glejeune
glejeune / gist:1059397
Created July 1, 2011 21:06
BrainF*ck to Ook!
O="Ook. ";o="Ook? ";k="Ook! ";_={">"=>O+o,"<"=>o+O,"+"=>O+O,"-"=>k+k,"."=>k+O,","=>O+k,"["=>k+o,"]"=>o+k};puts (ARGV[0]||"++++++++++[>++++++++>+++++++++++>+++<<<-]>-.>+.----.>+++.").split(//).map{|c|_[c]}.join
@glejeune
glejeune / jConsole.rb
Created August 8, 2011 19:17
A (very) simple Java console
#!jruby
unless RUBY_PLATFORM === "java"
puts "jConsole only works with jRuby"
puts "For more informations, see http://www.jruby.org/"
exit 1
end
require 'readline'
require 'rubygems'
@glejeune
glejeune / inca.sh
Created October 21, 2011 13:39
Find and convert file encoding
#!/bin/sh
get_encoding() {
FILE=$1
file --mime-encoding $FILE | awk '{print $2}'
}
get_type() {
FILE=$1
file $FILE | awk '{print $2}'
@glejeune
glejeune / ant2gv.rb
Created October 28, 2011 10:46
Generate a graph from an ANT file
#!/usr/bin/env ruby
require 'rubygems'
require 'open-uri'
require 'nokogiri'
require 'graphviz'
require 'getoptlong'
class Ant2Gv
def initialize(build_file, gv_path)
@glejeune
glejeune / README.md
Created November 6, 2011 19:50
A (very) simple chat service using AMQP

Run

  1. Install and run an AMQP server (RabbitMQ is a good choise)

  2. Install amqp and ncurses-ruby gems

    sudo gem install amqp ncurses-ruby

  3. Run the client

ruby ./amqp-chat.rb