Skip to content

Instantly share code, notes, and snippets.

let bin = System.IO.File.ReadAllBytes "../../test"
let mutable i = 0
let show len asm =
printf "%08X " i
for j = 0 to len - 1 do
printf "%02X" bin.[i + j]
for j = len to 5 do
printf " "
printfn "%s" asm
i <- i + len
@sousk
sousk / TouchEventDispatcher.js
Created December 26, 2014 05:30
Dispatching touch events between HTML which contains iframe and the document of that iframe
/**
@license WTFPL
@author @sou
This library dispatches touch events from an element to another on the different document through iframe.
NOTE:
This library only suports Mobile Safari as each browsers have different specifications for touch event creation.
You might expand _dispatch method if you want to deal with other browsers.
@sousk
sousk / snippet.rb
Created June 11, 2009 07:00
split large log into files named by the date (like May_11.log)
#!/usr/bin/env ruby
#'$_ = $_.match(/^([A-Z][a-z]+)\s+([0-9]+)/) ? "#{$1}_#{$2}\n" : ""' head.log > date.log
class FileSplitter
attr_accessor :read_from, :logdir
def initialize(args)
@read_from, @logdir = args
@cur_m, @cur_d, @f = nil
@sousk
sousk / snippet.rb
Created June 11, 2009 07:34
snip out large text file with regexp
#!/usr/bin/env ruby
path, from, to = $*
unless path && from && to
puts <<-__DESCRIPTION__
./echo_between.rb file_path "from" "to"
snips large text file
command starts to print lines when matched "from"
@sousk
sousk / snippet.rb
Created June 16, 2009 00:33
weby: make current directory accessible via HTTP
#!/usr/bin/env ruby
require 'webrick'
require 'optparse'
include WEBrick
OPTIONS = {
# :BindingAddress => '0.0.0.0',
:Port => 3000,
require 'rubygems'
class Trac
def initialize(url)
@url = url
end
def newticket
@url + '/newticket'
end
function not_empty(expr, msg) {
ok(function() {
if (! expr) {
return false;
}
// has length
else if (typeof expr['length'] == 'number') {
return expr.length > 0;
}
else {
@sousk
sousk / userjs - showing hantena bookmark comment on the page
Created August 12, 2009 02:23
userjs - showing hantena bookmark comment on the page
// ==UserScript==
// @name ShowHatenaBookmarkComment
// @namespace userjs.phphp.net
// @description build hatena bookmark comments
// @include http://*
// ==/UserScript==
/* Original Script: Hatena Bookmark Comments Viewer
* <http://www.ne.jp/asahi/nanto/moon/>
* <http://worris.sakura.ne.jp/hbcview.html>
@sousk
sousk / gist:167024
Created August 13, 2009 06:43
reload firefox v3.5
ps -xc|grep -sqi firefox && osascript <<'APPLESCRIPT'
tell application "Firefox" to activate
tell application "System Events"
if UI elements enabled then
keystroke "r" using command down
-- Fails if System Preferences > Universal access > "Enable access for assistive devices" is not on
else
-- Fails if Firefox is set to open URLs from external apps in new tabs.
-- tell app "Firefox" to Get URL "JavaScript:window.location.reload();" inside window 1
tell application "Firefox" to get URL "JavaScript:window.location.reload();"
@sousk
sousk / MockObject.class.php
Created November 2, 2009 06:14
a mock object lib for symfony/doctest
<?php
/**
* #test prepare for the test
* <code>
* class User {};
* function setup() {
* MockObject::setFixturePath(sfConfig::get('sf_test_dir') .'/fixtures/test_mock_object.yml', true);
* }
*
* </code>