Skip to content

Instantly share code, notes, and snippets.

View supermomonga's full-sized avatar
🏠
Working from home

supermomonga supermomonga

🏠
Working from home
View GitHub Profile
@supermomonga
supermomonga / gyazo.rb
Created June 6, 2013 01:57
gyazo uploader class
require 'net/http'
class Gyazo
attr_reader :id
def initialize(id = '',
boundary = '----BOUNDARYBOUNDARY----',
host = 'gyazo.com',
class Psgr
def Psgr.query room, text
{events: [{message: {room: room,text: text,}}]}.to_json.to_s
end
def Psgr.post query
url = URI.parse 'http://postgres-lingrbot.herokuapp.com/'
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url.path)
request.body = query
request['Content-Type'] = 'application/xml'
def godef(inputs, returns, &func)
Proc.new do | *args |
obj = Object.new
inputs.map.with_index{|v, i| obj.instance_variable_set(v, args[i])}
returns.map{|v| obj.instance_variable_set(v, nil) }
obj.instance_eval(&func)
returns.map{|v| obj.instance_variable_get(v) }
end
end
@supermomonga
supermomonga / gist:5792478
Created June 16, 2013 16:04
【質問】こんな条件の技術者を採用したいとなったら、どれくらいのオファーを出せばいいでしょう?

以下の条件は必須です

  • プログラミング技術
    • Ruby1.9以上でのプログラミング経験
    • Rails3.1以上でのウェブアプリケーション開発経験
  • TDD/CI
    • RSpecなどを用いたRailsアプリケーションのテスト経験
    • Jenkinsなどを用いたRailsアプリケーションのCI経験
  • herokuなどのPaaSを用いたアプリケーションのデプロイや運用経験
  • RDBMS
require 'RMagick'
w = 64
h = 32
canvas = Magick::Image.new(w, h) {
self.format = 'png'
}
Magick::Draw.new.tap do |dr|
prng = Random.new
@supermomonga
supermomonga / .vimrc
Created June 20, 2013 04:27
updatetime issue
augroup MyAutoCmd
autocmd!
augroup END
" NeoBundle initalize
set nocompatible
if has('vim_starting')
set runtimepath+=~/.vim/debug/bundle/neobundle.vim/
endif
elsif %r#^http://stat\.ameba\.jp/user_images/.+\.(jpe?g|gif|png)$# =~ m
require 'open-uri'
file = Time.now.to_i
open("./ameba_#{file}.#{$1}", 'wb') do |file|
open(m, 'Referer' => 'http://ameblo.jp/') do |data|
file.write(data.read)
end
end
url = `./gyazo ameba_#{file}.#{$1}`.gsub("\n","")
File.delete("ameba_#{file}.#{$1}")
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# coding: utf-8
include Java
class DataSet
def random scale
if !@random_array
@random_array = scale.times.map do
rand 1..scale