Skip to content

Instantly share code, notes, and snippets.

View tgck's full-sized avatar

tgck tgck

View GitHub Profile
@tgck
tgck / windowInitialization.py
Created August 20, 2012 16:22
simple window initialization in PyObjC (python)
# simple window initialization in PyObjC
import objc
from AppKit import *
from Foundation import *
from PyObjCTools import AppHelper
app = NSApplication.sharedApplication()
size = NSMakeRect(0.0, 0.0, 400.0, 400.0) # left-end-pos, bottom-end-pos, width, height
window = NSWindow.alloc().initWithContentRect_styleMask_backing_defer_(size,NSTitledWindowMask | NSClosableWindowMask |NSResizableWindowMask | NSMiniaturizableWindowMask, NSBackingStoreBuffered,False)
@tgck
tgck / simpleSpeakSynthesizer.py
Created August 20, 2012 16:23
simpleSpeakSynthesizer2
from AppKit import NSSpeechSynthesizer
voices = NSSpeechSynthesizer.availableVoices()
voices = [x.split(".")[-1] for x in voices]
voice = "com.apple.speech.synthesis.voice." + voices[-1]
speech = NSSpeechSynthesizer.alloc().initWithVoice_(voice)
speech.startSpeakingString_("Hello World!")
@tgck
tgck / simpleSpeakSynthesizer2.py
Created August 20, 2012 16:24
simpleSpeakSynthesizer2
# every time another person speaks!
from AppKit import NSSpeechSynthesizer
import random
voices = NSSpeechSynthesizer.availableVoices()
voices = [x.split(".")[-1] for x in voices]
def speak(txt):
voice = "com.apple.speech.synthesis.voice." + voices[random.randint(0,len(voices))]
@tgck
tgck / bash_profile
Created November 8, 2012 16:52
bash_profile with backup alias
#!/bin/bash
export PS1="\W:\!\$ "
# bkコマンド
bk() {
if [ -d $1 ]; then
tar cvf $(date +"%Y%m%d_%H%M%S")_${1#\/}_bkup.tar $1;
fi
}
@tgck
tgck / loadSoundFiles2Buffer.rtf
Last active December 10, 2015 01:58
loadSoundFiles2Buffer in SuperCollider(3.5)
//
// loadSoundFiles2Buffer.rtf
// ディレクトリ指定で取得したファイルをバッファにロードするサンプル
// 2012.12.23 tgck
//
s = Server.default; s.boot;
f = "find ~/Desktop/ -name '*aiff' | head".unixCmdGetStdOut;
f = f.split($\n);
@tgck
tgck / dumpOsc.cpp
Last active December 14, 2015 22:49
openFrameworksでOSCメッセージ受信
// OSCメッセージをコンソールに出力する関数
// from -- http://yoppa.org/ma2_10/2279.html
string testApp::dumpOSC(ofxOscMessage m) {
string str = m.getAddress();
for (int i=0; i<m.getNumArgs(); i++ ) {
str += " ";
switch (m.getArgType(i)) {
case OFXOSC_TYPE_INT32:
str += ofToString( m.getArgAsInt32(i));
break;
@tgck
tgck / grep in st
Created March 16, 2013 13:28
やりたいメソッドがどのクラスに含まれてるか調べるコード片@smalltalk
"名前に'something'を含むメソッドを取得する"
Object withAllSubclasses do:
[:clas | clas selectors do:
[:sel |
(sel asLowercase
includesSubString: 'something' )
ifTrue: [
Transcript
show: clas name;
show: ' ';
@tgck
tgck / captureEveryFile.scpt
Last active December 15, 2015 04:59
ファイルのキャプチャをバッチ処理的に作成するスクリプト AppleScript/MacOS X: 10.6.8/AppleScript Editor: 2.3
set whichUrl to 1
-- 画面サイズを取得
tell application "System Events"
set {rightLimit, bottomLimit} to size of scroll area 1 in process "Finder"
end tell
-- 対象ファイルの数を取得
-- TODO: Finder選択項目でフォルダ内容を取得 もしくはドロップしたファイルを対象とする
tell application "TextEdit"
@tgck
tgck / changeDesktopPicture.scpt
Last active December 15, 2015 07:09
壁紙を変更する(複数ファイルをリストで) AppleScript/MacOS X: 10.6.8/AppleScript Editor: 2.3
-- リストで与えられたファイルパスのファイルにより、順次壁紙を変更していく
--
set Basedir to "/Users/saji/Desktop/" as text
set theList to {"070613_r2d2_4.jpg", "1258216685I1Qshr.jpg", "5471d2e497139bf3398334027a8af8e2.jpg", "72467494.gif", "Unknown.jpeg", "dokusyosi.jpg", "images-1.jpeg", "images.jpeg", "walkman.jpg"}
repeat with curItem in theList
set curPath to Basedir & curItem
-- display dialog curPath
changeDesktopPicture(curPath)
delay 0.1
@tgck
tgck / countTrashes.scpt
Created March 22, 2013 17:23
ごみ箱の中のファイル数をかぞえる. @AppleScript/MacOS X: 10.6.8/AppleScript Editor: 2.3
-- ゴミ箱のファイル数を取得する
set trashCount to do shell script "ls -1 ~/.Trash/ | wc -l | tr -d ' '"
--> "412" (文字列)
set trashCount to trashCount as integer
--> 412 (数値)