Skip to content

Instantly share code, notes, and snippets.

View keithamus's full-sized avatar
:fishsticks:

Keith Cirkel keithamus

:fishsticks:
View GitHub Profile
<div itemscope itemtype="http://schema.org/Thing"></div>
### Keybase proof
I hereby claim:
* I am keithamus on github.
* I am keithamus (https://keybase.io/keithamus) on keybase.
* I have a public key whose fingerprint is 887F 7DC5 A858 9D7D 8653 D0B7 FCCC E6EC AC15 16FC
To claim this, I am signing this object:
#!/bin/sh
message=`sed '/^#/,$d' $1`
firstLine=`echo "$message" | awk 'NR>1{exit};1'`
exitCode=0
txtred=$(tput setaf 1) # Red
txtrst=$(tput sgr0) # Text reset
if [[ "`echo "$firstLine" | awk '{print length()}'`" -gt 49 ]]; then
echo "${txtred}[POLICY] Ensure first line in your commit message is no longer than 50 characters${txtrst}"
@keithamus
keithamus / example_code.js
Created November 22, 2012 12:20
How to do Dependency Injection in RequireJS?
define([], function () {
return function HypotheticalHelperMethod() {
doSomeOtherStuff();
}
});
define(["helperMethod"], function (helperMethod) {
@keithamus
keithamus / hexandrgb.js
Created February 20, 2013 12:27
RGB to HEX, HEX to RGB Can work with small hexes ('#000', '#f0c'), and RGB object ({r: 0, g: 0, b: 0})
function hex2rgb(hex) {
var int = parseInt(hex.replace(/^#/, '').replace(/^#/, '').replace(/^([\da-f])([\da-f])([\da-f])$/, '$1$1$2$2$3$3'), 16);
return {
r: (int >> 16) & 255,
g: int >> 8 & 255,
b: int & 255
};
}
hotkey.bind({"command", "option"}, 'down', function()
local resizing = hs.hotkey.modal.new()
local activeWindow = hs.window.focusedWindow()
local backdrop = hs.drawing.rectangle( hs.screen.mainScreen():frame() )
:setFillColor({ red=0, green=0, blue=0, alpha=0.2 })
local resizeIndicator = hs.drawing.rectangle({ x=0, y=0, w=0, h=0 })
:setFillColor({ red=1, green=1, blue=1, alpha=0.3 })
:setStrokeWidth(1)
:setStroke(1)
:setStrokeColor({ red=1, green=1, blue=1, alpha=0.5 })
@keithamus
keithamus / collect-headers.js
Created December 5, 2013 20:51
A little server that I used to collect headers for https://keithamus.ghost.io/an-analysis-of-http-headers
var app = require('express')(),
fs = require('fs');
var headers = [];
app.get('/', function (req, res) {
headers.push(req.headers);
res.json(req.headers);
});
setInterval(function () {
fs.writeFileSync('headers.json', JSON.stringify(headers));
}, 10000);
@keithamus
keithamus / loading.gif
Last active June 22, 2020 23:39
loading
loading.gif
@keithamus
keithamus / store.js
Created July 11, 2022 10:29
Reducer State management library, similar to Redux, using EventTarget
class Store extends EventTarget {
constructor(reducer, state) {
super()
this.#reducer = reducer
this.#state = state
}
get state() {
return this.#state
}
dispatch(action) {
@keithamus
keithamus / Nano Git Commit Syntax highlighting
Created December 10, 2010 13:58
Add this to your ~/.nanorc and when running "git commit" (if your editor is nano) you'll have syntax highlighting in your commit message. Includes support for "git commit -v" too!
syntax "gitcommit" "COMMIT_EDITMSG$"
color white "#.*"
color green "#.(modified|deleted).*"
color yellow start="# Changes.*" end="# Changed.*"
color cyan start="# Untracked.*" end="diff"
color cyan start="# Untracked.*" end="$$"
color brightred "^deleted file mode .*"
color brightgreen "^\+.*"
color brightred "^-.*"
color brightyellow "^(diff|index|---|\+\+\+).*"