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
<?php | |
// ref: http://www.php.net/manual/ja/function.file-exists.php#79118 | |
function getResource(){ | |
$args_last_key = func_num_args() - 1; | |
$resource_urls = array_slice(func_get_args(), 0, $args_last_key); | |
// The last argument is a local file path. | |
$local_fallback = func_get_arg($args_last_key); | |
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
// ref: http://ituneslp.net/tutorials/itunescontrol | |
array.sortOn = function() { | |
for(var i=0 ; i < arguments.length; i++){ | |
var field = arguments[i]; | |
this.sort(function(a, b){ | |
if(a[field] > b[field]){ | |
return 1; | |
} | |
if(a[field] < b[field]){ |
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
iTunes.goToChapter = function(cNum){ | |
//Note : iTunes.currentChapter starts at 1, NOT 0. | |
//If currently playing track has no chapter | |
if(this.currentChapter == 0 || ! cNum){ | |
return; | |
} | |
var isPlaying = false; | |
if(this.waveform.waveformData){ |
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
// Return single USB port's name | |
String unixUsbSerial(String device){ | |
return unixUsbSerials(device, 1)[0]; | |
} | |
// Return multiple USB ports' names | |
String[] unixUsbSerials(String device, int... num){ | |
/* Parameter "device" can be "cu" or "tty". | |
* num[0] can be a number of ports required. | |
*/ |
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
/* | |
* Delete all empty log files, | |
* which are created when the "flush()" method isn't used correctly. | |
*/ | |
import java.io.File; | |
File[] files = new File(sketchPath("log")).listFiles(); | |
int deleted = 0; | |
for(File elm : files){ |
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
<?php | |
function cssSprite($singleWidth, $singleHeight, $verticalNum, $horizontalNum, $elementNum){ | |
echo " style='background:"; | |
echo -floor($elementNum * ceil(1 / $verticalNum)) * $singleWidth, "px "; | |
echo -$elementNum % $horizontalNum * $singleHeight, "px "; | |
echo "url(******.jpg) no-repeat;'"; | |
} | |
?> |
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
<?php | |
$agent = getenv('HTTP_USER_AGENT'); | |
function getVersion($req){ | |
global $agent; | |
preg_match( | |
"/(?<=".$req."[^0-9\.])([0-9]+)([0-9\._]+?)(?=[^0-9\._]|$)/i", | |
$agent, | |
$matchedStringsArr |
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
// background.jpg | |
// | |
// +------+------+ | |
// |#aaa |#aaa | | |
// | |:hover| | |
// +------+------+ | |
// |#bbb |#bbb | | |
// | |:hover| | |
// +------+------+ | |
// |#ccc |#ccc | |
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
var mainPlaylist = iTunes.createTempPlaylist(); | |
(function(){ | |
//location.host returns "persistentid-***" | |
var hostPersistentID = location.host.split("-")[1]; | |
var tmpArr = iTunes.findTracksByTextFields({ | |
album : iTunes.findTrackByPersistentID( hostPersistentID ).album | |
}); | |
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
/* | |
ArduinoなどのUSBデバイスを繋いでいる状態でこれを実行すると、 | |
デバイス名がクリップボードにコピーされる | |
そのまま Quartz Composer の、Kineme Serial Inputの Device 欄にペーストすると | |
Quartz Composerでのシリアル通信が始まる | |
*/ | |
import java.awt.datatransfer.Clipboard; |
OlderNewer