Skip to content

Instantly share code, notes, and snippets.

@roberocity
roberocity / roberocity.zsh-theme
Created February 25, 2012 14:47
roberocity oh my zsh theme
#!/usr/bin/env zsh
#local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
setopt promptsubst
autoload -U add-zsh-hook
PROMPT_SUCCESS_COLOR=$FG[117]
PROMPT_FAILURE_COLOR=$FG[124]
PROMPT_VCS_INFO_COLOR=$FG[242]
@roberocity
roberocity / initial-server-setup.sh
Created February 5, 2012 02:44
Simple Server Setup
echo "Setting up the server with initial packages, etc."
echo "This should be done as sudo."
echo "-------"
echo "Upate and Upgrade existing packages. Install basic packages."
# initial server setup
apt-get update
apt-get -y upgrade
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libpcre3-dev git-core libxml2 libxml2-dev libxslt-dev
@roberocity
roberocity / copy-ssh-key-to-server.sh
Created February 5, 2012 02:24
Copy ssh pub key from local to server
ssh username@host "echo `cat ~/.ssh/id_rsa.pub` >> ~/.ssh/authorized_keys"
@roberocity
roberocity / shuffle.cs
Last active February 9, 2023 15:01
Shuffle Array
// Sattolo's algorithm as an extention method of Array
public static T[] Shuffle<T>(this T[] array)
{
var random_generator = new Random(DateTime.Now.Millisecond);
int i = array.Length-1;
while (i > 1)
{
i--;
int j = random_generator.Next(i);
@roberocity
roberocity / randome_string.rb
Created October 20, 2011 20:45
Ruby Random String
# base 36
# 12 character long random string
rand(36**12).to_s(36)
@roberocity
roberocity / jquery.equalizeHeight.js
Created October 18, 2011 11:41
jQuery plugin to equalize the height of several elements
(function($) {
$.fn.equalizeHeight = function(minHeight, maxHeight) {
tallest = (minHeight) ? minHeight : 0;
this.each(function() {
if($(this).height() > tallest) {
tallest = $(this).height();
}
});
if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
return this.each(function() {
@roberocity
roberocity / config.rb
Created September 23, 2011 23:49
General Config class for handling YAML files
class Config
attr_reader :data, :env
def self.config_path
File.join('config')
end
def initialize(opts)
@env = opts[:env]
filename = opts[:filename]
@roberocity
roberocity / simple_html5.js
Created September 21, 2011 16:22
Minimum needed to support HTML5 element in IE < 9
// @roberocity
// this is the minimum to do to provide html5 element support for older versions of IE
for(i in k='abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|subline|summary|time|video'.split('|')){document.createElement(k[i]);}
// a better solution may be by @rem, @jon_neal & @aFarkas, but I've had a few errors when printing using this: http://html5shim.googlecode.com/svn/trunk/html5.js