create different ssh key according the article Mac Set-Up Git
$ ssh-keygen -t rsa -C "your_email@youremail.com"
| import sys | |
| import time | |
| def progressbar(it, prefix = "", size = 60): | |
| count = len(it) | |
| def _show(_i): | |
| x = int(size*_i/count) | |
| sys.stdout.write("%s[%s>%s] %i/%i\r" % (prefix, "="*x, "-"*(size-x), _i, count)) | |
| sys.stdout.flush() |
| #!/bin/bash | |
| # remove __MACOSX foldr and .DS_Store files | |
| # from *_original.zip file | |
| # zip again and place under fixed/* | |
| for x in $* | |
| do | |
| unzip $x |
| class ApplicationController < ActionController::Base | |
| # ... | |
| unless Rails.application.config.consider_all_requests_local | |
| rescue_from Exception, with: lambda { |exception| render_error 500, exception } | |
| rescue_from ActionController::RoutingError, ActionController::UnknownController, ::AbstractController::ActionNotFound, ActiveRecord::RecordNotFound, with: lambda { |exception| render_error 404, exception } | |
| end | |
| private | |
| def render_error(status, exception) |
| The basic idea here is to substantiate the claims made by this square post: | |
| http://corner.squareup.com/2011/06/postgresql-data-is-important.html | |
| In PostgreSQL, and MySQL (MyISAM and InnoDB) I create millions of rows and then add | |
| and remove columns and add and remove indexes. For columns without defaults this is | |
| basically free in PostgreSQL and O(n) in MySQL. For adding indexes its at best O(n) | |
| everywhere, but with PostgreSQL it claims not to do any locking that would otherwise | |
| prevent table interaction. | |
| Also, PostgreSQL has _awsome_ documentation (it has real examples!). I always get |
| // This document distills the magic that happens when you create a file with the ".jst" | |
| // and ".ejs" extensions anywhere on your asset path in Ruby on Rails, courtesy of the | |
| // Sprockets library (https://github.com/sstephenson/sprockets). | |
| // | |
| // For the purpose of this example, imagine that you have created a template for | |
| // messages in `app/assets/javascripts/backbone/templates/messages/message.jst.ejs` | |
| // with the following contents: | |
| // | |
| // <h1><%= user.full_name %></h1> | |
| // <p><%= body %></p> |
| // Ruby = 5.times { |i| puts i } | |
| // JS = (1).times(function(i){console.log(i);}) | |
| Number.prototype.times = function(cb) { | |
| var i = -1; | |
| while (++i < this) { | |
| cb(i); | |
| } | |
| return +this; |
create different ssh key according the article Mac Set-Up Git
$ ssh-keygen -t rsa -C "your_email@youremail.com"
Ruby の HTTP クライアントライブラリ Faraday が便利そう
API ラッパの開発には [RestClient gem][rest_client_gem] だとか
OAuth の必要なものは [Net/HTTP][net_http] + [OAuth gem][oauth_gem] を使ってた
[Twitter gem][twitter_gem] や [Instagram gem][instagram_gem] など API ライブラリのソースを読んでみると
[Faraday gem][faraday_gem] というものがよく使われてた
| ;; Idea based on concatenating those values before the pivot with the pivot and those that come after the pivot. | |
| ;; | |
| ;; Call recursively until the length of the collection is 1 (then return just that item in the collection). | |
| ;; | |
| ;; Getting the items before and after the pivot is done by filtering the collection with an anonymous function | |
| ;; that takes a single argument and compares that to the pivot. | |
| (defn quicksort | |
| "Recursive quick sort implementation" | |
| [items] |
| (def open-for-business? (atom true)) | |
| (def haircut-count (agent 0)) | |
| (def waiting-room (ref [])) | |
| (def waiting-room-size 3) | |
| (defn open-shop [duration] | |
| (do (Thread/sleep duration) (swap! open-for-business? not))) | |
| (defn add-customers [] | |
| (future |