Some exercises from the Falsy Values workshops.
The good parts:
- HTTP server and client in same script
- Express cookies example
- Express routing example
- Express error handling
- Express middlewares example
- Simple HTTP proxy
let s:id_counter = 0 | |
let s:klass = {'_class_': ['Klass'], '_id_': 0} | |
" クラスの作成 | |
function! s:klass.create(...) dict | |
let object = deepcopy(self) | |
let class = copy(self._class_) | |
for c in get(a:1, '_class_', []) | |
call add(class, c) | |
endfor |
# | |
# Show branch name in Zsh's right prompt | |
# | |
autoload -Uz VCS_INFO_get_data_git; VCS_INFO_get_data_git 2> /dev/null | |
setopt prompt_subst | |
function rprompt-git-current-branch { | |
local name st color gitdir action |
#!/bin/bash | |
true=":" | |
false="/bin/false" | |
success=0 | |
failure=1 | |
Some exercises from the Falsy Values workshops.
The good parts:
class Application | |
def call(request, response) | |
response.write(request, "hello", 200, {}) | |
10.times do |body| | |
response.write(request, body) | |
end | |
response.close | |
end |
function! s:BundleGet() "{{{ | |
let bundle_dir = expand('~/.vim/bundle') | |
try | |
let org_cwd = getcwd() | |
silent lcd `=bundle_dir` | |
let repo = matchstr(getline('.'), 'BUNDLE:\s\+\zs.*') | |
if repo != '' | |
let local_name = substitute(fnamemodify(repo, ':t'), | |
\ '^\%\(vim-\)\?\(.*\).git','\1', '') | |
if isdirectory(local_name) |
// knockout 2.2.1 | |
ko.utils.arrayFilter = function (array, predicate) { /* .. */ } | |
ko.utils.arrayFirst = function (array, predicate, predicateOwner) { /* .. */ } | |
ko.utils.arrayForEach = function (array, action) { /* .. */ } | |
ko.utils.arrayGetDistinctValues = function (array) { /* .. */ } |
# Rake Quick Reference | |
# by Greg Houston | |
# http://ghouston.blogspot.com/2008/07/rake-quick-reference.html | |
# ----------------------------------------------------------------------------- | |
# Running Rake | |
# ----------------------------------------------------------------------------- | |
# running rake from the command-line: | |
# rake --help |
// Lack of tail call optimization in JS | |
var sum = function(x, y) { | |
return y > 0 ? sum(x + 1, y - 1) : | |
y < 0 ? sum(x - 1, y + 1) : | |
x | |
} | |
sum(20, 100000) // => RangeError: Maximum call stack size exceeded | |
// Using workaround |
/* Exercise: Loops and Functions #43 */ | |
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
func Sqrt(x float64) float64 { | |
z := float64(2.) |