Skip to content

Instantly share code, notes, and snippets.

View omo's full-sized avatar

Hajime Morrita omo

  • Mountain View, CA
View GitHub Profile
@omo
omo / gist:11598
Created September 19, 2008 14:57
class Mysql
def async_query(sql)
send_query(sql)
select [ (@sockets ||= {})[socket] ||= IO.new(socket) ], nil, nil, nil
get_result
end
end
@omo
omo / gist:11600
Created September 19, 2008 14:58
/* send_query */
static VALUE send_query(VALUE obj, VALUE sql)
{
MYSQL* m = GetHandler(obj);
Check_Type(sql, T_STRING);
if (GetMysqlStruct(obj)->connection == Qfalse) {
rb_raise(eMysql, "query: not connected");
}
if (mysql_send_query(m, RSTRING_PTR(sql), RSTRING_LEN(sql)) != 0)
mysql_raise(m);
@omo
omo / gist:11604
Created September 19, 2008 15:08
/* sql/client.c */
int STDCALL
mysql_real_query(MYSQL *mysql, const char *query, ulong length)
{
...
if (mysql_send_query(mysql,query,length))
DBUG_RETURN(1);
DBUG_RETURN((int) (*mysql->methods->read_query_result)(mysql));
}
@omo
omo / gist:11606
Created September 19, 2008 15:10
/* socket */
static VALUE socket(VALUE obj)
{
MYSQL* m = GetHandler(obj);
return INT2NUM(vio_fd(m->net.vio));
}
append 48360
add 11626
put 10803
decode 10319
write 7416
get 6568
access 6497
create 6418
read 6093
value 4416
;; modified http://www.emacswiki.org/emacs/TinyUrl
(require 'thingatpt)
(defun my-get-shorter-bug-url(longer-uri)
(cond ((string-match "bugs.webkit.org" longer-uri)
(let ((num-start (string-match "[[:digit:]]" longer-uri)))
(concat "http://webkit.org/b/" (substring longer-uri num-start))))
((string-match "http://code.google.com/p/chromium/issues" longer-uri)
(let ((num-start (string-match "[[:digit:]]" longer-uri)))
(concat "http://crbug.com/" (substring longer-uri num-start))))
((error (concat longer-uri " is not bug url")))))
@omo
omo / async testsucks.js
Created September 20, 2010 15:32
async test sucks.
var testDbCardStoragePutSouldCount = function() {
doTestDbCardStorage(
"test1",
function(done, target) {
target.count(
function(cnt) {
assertEquals(0, cnt);
target.put(
tfil.test.HELLO_CARD_RECORD,
function() {
@omo
omo / gist:629832
Created October 16, 2010 14:26
information hiding violation
...
target.startRoundFor(new tfil.Round([card1]));
target.startReview();
assertTrue(target.reviewBox_.isVisible());
// here!
tfil.ui.takeAction(target.reviewBox_.scoreBox_.proceedButton_);
...
@omo
omo / gist:1343964
Created November 7, 2011 01:30
.emacs diff
(setq vc-handled-backends nil)
@omo
omo / gist:1347579
Created November 8, 2011 11:53
open today's journal. used from emacs.
#!/usr/bin/env ruby
require "date"
Dir::chdir(File::join(ENV["HOME"], "work/octopress"))
if (ARGV[0] == "pub")
system("bash -l -c 'rvm use 1.9.2 && rake generate deploy'")
exit
end