Skip to content

Instantly share code, notes, and snippets.

@kitak
kitak / config.ru
Created February 8, 2012 08:05
Sinatraのconfig.ru
# thin start -R config.ru
require 'sinatra'
require './myapp.rb'
run Sinatra::Application
@kitak
kitak / viewport-for-app
Created February 12, 2012 05:22
アプリのためのViewport設定
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
@kitak
kitak / hide-url-bar
Created February 12, 2012 05:30
URLバーの自動消去
<body onload="window.scrollTo(0,1);">
# jQuery
$(document).ready(function () {
setTimeout(function () {
window.scrollTo(0,1);
}, 100);
// 500を使うケースも
})
@kitak
kitak / load_jquery
Created February 14, 2012 07:35
jQueryの読み込み
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
@kitak
kitak / gist_memo
Created March 7, 2012 07:34
gistのメモ
# オプション
-s 説明
-e バッファからの更新
@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();
@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 / gist:3165903
Created July 23, 2012 20:05
dailycoding_2012-7-23
# coding: utf-8
puts (1..999).select {|num| num % 3 == 0 || num % 5 == 0}.size
@kitak
kitak / gist:3169306
Created July 24, 2012 10:30
problem2
# coding- utf-8
sum = 2
t = 1
t2 = 2
while (t + t2) < 4000000
tmp = t2
t2 = t + t2
@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) {