Skip to content

Instantly share code, notes, and snippets.

View thisivan's full-sized avatar

Ivan Torres thisivan

View GitHub Profile
@thisivan
thisivan / gist:1395629
Created November 26, 2011 12:58
Git-rm: Delete already deleted files
git status | grep deleted | cut -f2 | sed -e 's/deleted:\s*//g' | xargs git rm -f
@thisivan
thisivan / gist:1314957
Created October 26, 2011 00:31
Change Vim file alias
#!/usr/bin/env sh
DEFAULT_VIM_PATH='/workspace/tools/vim'
if [[ ! -z $1 ]]; then
DEFAULT_VIM_PATH=$1
fi
rm ~/.vimrc
rm ~/.vim
startup_message off
defscrollback 5000
defutf8 on
hardstatus alwayslastline
hardstatus string '%{= kG}[%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'
@thisivan
thisivan / paginated_collection.js
Created October 17, 2011 11:50 — forked from io41/paginated_collection.js
Pagination with Backbone.js
// includes bindings for fetching/fetched
var PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage');
typeof(options) != 'undefined' || (options = {});
this.page = 1;
typeof(this.perPage) != 'undefined' || (this.perPage = 10);
},
fetch: function(options) {
vmap <Leader>! :call ExecuteVLines()<CR>
function! NumSort(a, b)
return a:a>a:b ? 1 : a:a==a:b ? 0 : -1
endfunction
function! ExecuteVLines()
let [firstline, lastline]=sort([line('v'), line('.')], 'NumSort')
let lines = getline(firstline, lastline)
exec ":!".join(lines, " && ")
@thisivan
thisivan / gist:1284745
Created October 13, 2011 16:41
String Concatenation
# Ruby String Concatenation Benchmarks
require 'benchmark'
n = 100000
a = "a"
b = "b"
c = "c"
@thisivan
thisivan / gist:1208606
Created September 10, 2011 18:23
Install Ubuntu 11.04 server
# Update to the latest version
sudo apt-get update && sudo apt-get upgrade && sudo shutdown -r now
# Install SSH server
sudo apt-get install openssh-server
# Install basic tools
sudo apt-get install build-essential vim-nox curl git-core subversion
# Install RVM (as root, system wide)
@thisivan
thisivan / rmagick.sh
Created September 7, 2011 18:37 — forked from zoras/rmagick.sh
Install RMagick on Ubuntu 11.04
sudo apt-get install libdjvulibre-dev libjpeg-dev libtiff-dev libwmf-dev libmagickcore-dev libmagickwand-dev libmagick++-dev rvm
sudo gem install rmagick
ok!
Fetching: rmagick-2.13.1.gem (100%) Building native extensions. This could take a while ... Successfully installed rmagick-2.13.1 1 gem installed
require 'RMagick' #=> true
@thisivan
thisivan / gist:1201342
Created September 7, 2011 18:36
Install Ubuntu 11.04 Desktop (amd64)
# Update to the latest version
sudo apt-get update && sudo apt-get upgrade && sudo shutdown -r now
# Install Chromium
sudo apt-add-repository ppa:chromium-daily/dev
sudo apt-get update && sudo apt-get install chromium-browser
# Install basic tools
sudo apt-get install build-essential vim-nox curl git-core subversion openssh-server
@thisivan
thisivan / method_missing_vs_method_compilation.rb
Created August 24, 2011 09:19
Method Missing vs Method Compilation
require 'benchmark'
# Defined method
class ExampleA
def test
10000 * 10000
end
end
# Method lookup