Skip to content

Instantly share code, notes, and snippets.

View dtinth's full-sized avatar
🎶
𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪

Thai Pangsakulyanont dtinth

🎶
𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪𒐪
  • @bemusic                 @creatorsgarten                 @eventpop                 @showdownspace                 @spacetme                @wonderfulsoftware                
  • Krungthepmahanakhonamonrattanakosinmahintharayutthayamahadilokphopnoppharatratchathaniburiromudomratchaniwetmahasathanamonphimanawatansathitsakkathattiyawitsanukamprasit (Bangkok), Thailand
  • YouTube @dtinth
View GitHub Profile
@dtinth
dtinth / decodeUTF.js
Created August 14, 2011 15:01
Decode UTF-8 characters in URLs. Pass the second argument as true to make it output as &#charcode; instead of the character.
function decodeUTF(x, z) {
return x.replace(/%([cd][0-9a-f]%[89ab][0-9a-f]|e[0-9a-f](?:%[89ab][0-9a-f]){2}|f[0-7](?:%[89ab][0-9a-f]){3}|f[89ab](?:%[89ab][0-9a-f]){4}|f[cd](?:%[89ab][0-9a-f]){5})/ig, function(a) {
return z ? '&#' + decodeURIComponent(a).charCodeAt(0) + ';' : decodeURIComponent(a);
});
}
@dtinth
dtinth / get-itunes.c
Created August 15, 2011 16:05
Get currently playing track.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main() {
execl("/usr/bin/osascript", "osascript",
"-e", "tell the application \"iTunes\" to get (the name of current track) & \" ----- \" & (the artist of current track) as string", NULL);
return 0;
}
@dtinth
dtinth / topcm.c
Created August 28, 2011 18:17
Convert to PCM using libsndfile.
#include <stdio.h>
#include <sndfile.h>
#include <string.h>
// gcc topcm.c -lsndfile -o topcm
int main(int argc, char **argv) {
if (argc < 3) {
printf("Usage: %s in-filename out-filename\n", argv[0]); return 0;
@dtinth
dtinth / gist:1298205
Created October 19, 2011 12:55
Async Stuff
var asyncLoop = function(init, cond, next, body, fin) {
init();
if (cond()) body(function cont() {
next(); if (cond()) body(cont); else if (fin) fin();
});
};
var asyncSeq = function() {
var i, args = arguments;
@dtinth
dtinth / gen-regex.js
Created November 9, 2011 09:19
Regex เมพ
require('https').get({
host: 'raw.github.com',
path: '/twitter/twitter-text-js/master/twitter-text.js'
}, function(res) {
var buf = '';
res.setEncoding('utf-8');
res.on('data', function(d) { buf += d });
res.on('end', function() { gen(buf); });
});
@dtinth
dtinth / Convert.php
Created November 22, 2011 16:18
Fun with Beeping
<?php
$events = array();
$e = array();
foreach (file($argv[1]) as $v) {
$l = explode(', ', trim($v));
$time = (intval($l[1]) / 96) * 60 / 160;
$ms = floor($time * 1000);
if ($l[2] == 'Note_off_c' || ($l[2] == 'Note_on_c' && $l[5] == '0')) {
@dtinth
dtinth / setDockBadge.js
Created April 8, 2012 02:41
sets the dock badge in Fluid, with resistant to back buttons.
var fluidHoster = window;
var fluidIframe = null;
var fluidQueuedText = null;
function setDockBadge(text) {
if ('fluid' in window) {
try {
if (fluidHoster == null) {
fluidQueuedText = text;
} else {
fluidHoster.fluid.dockBadge = text;
var cp = require('child_process');
exports.notify = function(appName, message) {
var g = cp.spawn('growlnotify', [
'-n', appName,
'-s',
'-m', message,
'-p', '2'
]);
g.stdin.end();
@dtinth
dtinth / gist:2585567
Created May 3, 2012 13:22
thaiWitter Custom CSS: ?!?
.notification-area > div[style] > div[style] {
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAATCAYAAACZZ43PAAAAQElEQVQ4jc2UMREAQAyD8FRP76lq8w6SMR3YOEZgnhwCC0k4EFgPSTgQkIck9AMTIAn9ACtPFOqBNx6S0A+kY30pBObP4JSXugAAAABJRU5ErkJggg==) center right !important;
text-shadow: 1px 1px 0 black, 1px 0px 0 black, 1px -1px 0 black,
0px 1px 0 black, 0px -1px 0 black, -1px 1px 0 black,
-1px 0px 0 black, -1px 0px 0 black, 2px 2px 1px black;
color: white !important;
}
each_dir() {
COMMAND="$1"
for I in */*
do
if [ -d "$I" ];
then
"$COMMAND" "$I"
fi
done
}