jQuery.deferred
で実験。fail()
は jQuery 用語で、ES2015 だと catch()
になる。
$.getJSON('/api1')
#! /bin/sh | |
xcode-select --install | |
brew install php@5.6 postgresql@9.4 brew-php-switcher libmemcached | |
brew link --force php@5.6 | |
brew link --force postgresql@9.4 | |
# |
<?php | |
/** | |
* @param object $obj ( may be array ) | |
* @return mixed string or null | |
*/ | |
function csv_encode($obj) | |
{ | |
$csv = null; | |
$rows = is_object($obj) ? json_decode(json_encode($obj), true) : $obj; |
<?php | |
class CacheInitiator | |
{ | |
static function run() | |
{ | |
$initializer = "init".ucfirst(strtolower(Cache::getDefaultDriver())); | |
$self = new CacheInitiator(); | |
if ( method_exists($self, $initializer) ) { |
import argparse | |
class Weinrer: | |
def __init__(self, host, port): | |
self.host = host | |
self.port = port | |
def response(self, flow): | |
text = flow.response.text |
#! /usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
# | |
# Usage: | |
# cat src.csv | ruby collect-screen-sizes.rb > dest.csv | |
# | |
require 'csv' | |
class NotExpectedHeaders < RuntimeError; end |
# Returns whether the document is a draft. This is only the case if | |
# the document is in the 'posts' collection but in a different | |
# directory than '_posts'. | |
# | |
# Returns whether the document is a draft. | |
def draft? | |
data['draft'] ||= relative_path.index(collection.relative_directory).nil? && collection.label == "posts" | |
end |
はじめてのC☆I
# -*- mode: ruby -*- | |
desc 'latest-todomvc-vanilla' | |
task 'latest-todomvc-vanilla' => ['clean:dest', 'todomvc:fetch'] do | |
sh <<EOD | |
cd #{File.join(todomvc_dir, 'examples')} | |
git ls-files vanillajs | cpio -pud ../../ | |
EOD | |
end |
{ | |
"dependencies": { | |
"babelify": "^7.2.0", | |
"browserify": "^13.0.0", | |
"licensify": "^2.2.0", | |
"uglifyjs": "^2.4.10" | |
}, | |
"devDependencies": { | |
"watchify": "^3.7.0" | |
}, |