Skip to content

Instantly share code, notes, and snippets.

@kascote
kascote / color_luminance
Created March 14, 2015 18:48
Calculate Lighter or Darker Hex Colors
#
# Examples:
# color_luminance("#69c", 0); # returns "#6699cc"
# color_luminance("6699CC", 0.2); # "#7ab8f5" - 20% lighter
# color_luminance("69C", -0.5); # "#334d66" - 50% darker
# color_luminance("000", 1); # "#000000" - true black cannot be made lighter!
#
# based on code from
# http://www.sitepoint.com/javascript-generate-lighter-darker-color/
#
@kascote
kascote / .pryrc
Created August 28, 2014 18:36 — forked from justin808/.pryrc
## Useful Collections
def a_array
(1..6).to_a
end
def a_hash
{hello: "world", free: "of charge"}
end
#encoding: UTF-8
require 'rubygems'
require "pismo"
require 'punkt-segmenter'
require 'htmlentities'
require './markov.rb'
CLEAN_TEXT = <<-EOF
@kascote
kascote / Rakefile
Created August 9, 2014 22:34 — forked from fstrube/Rakefile
# Include all rake files in the tasks directory
Dir.glob('tasks/*.rake').each { |r| import r }
# Read configuration from tasks/config.yaml
require 'yaml'
CONFIG = YAML.load_file('tasks/config.yaml')[ENV['env'] || 'development']
# Default utility functions available in all tasks
def ok_failed(condition)
if (condition)
@kascote
kascote / app.js
Created June 23, 2014 21:14 — forked from skypanther/app.js
var Utils = {
/* modified version of https://gist.github.com/1243697
* adds detection of file extension rather than hard-coding .jpg as in the original
*/
_getExtension: function(fn) {
// from http://stackoverflow.com/a/680982/292947
var re = /(?:\.([^.]+))?$/;
var tmpext = re.exec(fn)[1];
return (tmpext) ? tmpext : '';
},
@kascote
kascote / OhmUtils.rb
Created October 18, 2013 03:51
Utility function to reindex an Ohm model or populate a new added index
#
# Utility function to reindex an Ohm model or populate a new added index
# The functions is idempotent
# only use over 'index', not 'reference' indexes
#
# use:
# class Table < Ohm::Model
# include OhmUtils
#
# ...
#!/bin/bash -ex
### configuration
PKGS_TO_ADD="$PKGS_TO_ADD curl git etckeeper python-software-properties"
PKGS_TO_REMOVE="$PKGS_TO_REMOVE geoip-database popularity-contest"
PKGS_TO_REMOVE="$PKGS_TO_REMOVE pppoeconf pppconfig ppp"
PKGS_TO_REMOVE="$PKGS_TO_REMOVE ubuntu-standard memtest86+" # warning: be careful about what you remove after this
KERNEL_MODULES_TO_BLACKLIST="$KERNEL_MODULES_TO_BLACKLIST joydev gameport"
KERNEL_MODULES_TO_BLACKLIST="$KERNEL_MODULES_TO_BLACKLIST btusb bluetooth"
@kascote
kascote / snippet
Created June 24, 2013 14:56
CSS Snippets
/*
* 2011 Clearfix
*/
.clearfix:before, .container:after { content: ""; display: table; }
.clearfix:after { clear: both; }
/* IE 6/7 */
.clearfix { zoom: 1; }
@kascote
kascote / gist:5609343
Created May 19, 2013 22:39
osx ruby 2.0 install
brew install readline openssl
export CFLAGS=-Wno-error=shorten-64-to-32
env RUBY_CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl` CONFIGURE_OPTS=--with-readline-dir=`brew --prefix readline` rbenv install 2.0.0-p195
@kascote
kascote / inputrc
Created August 23, 2012 20:17
Vim keybinding everywhere
» cat .inputrc
set -o vi
set editing-mode vi
set keymap vi