Skip to content

Instantly share code, notes, and snippets.

@kyab
kyab / XCodeユーザスクリプト:現在開いているファイルのフォルダでターミナルを開始
Created January 9, 2011 17:26
(XCode4非対応)XCodeで現在開いているソースファイルのフォルダからターミナルを開始します。「ユーザスクリプトの編集」でディレクトリを「選択部分」にしておいてください。
#!/usr/bin/ruby
#カレントディレクトリを取得
dir = `pwd` #エディタにフォーカスがないと、上手くそのファイルのディレクトリに移動できない・・。
puts dir
#ターミナル.appにさせる処理(AppleScript)を文字列に詰める
terminal = "\\\"Terminal\\\"" #\"Terminal\"
cmd1 = "\\\"cd /\\\""
cmd2 = "\\\"echo foo\\\""
@kyab
kyab / manweb.command
Created May 20, 2011 11:02
goto apple's man page. example "$ ./manweb.command 1 ls"
#!/bin/bash
echo jumping to apple man page...
echo level is $1
echo target manual is $2
open http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man$1/$2.$1.html
@kyab
kyab / manmate
Created May 20, 2011 11:03
open man pages with TextMate
#!/bin/sh
#echo $1 $2 $3 $4 $5
man $1 $2 $3 $4 $5 | col -b | mate
@kyab
kyab / setPrompt.sh
Created May 20, 2011 14:00
set prompt for #, not $ when sudo bash
#anyhow,we should use \\$, not \$..
#https://discussions.apple.com/thread/1265800?threadID=1265800
#I think alsp \\\$ should work.
export PS1="\[\033[36m\][\u@\h:\w]\\$ \[\033[0m\]"
@kyab
kyab / cot
Created May 21, 2011 15:30
cot : let's pipe to CotEditor, like mate for TextMate.
#!/bin/bash
#pipe to cotEditor
#example:
# ls -alF | cot.sh
# man mount | col -b | cot.sh
file=`mktemp -t cot`
rm -f $file
@kyab
kyab / main.m
Created July 4, 2011 17:36 — forked from Watson1978/main.m
$ gcc main.m -framework Foundation -framework MacRuby -fobjc-gc
$ ./a.out
Fixnum
42
diff --git a/Rakefile b/Rakefile
index 1e41707..f94998c 100644
--- a/Rakefile
+++ b/Rakefile
@@ -77,6 +77,8 @@ specification_version: 2
summary: N-dimensional Numerical Array class for Ruby
test_files: []
+licenses: []
+
@kyab
kyab / gist:1072070
Created July 8, 2011 15:22 — forked from Watson1978/gist:1062455
MacRuby : Build UniversalBinary

Build LLVM 2.9

$ svn co https://llvm.org/svn/llvm-project/llvm/branches/release_29@127367 llvm-2.9
$ cd llvm-2.9
$ env UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" CC=/usr/bin/gcc CXX=/usr/bin/g++ ./configure --enable-bindings=none --enable-optimized --with-llvmgccdir=/tmp
$ env UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" CC=/usr/bin/gcc CXX=/usr/bin/g++ make 
$ sudo env UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" CC=/usr/bin/gcc CXX=/usr/bin/g++ make install

Build MacRuby

diff --git a/Rakefile b/Rakefile
index 1e41707..f94998c 100644
--- a/Rakefile
+++ b/Rakefile
@@ -77,6 +77,8 @@ specification_version: 2
summary: N-dimensional Numerical Array class for Ruby
test_files: []
+licenses: []
+
@kyab
kyab / objc-macruby.m
Created December 18, 2011 01:04 — forked from Watson1978/objc-macruby.m
Objective-C + MacRuby
#import <Foundation/Foundation.h>
#import <MacRuby/MacRuby.h>
int main(void)
{
id fooClass;
id foo;
[[MacRuby sharedRuntime] evaluateFileAtPath:@"test.rb"];
fooClass = [[MacRuby sharedRuntime] evaluateString:@"Foo"];