Skip to content

Instantly share code, notes, and snippets.

@Altech
Altech / testfile
Created February 20, 2012 08:25
test
contents
@Altech
Altech / test.rb
Created September 23, 2012 14:15
test
class Bar
def foo
nil
end
end
@Altech
Altech / usecase_of_data_table.rb
Created September 23, 2012 18:50
ruby way for cunstructing DataTable for Google Chart.
# thin warper of google_visualr (delegate the process of javascript conversion to it).
# I think :: Google_visualr is quite useful gem because it enable us to draw intractive chart on browser only using ruby. But it takes over the interface of JavaScript, especially setter and getter form. There is better way on ruby and we shold do so.
# basic - column first construction.
data = DataTable.new('label', 'score')
data << ['label1', 245]
data << ['label2', 2194]
# data += [['label1', 245], ['label2', 2194]] # other way.
@Altech
Altech / JonResultStoreServer.rb
Created October 10, 2012 09:33
how to send procedure by messagepack-rpc(pseudocode).
require 'msgpack/rpc'
require 'sourcify'
class JobExecuteClient1
def do_job
job = CloudDatawareHouse::Client.new.query('some_query')
# local variables
type = 'one'
@Altech
Altech / use_closure_on_msgpack_rpc.rb
Created October 10, 2012 14:58
This extension enables to use block on messagepack-prc. Free variable must be an object which acccepts 'Marshal.dump'.
require 'msgpack/rpc'
require 'sourcify'
# client extension
module ClientProcHandler
def call_block(&proc)
self.call(:process_block,proc_dump(proc))
end
private
def proc_dump(proc)
@Altech
Altech / .tmux.conf
Created October 24, 2012 08:13
My tmux configuration.
# Prefix
unbind C-b
set-option -g prefix C-z
bind C-z send-prefix
bind C-d detach
# Option
set-window-option -g utf8 on
@Altech
Altech / fill_matrix.js
Created October 30, 2012 19:47
This script fills the matrix authentication of portal.titech.ac.jp. You can use this as a bookmarklet.
var matrix = {
A: ['I','U','U','A','I','Y','F'],
B: ['Z','N','C','C','U','O','G'],
C: ['V','A','K','I','V','R','B'],
D: ['N','S','R','U','H','A','I'],
E: ['N','M','R','T','E','A','P'],
F: ['E','B','O','P','L','K','P'],
G: ['X','L','O','M','O','I','D'],
H: ['A','E','L','O','H','A','E'],
I: ['Y','I','X','T','J','F','G'],
@Altech
Altech / search_gmail.rb
Created November 5, 2012 07:43
grep like search to gmail.
#!/Users/Altech/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
# -*- coding: utf-8 -*-
require 'gmail'
require 'nokogiri'
require 'colorize'
require 'pry'
gmail = Gmail.connect('takeno.sh',PASSWORD)
@Altech
Altech / close.el
Last active October 13, 2015 04:57
The way to `cache` the application Cocoa Emacs.
(global-set-key (kbd "C-x C-c") 'close-on-mac)
(require 'cl)
(defun close-buffers-without-default ()
(interactive)
(loop for buffer being the buffers
do ((lambda (buffer)
(if (and (not (string= (buffer-name buffer) "*GNU Emacs*"))
(not (string= (buffer-name buffer) "*scratch*"))
(not (string= (buffer-name buffer) "*Messages*")))
@Altech
Altech / query_set.rb
Last active December 11, 2015 22:49
experimental API of many td queries.
# case1-1: one-to-one
QuerySet.add :count_users_inflow_source, ->(from, to) do
%w[customers creators].each do |users|
td.query('db',"SELECT * FROM #{users} WHERE #{specific_time(from,to)}"){|result| # queries are processed concurrently.
mongo.collection('collectionA').insert(cnt: result[0], type: uesrs)
}
end
end # return when all jobs finished.
# case1-2: many-to-one