Skip to content

Instantly share code, notes, and snippets.

View kellishaver's full-sized avatar

Kelli Shaver kellishaver

View GitHub Profile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "rr2014"
config.vm.box_url = "https://s3.amazonaws.com/kshaver-resources/rr2014.box"
@kellishaver
kellishaver / image-analyze.rb
Last active January 3, 2016 07:39
Analyze an image for the 10 most common colors and their percentage.
require 'RMagick'
include Magick
puts "Enter the path to the image you wish to analyze:"
file = gets.chomp
image = Magick::ImageList.new(file)
q = image.quantize(10, Magick::RGBColorspace)
palette = q.color_histogram.sort {|a, b| b[1] <=> a[1]}
@kellishaver
kellishaver / gist:8012670
Created December 17, 2013 21:09
Developer's Creed
This is my text editor. There are many like it, but this one is mine.
My text editor is my best friend. It is my life. I must master it as I must master my life.
My text editor, without me, is useless. Without my text editor, I am useless. I must use my text editor efficiently.
I must code faster than my approaching deadline which is trying to kill me. I must debug before it arrives. I will...
My text editor and I know that what counts in this project is not the lines of code we write, the automated testing, nor the code linters we use.
@kellishaver
kellishaver / Loading-Animation.markdown
Created October 22, 2013 03:18
A Pen by Kelli Shaver.
@kellishaver
kellishaver / hex_color_validator.rb
Created October 21, 2013 14:30
Validates a hexadecimal color value
class HexColorValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors[attribute] << (options[:message] || 'is not a valid colour value') unless self.class.matches?(value)
end
def self.matches?(value)
return false unless value
/\A#(?:[0-9a-f]{3})(?:[0-9a-f]{3})?\z/i.match(value).nil? ? false : true
end
end
@kellishaver
kellishaver / SublimeBlockCursor.py
Created June 26, 2012 15:32
Sublime Text 2 Block Cursor - outside of Vintage Mode
import sublime
import sublime_plugin
class SublimeBlockCursor(sublime_plugin.EventListener):
def view_is_widget(view):
settings = view.settings()
return bool(settings.get('is_widget'))
def show_block_cursor(self, view):
validRegions = []
@kellishaver
kellishaver / thumbnail-preview-demo.html
Created April 20, 2012 07:51
Demo of how to display cropped thumbnail previews for file input boxes.
<!DOCTYPE html>
<html>
<head>
<title>Image Preview</title>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<style type="text/css">
* {
box-sizing: border-box;
position: relative;
-moz-box-sizing: border-box;
@kellishaver
kellishaver / updater.php
Created February 26, 2010 06:53
monitors a github repo/branch and pulls new code when it detects a change
<?php
/*
A small script to authenticate to github, check a repo/branch
and pull the code if a new commit has been made. It also does
an initial pull as soon as it's executed.
Dead Simple, but it works.
$: cd <your repo>
$: php updater.php
@kellishaver
kellishaver / tab_shortcuts.html
Created February 21, 2010 18:02
Demo implementation of tabbed nav with keyboard shortcuts
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<head>
<title>Tabs With Keyboard Shortcuts</title>
<style type="text/css">
body { background:#fff; font-family:arial, helvetica, sans-serif; color:#000; font-size:10pt; }
#container { width:450px; border:1px solid #3b3b3b; height:200px; }
#tabs { margin:0; padding:0; background:#aaa; height:35px; border-bottom:1px solid #3b3b3b; }
#tabs li { list-style:none; margin:0; padding:0; display:inline; }
#tabs li a { color:#999; font-weight:bold; text-decoration:none; height:25px; line-height:25px; margin-top:5px; border-bottom:1px solid #3b3b3b; padding:0 10px; margin:10px 0 0 10px; float:left; background:#ededed; border-right:2px solid #3b3b3b; outline:none; }
@kellishaver
kellishaver / flash_notice.css
Created February 13, 2010 19:22
javascript/css for floating flash notice
#flash_notice {
width:400px;
padding:10px;
background:#dbffca;
color:#060;
height:30px;
line-height:30px;
border:1px solid #060;
font-family:arial, helvetica, sans-serif;
font-size:12pt;