Skip to content

Instantly share code, notes, and snippets.

View tshm's full-sized avatar

tosh shimayama (satake) tshm

View GitHub Profile
#!/bin/sh
# acpi notifier
LANG=C
FG="white"
BG="#555"
W=500
X=$(xwininfo -root | awk "/Width:/{print \$2-$W}")
Y=20
GEOM="-fg $FG -bg $BG -y $Y -x $X -w $W"
@tshm
tshm / dicom_grouper_renamer
Created December 10, 2010 13:23
dicom sample
#!env ruby
require 'fileutils'
require 'rubygems'
require 'dicom'
require 'ap'
SUID_TAG = "0020,000E"
LATE_TAG = "0020,0062"
VIEW_TAG = "0018,5101"
ACQN_TAG = "0020,0012"
@tshm
tshm / loadScript.js
Created April 28, 2011 12:41
dynamic javascript loading
function loadScript(url, callback) {
var tag = document.createElement('script');
tag.type = 'text/javascript';
tag.src = url;
//tag.onreadystatechange = callback;
tag.onload = callback;
document.getElementsByTagName("head")[0].appendChild(tag);
};
function createXMLHttpRequest() {
@tshm
tshm / lshistory_cview.sh
Created February 29, 2012 14:24
get 'view specific' history of a given file in clearcase
#!/bin/sh
[ $# -ne 2 ] && echo 'please specify date and filename' && exit 1
date=$1; shift; file=$1
ct='cleartool'
# get the current visible branch
branch=$(${ct} find ${file} -cview -print | sed -e 's/.*\\\(.*\)\\\(.*\)/\1/g')
# get the history of the file within the branch
${ct} find ${file} -version "{brtype(${branch}) && created_since(${date})}" -print
@tshm
tshm / agility-localStorage.js
Created March 20, 2012 12:45
agilityjs - localStorage adapter
/*
[MIT licensed](http://en.wikipedia.org/wiki/MIT_License)
*/
// custom agilityjs adapter for localstorage
(function($$, console) {
'use strict';
$$.adapter.localStorage = function(_params) {
var storageKey = (this._data.persist.baseUrl || '') + this._data.persist.collection,
storageStr = localStorage[storageKey],
@tshm
tshm / console_log.js
Created May 24, 2013 05:10
console.log() for jscript.
var console = {
log: function( v ) {
var str = (function stringify( obj, unquote ) {
if ( obj === null ) return 'null';
if ( obj === undefined ) return 'undefined';
if ( obj instanceof Array ) {
var str = [];
for ( var i = 0; i < obj.length; ++i ) {
str.push( stringify( obj[i] ));
}
@tshm
tshm / log_adapter.cpp
Last active July 7, 2016 03:21
logging adapter / stream I/F for VS2012 UT FW.
// adapter for the test framework Logger.
class DebugLogger {
std::stringstream str;
public:
DebugLogger(): str("") {}
~DebugLogger() { Logger::WriteMessage( str.str().c_str() ); }
template<typename T> DebugLogger& operator<<( const T& val ) {
str << val;
return *this;
int graycode(int in) {
int out = in & 0xFFFF;
for (int i=0; i<16; i++) {
// if certain bit is 1 then rest of bits get flipped else no change.
if (out & (0x8000 >> i)) {
out ^= (0xFFFF >> (i+1));
}
}
return out;
}
taskkill /f /im explorer.exe
start "" "explorer.exe"
pause
#include<math.h>
#include<stdio.h>
#include<stdlib.h>
#define SWAP(a,b) tempr=(a); (a)=(b); (b)=tempr
const long N = 1 << 13;
void four(float*, unsigned long, int);
int main(int argc, char* argv[]) {
char* buf = new char[256];