Skip to content

Instantly share code, notes, and snippets.

View kellishaver's full-sized avatar

Kelli Shaver kellishaver

View GitHub Profile
@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 / .rspec
Created February 13, 2020 20:18
Fun Rspec matcher
# lives in ~/.rspec
# update path to formatter.rb as needed - I also put it in ~/ :)
--require ~/formatter.rb --format GroupingFormatter
@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 = []
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
# 3. Clear 'Processed' and 'Failed' jobs
@kellishaver
kellishaver / FlappyArmy.ino
Last active January 15, 2019 19:00
Flappy Guy Army Control Code
#include <IRremote.h>
// FanGates control MOSFET transistors
int FanGates[5] = {3,5,6,9,10};
// Individual states for each Gate (on 1/off 0)
int FanState[5] = {0};
// Array of power levels for each fan
int FanSpeeds[5] = {0};
define :guitar_chords do
in_thread do
4.times do
with_fx :echo, mix: 0.3, phase: 0.25 do
sample :guit_em9, rate: 1
end
sleep 4
end
end
end
@kellishaver
kellishaver / mood_lamp.ino
Created March 12, 2016 04:08
Mood Lamp Sketch
int pulseSpeed = 5;
int ldrPin = 0;
int redLed = 10;
int greenLed = 11;
int blueLed = 9;
int ambientLight;
int power = 150;
@kellishaver
kellishaver / keymap.c
Created February 13, 2016 19:38
Planck Custom Keymap
#include "planck.h"
#define _QW 0
#define _CM 1
#define _DV 2
#define _LW 3
#define _RS 4
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_QW] = { /* Qwerty */
@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.