Skip to content

Instantly share code, notes, and snippets.

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
@uasi
uasi / gist:214109
Last active September 11, 2015 03:06
Show branch name in Zsh's right prompt
#
# 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
@bergie
bergie / README.md
Created May 18, 2011 11:33
Falsy Values tutorials
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)
@hyle
hyle / ko.utils.signatures.js
Last active May 14, 2022 21:15
KnockoutJS utils (ko.utils) signatures
// 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) { /* .. */ }
@noonat
noonat / gist:1649543
Created January 20, 2012 21:02
Rake Quick Reference
# 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
@Gozala
Gozala / example.js
Created January 29, 2012 03:46
Workaround for lack of "tail call optimization" in JS
// 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
@zyxar
zyxar / exercise.tour.go
Last active April 28, 2024 17:06
tour.golang exercise solutions
/* Exercise: Loops and Functions #43 */
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := float64(2.)