Skip to content

Instantly share code, notes, and snippets.

How Unicorn Reaps Worker Processes
RubyによるUnixプログラミングを掘り下げるなら、Unicorn web サーバーについても触れておく必要がある。既にこの本でも何度かUnicornについて言及をしてきた。
Unicornの何が凄いのか?Unicornはkernelの機能を限界まで使いこなしている。
コードベースはUnixプログラミングテクニックで一杯だ。
それだけではなく、効率的で信頼性も備えている。GithubやShopifyといったRubyで構築されているWebサイトの多くがUnicornを使っている。
RubyによるUnixプログラミングについてもっと興味がわいならUnicornの詳細を調べてみるといい。

コミットするまでの流れ

前回のコミットから何も変更を加えていない状態。

$ git status
# On branch masternothing to commit, working directory clean

エディタでファイルを編集する

@kitak
kitak / sekigae.js
Last active December 17, 2015 15:29 — forked from hfm/shuffle.pl
var freshers = ["おっくん", "ぐっさん", "たけお", "きたけー"];
freshers.shuffle = function () {
var i = this.length;
var j = 0;
var tmp = "";
while(i) {
j = Math.floor(Math.random()*i);
i--;
tmp = this[i];
require 'mechanize'
class IshikawaAirPollutionAPI
def initialize
@agent = Mechanize.new
@agent.user_agent_alias = 'Mac Safari'
@agent.request_headers = {
'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-language' => 'ja-jp',
var LINE = require('./line.js');
var line = new LINE();
var email = 'your email';
var password = 'your password';
line.login(email, password, function(error, result) {
if (error) {
return;
}
@kitak
kitak / gist:4584035
Created January 21, 2013 06:39 — forked from mislav/gist:938183
connection = Faraday::Connection.new('http://example.com') do |builder|
builder.request :url_encoded # for POST/PUT params
builder.adapter :net_http
end
# same as above, short form:
connection = Faraday.new 'http://example.com'
# GET
connection.get '/posts'
//Customise Backbone.sync to work with Titanium rather than jQuery
var getUrl = function(object) {
if (!(object && object.url)) return null;
return _.isFunction(object.url) ? object.url() : object.url;
};
Backbone.sync = (function() {
var methodMap = {
'create': 'POST',
'read' : 'GET',
@kitak
kitak / method_missing.js
Created August 16, 2012 02:42 — forked from hagino3000/method_missing.js
__noSuchMethod__ for Chrome
/**
* Enable route to __noSuchMethod__ when unknown method calling.
*
* @param {Object} obj Target object.
* @return {Object}
*/
function enableMethodMissing(obj) {
var functionHandler = createBaseHandler({});
functionHandler.get = function(receiver, name) {
@kitak
kitak / testing_front_end_rspec_capybara.md
Created July 10, 2012 11:08 — forked from juliocesar/testing_front_end_rspec_capybara.md
Testing front-end for a Sinatra app with RSpec and Capybara

Testing front-end for a Sinatra app with RSpec and Capybara

I've used Cucumber quite a bit on my last job. It's an excellent tool, and I believe readable tests are the way to the future. But I could never get around to write effective scenarios, or maintain the boatload of text that the suite becomes once you get to a point where you have decent coverage. On top of that, it didn't seem to take much for the suite to become really slow as tests were added.

A while ago I've seen a gist by Lachie Cox where he shows how to use RSpec and Capybara to do front-end tests. That sounded perfect for me. I love RSpec, I can write my own matchers when I need them with little code, and it reads damn nicely.

So for my Rails Rumble 2010 project, as usual, I rolled a Sinatra app and figured I should give the idea a shot. Below are my findings.

Gemfile

@kitak
kitak / app.js
Created July 9, 2012 01:17 — forked from champierre/app.js
Effect like Path - Titanium app.js
//
// Base
//
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();