#Backbone.jsでUIバインディング
Backbone.js Advent Calendarの14日目です。
Backbone.jsはAngularJSのようなUIバインディングを持たないので自分でバインドしなければなりません。 例えば、テキストボックスの入力内容をモデルに格納して、さらにモデルの内容を別のDOM要素に表示する、 というのはこんな感じかと思います。
#Backbone.jsでUIバインディング
Backbone.js Advent Calendarの14日目です。
Backbone.jsはAngularJSのようなUIバインディングを持たないので自分でバインドしなければなりません。 例えば、テキストボックスの入力内容をモデルに格納して、さらにモデルの内容を別のDOM要素に表示する、 というのはこんな感じかと思います。
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
#!/bin/sh | |
# Licence: MIT | |
# Created by tomykaira, 2011-10-25 | |
if [ $# -ne 1 ]; then | |
echo "Give me your new project name (only)" | |
exit 1 | |
fi |
# usage: | |
# it "should return a result of 5" do | |
# eventually { long_running_thing.result.should eq(5) } | |
# end | |
module AsyncHelper | |
def eventually(:options = {}) | |
timeout = options[:timeout] || 2 | |
interval = options[:interval] || 0.1 | |
time_limit = Time.now + timeout | |
loop do |
There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.
From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?
=begin | |
Need to install gems heroku, newrelic_rpm | |
$ gem install heroku newrelic_rpm | |
Set your apps setting | |
app_name : heroku's app_name of auto scaling | |
license_key : NewRelic api key. You can get heroku's NewRelic admin console. "App setting" and "Agent configuration" | |
execute with cron every minutes | |
$ ruby ./adjust_dynos_with_newrelic.rb |
require 'rest_client' | |
require 'nokogiri' | |
resource = RestClient::Resource.new('https://api.heroku.com', 'USERNAME', 'PASSWORD') | |
args = [:get, nil, { | |
'X-Heroku-API-Version' => '2', | |
'User-Agent' => 'my heroku client/1.0', | |
'X-Ruby-Version' => RUBY_VERSION, | |
'X-Ruby-Platform' => RUBY_PLATFORM | |
}].compact |
#!/bin/bash | |
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF | |
appify v3.0.1 for Mac OS X - http://mths.be/appify | |
Creates the simplest possible Mac app from a shell script. | |
Appify takes a shell script as its first argument: | |
`basename "$0"` my-script.sh |
#!ruby | |
# -*- coding: utf-8 -*- | |
require 'open-uri' | |
puts open('http://holiday.fjord.jp/').read.match(%r!<div class="next-holiday">\s*?(\d+月\d+日)\s*?<span>(.*?)</span>!)[1,2].join(' ') |