Skip to content

Instantly share code, notes, and snippets.

View nowlinuxing's full-sized avatar

Loose coupling nowlinuxing

View GitHub Profile
@nowlinuxing
nowlinuxing / gist:2636145
Created May 8, 2012 15:14
Converting RCS to Git
# http://xrtc.net/f/projects/rcs-to-git.shtml
$ mkdir repos.cvs repos.source
$ cvs -d /path/to/repos.cvs/ init
$ (cd repos && find . -type d -exec mkdir /path/to/repos.cvs/{} \;)
$ (cd repos.source && CVSROOT=/path/to/repos.cvs/ cvs import -m "Initial CVS import" repos.source TICALC start)
$ (cd repos && find . -type f -exec cp {} /path/to/repos.cvs/{} \;)
$ CVSROOT=/path/to/repos.cvs git cvsimport -C . repos.source
@nowlinuxing
nowlinuxing / gist:4230314
Created December 7, 2012 02:43
build deb package from tarball
> tar xfz source-0.0.1.tar.gz
> cd source-0.0.1
> dh_make
> sudo dpkg-buildpackage -rfakeroot
> dpkg-buildpackage
> sudo dpkg -i ../source-0.0.1-1_amd64.deb
@nowlinuxing
nowlinuxing / gist:4397640
Last active December 10, 2015 06:58
https://gist.github.com/4397599 は誤って作成してしまったもの
#!/usr/bin/env ruby
require 'rubygems'
require 'mechanize'
require 'uri'
class HttpClient
def initialize(base_url)
class FoosController < ApplicationController
skip_before_filter :verify_authenticity_token
end
$ curl -i -X PUT -H "Content-Type: application/json; charset=utf-8" -d '{"title": "hoge"}' http://localhost:3000/foos/123.json
@nowlinuxing
nowlinuxing / trans_railslog.rb
Created July 24, 2013 08:21
A skelton script to transform Rails log
#!/usr/bin/env ruby
buf = {}
ARGF.readlines.each do |l|
case l.chomp
when /^Started ([^\s]+) "([^\s]+)" .* at ([-0-9]+) ([:0-9]+).*/
_, method, path, date, time = Regexp.last_match.to_a
buf.merge!(:method => method, :path => path, :date => date, :time => time)
when /^Completed/
puts "%s %s %s" % [buf[:time], buf[:method], buf[:path]]
@nowlinuxing
nowlinuxing / gist:6171837
Created August 7, 2013 07:05
get/post to controller#action on rails c
ApplicationController.allow_forgery_protection = false
app.instance_eval do
post('/login', user: {login: 'bob', password: 'pass'})
get("/my")
puts response.body
end
@nowlinuxing
nowlinuxing / gist:6362609
Created August 28, 2013 06:09
slow response ranking of production log of Rails
awk '/^Started /{t=$8} /^Completed /{print t,$5,$7,$10}' log/production.log | sort -k 2,2nr | head -20
@nowlinuxing
nowlinuxing / gist:6435240
Created September 4, 2013 10:23
execute Controller#action via rails runner with user authentication (devise)
rails runner "ApplicationController.allow_forgery_protection = false; s = ActionDispatch::Integration::Session.new(Rails.application); s.post('/login', user: {login: 'admin', password: 'password'}); s.get('/my'); puts s.response.body"
@nowlinuxing
nowlinuxing / gist:6547747
Last active December 22, 2015 23:38
AR condition using arel table

Arel Table

OR condition query

admins = User.where(:kind => :admin).where_values.reduce(:and)
authors = User.where(:kind => :author).where_values.reduce(:and)
@nowlinuxing
nowlinuxing / gist:7116228
Created October 23, 2013 10:30
Work with github issue and pull request