This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
# If you want the first n items from an array, you could call first(n) | |
# but if the array has less than n members, so will the return value. | |
# This method ensures that the return value has as many items as requested, | |
# by cycling through the array from the beginning. | |
# e.g. [1,2,3].modulo(2) => [1,2] | |
# [1,2,3].modulo(4) => [1,2,3,1] | |
# [1,2,3].modulo(7) => [1,2,3,1,2,3,1] | |
def modulo(required_size) | |
required_size = size if required_size.nil? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
# Handy when outputing a list in two columns, such as: | |
# | |
# A B A C A C A D | |
# B B D B E | |
# C | |
# | |
def columnize | |
if size <= 1 | |
[ self, [] ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Set tabstop, softtabstop and shiftwidth to the same value | |
command! -nargs=* Stab call Stab() | |
function! Stab() | |
let l:tabstop = 1 * input('set tabstop = softtabstop = shiftwidth = ') | |
if l:tabstop > 0 | |
let &l:sts = l:tabstop | |
let &l:ts = l:tabstop | |
let &l:sw = l:tabstop | |
endif | |
call SummarizeTabs() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Switch wrap off for everything | |
set nowrap | |
if has("autocmd") | |
" This is probably in your .vimrc already. No need to duplicate! | |
filetype plugin indent on | |
" Set File type to 'text' for files ending in .txt | |
autocmd BufNewFile,BufRead *.txt setfiletype text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if has("autocmd") | |
" This is probably in your .vimrc already. No need to duplicate! | |
filetype plugin indent on | |
" When editing a file, always jump to the last known cursor position. | |
autocmd BufReadPost * | |
\ if line("'\"") > 1 && line("'\"") <= line("$") | | |
\ exe "normal! g`\"" | | |
\ endif | |
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Giles Bowkett, Greg Brown, and several audience members from Giles' Ruby East presentation. | |
# http://gilesbowkett.blogspot.com/2007/10/use-vi-or-any-text-editor-from-within.html | |
require 'tempfile' | |
module Exec | |
extend self | |
def system(file, *args) | |
Kernel::system(file, *args) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Delete all inactive buffers by running: | |
" :call CloseHiddenBuffers() | |
" or the | |
" :Only | |
command! -nargs=* Only call CloseHiddenBuffers() | |
function! CloseHiddenBuffers() | |
" figure out which buffers are visible in any tab | |
let visible = {} | |
for t in range(1, tabpagenr('$')) | |
for b in tabpagebuflist(t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.setup({ | |
onReady: function() { | |
var data = [{ | |
name: 'Joshua', | |
age:3 | |
},{ | |
name: 'Matthew', | |
age:2 | |
},{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.setup({ | |
onReady: function() { | |
var data = [{ | |
name: 'Joshua', | |
age:3 | |
},{ | |
name: 'Matthew', | |
age:2 | |
},{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head>...[load sencha js/css etc.]...</head> | |
<body> | |
<textarea id="kids-list" class="x-hidden-display"> | |
<p>Kids:</p> | |
<tpl for="."> | |
<p>{#}. {name}</p> | |
</tpl> |
OlderNewer