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
- (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 { |
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
# 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, |
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
IoGraphViz | |
gv := IoGraphViz clone with("G") | |
hello := gv addNode("hello", nil) | |
world := gv addNode("world", nil) | |
gv addEdge(hello, world) | |
options := Map clone do( |
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
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 ) |
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
// 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 |
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
require "shortcut" | |
require 'hotcocoa' | |
class Application | |
include HotCocoa | |
def start | |
application :name => "Shortcut" do |app| | |
app.delegate = self |
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
<img src="http://dotgraph.net/embed/[mysite]/image/?src=http://mysite.com/my_graph.dot"> |
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
require 'java' | |
require 'rubygems' | |
rb_root = File.dirname(__FILE__) | |
app_root = File.dirname(__FILE__)+'/..' | |
Dir[app_root+"/*.jar"].each { |jar| require jar } | |
require 'rack' | |
Dir[app_root+"/Java/jetty/*.jar"].each { |jar| require jar } |
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
require 'rubygems' | |
require 'eventmachine' | |
class Timer | |
def initialize | |
@run = false | |
@timeout_proc = nil | |
end | |
# Run <tt>blk</tt> every <tt>every</tt> seconds during <tt>during</tt> seconds |
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
# (The MIT License) | |
# | |
# Copyright (c) 2009 Grégoire Lejeune | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining | |
# a copy of this software and associated documentation files (the | |
# 'Software'), to deal in the Software without restriction, including | |
# without limitation the rights to use, copy, modify, merge, publish, | |
# distribute, sublicense, and/or sell copies of the Software, and to | |
# permit persons to whom the Software is furnished to do so, subject to |