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
# 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) |
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
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!") |
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
# 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))] |
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
#!/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 | |
} |
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
// | |
// loadSoundFiles2Buffer.rtf | |
// ディレクトリ指定で取得したファイルをバッファにロードするサンプル | |
// 2012.12.23 tgck | |
// | |
s = Server.default; s.boot; | |
f = "find ~/Desktop/ -name '*aiff' | head".unixCmdGetStdOut; | |
f = f.split($\n); |
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
// 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; |
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
"名前に'something'を含むメソッドを取得する" | |
Object withAllSubclasses do: | |
[:clas | clas selectors do: | |
[:sel | | |
(sel asLowercase | |
includesSubString: 'something' ) | |
ifTrue: [ | |
Transcript | |
show: clas name; | |
show: ' '; |
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
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" |
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
-- リストで与えられたファイルパスのファイルにより、順次壁紙を変更していく | |
-- | |
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 |
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
-- ゴミ箱のファイル数を取得する | |
set trashCount to do shell script "ls -1 ~/.Trash/ | wc -l | tr -d ' '" | |
--> "412" (文字列) | |
set trashCount to trashCount as integer | |
--> 412 (数値) |
OlderNewer