Skip to content

Instantly share code, notes, and snippets.

@roberocity
roberocity / tablesort.css
Last active August 29, 2015 14:07
sorts a table by rows with no dependencies
th[data-sort] {
cursor: n-resize;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@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
@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 / 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 / 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 / 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 / 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 / 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]
(function( $ ) {
$.fn.maxHeight = function() {
var max = 0;
this.each(function() {
max = Math.max(max, $(this).height() );
});
return max;
};
$.fn.equalizeHeight = function() {
@roberocity
roberocity / git-deploy.rb
Created May 9, 2012 19:39
Git-based deployment for Sinatra
require 'sinatra/base'
require 'time'
class GitHook < Sinatra::Base
def self.parse_git
# Parse hash and date from the git log command
sha1, date = `git log HEAD~1..HEAD --pretty=format:%h^%ci`.strip.split('^')
set :commit_hash, sha1
set :commit_date, Time.parse(date)