Skip to content

Instantly share code, notes, and snippets.

View strika's full-sized avatar

Nebojša Stričević strika

View GitHub Profile
@strika
strika / vbox-port-forwarding
Created April 4, 2013 17:19
VirtualBox port forwarding
VBoxManage modifyvm "mybox" --natpf1 "rails,tcp,,3000,,3000"
VBoxManage modifyvm "mybox" --natpf1 "guestssh,tcp,,2222,,22"
class NullObject
def nil?; true; end
def !; true end
def to_a; []; end
def to_s(*args); ""; end
def to_str(*args); ""; end
def to_f(*args); 0.0; end
def to_i(*args); 0; end
def method_missing(*args, &blk)
self
@strika
strika / install-git
Created October 2, 2013 08:16
Latest Git on Ubuntu
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git
@strika
strika / random-token
Created October 6, 2013 05:32
Generating a random token in Ruby
def generate_token
token = Digest::SHA1.hexdigest([Time.now, rand].join)
end
@strika
strika / uninstall-gems
Created October 22, 2013 05:13
Uninstall all ruby gems
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
@strika
strika / ssh-config
Last active April 25, 2016 14:12
.ssh/config
Host devbox
Hostname localhost
Port 2222
User strika
ForwardX11 yes
ForwardX11Trusted yes
ForwardAgent yes
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
@strika
strika / pds-remover.sh
Created December 6, 2013 07:19
Bash script for removing all PSD files from a repo history.
#!/bin/bash
set -o errexit
git filter-branch --tree-filter "git rm -r -f --ignore-unmatch *.psd" HEAD
rm -rf .git/refs/original/ && git reflog expire --all && git gc --aggressive --prune
@strika
strika / db_setup_test.rb
Created September 3, 2014 14:07
Database setup debugger
require "yaml"
ROOT = File.expand_path('..', File.dirname(__FILE__))
puts "Project root: #{ROOT}"
db_file = File.join(ROOT, "config", "database.yml")
puts "database.yml path: #{db_file}"
db_configuration = YAML.load_file(db_file)
puts "Database configuration:"
@strika
strika / ng-bindings.js
Created November 12, 2014 11:40
Number of bindings in AngularJS application
function getScopes(root) {
var scopes = [];
function traverse(scope) {
scopes.push(scope);
if (scope.$$nextSibling)
traverse(scope.$$nextSibling);
if (scope.$$childHead)
traverse(scope.$$childHead);
}
traverse(root);
@strika
strika / rest-design.txt
Last active August 29, 2015 14:14
Turning requirements into read/write resources
1. Figure out the data set
2. Split the data set into resources.
For each kind of resource:
3. Name the resources with URIs.
4. Expose a subset of the uniform interface.
5. Design the representation(s) accepted from the client.
6. Design the representation(s) served to the client.
7. Integrate this resource into eisting resources, using hypermedia links and forms.
8. Consider the typical course of events: what's supposed to happen?
9. Consider error conditions: what might go wrong?