Skip to content

Instantly share code, notes, and snippets.

@whitlockjc
whitlockjc / main.js
Created December 12, 2012 00:55
Example showing how to use Require.js to load Backbone.js and its dependencies (jQuery and Underscore.js).
require.config({
paths: {
jquery: 'libs/jquery/jquery.min',
underscore: 'libs/underscore/underscore.min',
backbone: 'libs/backbone/backbone.min',
bootstrap: 'libs/bootstrap/bootstrap.min'
},
shim: {
'underscore': {
exports: '_'
@whitlockjc
whitlockjc / html-ejs.el
Last active December 21, 2015 01:19
Use mmm-mode to enable EJS Template highlighting in html-mode
;; ...
;; Use mmm-mode to enable EJS (http://embeddedjs.com) Template highlighting in html-mode
;; Turn on mmm-mode
(require 'mmm-mode)
(setq mmm-global-mode 'maybe)
;; mmm-mode class for EJS Templates
(mmm-add-classes
@whitlockjc
whitlockjc / rgbaToHex.js
Last active July 18, 2022 10:25
Use JavaScript to Convert RGBA CSS Value to Hexadecimal
#!/usr/bin/env node
// Takes an rgba() CSS value and converts it to its 8 digit hexadecimal value.
//
// Usage: ./rgbaToHex.js "{YOUR_RGBA_STRING}"
//
// Example: ./rgbaToHex.js "rgba(197, 200, 198, .2)" => #C5C8C633
function trim (str) {
return str.replace(/^\s+|\s+$/gm,'');
@whitlockjc
whitlockjc / keybase.md
Created March 31, 2014 15:57
Proving my GitHub for Keybase

Keybase proof

I hereby claim:

  • I am whitlockjc on github.
  • I am whitlockjc (https://keybase.io/whitlockjc) on keybase.
  • I have a public key whose fingerprint is 9AC5 D0B9 B22B 4294 B2C4 9527 6811 E747 E3DF 6D9D

To claim this, I am signing this object:

@whitlockjc
whitlockjc / wordcount.js
Created May 13, 2014 20:23
Node.js Based Wordcount MapReduce Job
'use strict';
var FileInputFormat = require('hadoop-input').FileInputFormat;
var FileOutputFormat = require('hadoop-output').FileOutputFormat;
var counterGroup = 'Word Count Counters';
var uniqueWordCounterName = 'Unique Words';
var totalWordsCounterName = 'Total Words';
var uniqueWordsCounter;
var totalWordsCounter;
@whitlockjc
whitlockjc / formatted_uptime.sh
Created May 30, 2014 18:28
Human readable uptime
uptime | sed 's/,//g' | cut -f 4- -d ' ' | sed 's/ [0-9][0-9]* users .*//' | sed 's/\(.*\):\(.*\)/\1 hours \2 mins/'
@whitlockjc
whitlockjc / frame-geometry.el
Created January 15, 2015 22:41
Emacs package for storing/restoring window geometry
;;; frame-geometry.el --- Emacs package for storing/restoring window geometry
(setq frameg-file (expand-file-name "frame-geometry" user-emacs-directory))
(defun save-frameg ()
"Gets the current frame's geometry and saves to ~/.emacs.d/frame-geometry."
(let ((frameg-font (frame-parameter (selected-frame) 'font))
(frameg-left (frame-parameter (selected-frame) 'left))
(frameg-top (frame-parameter (selected-frame) 'top))
(frameg-width (frame-parameter (selected-frame) 'width))
@whitlockjc
whitlockjc / TerminalHelper.scpt
Last active August 29, 2015 14:20
Better/Working version of TerminalHelper.scpt for Visual Studio Code for Mac
-- This file resides at /Applications/Visual Studio Code.app/Contents/Resources/app/client/vs/workbench/contrib/debug/bin/TerminalHelper.scpt
on run argv
set working_dir to missing value
set runtimeArgs to missing value
set runtimeName to missing value
set programArgs to missing value
set env_vars to ""
repeat with i from 1 to (count of argv)
set a to (item i of argv)
@whitlockjc
whitlockjc / json-refs-leaning-up.md
Last active August 29, 2015 14:24
Interesting stuff learned about browserify and lodash while leaning up json-refs.

I was recently building a release of json-refs when I realized that the on disk file size was much larger than I expected. I use browserify to build my browser builds since I write json-refs for io.js/node.js. I started looking into the browserify build graph and that is when I noticed something interesting. Below are my findings.

Note: I realize I might be fixing a problem that does not matter and there could even be flaws in how json-refs is using browserify. I also realize that removing lodash is not something you can always do. This is just one of those cases where I wasn't using anything in lodash that wasn't in ES5 and I didn't need json-refs to work in pre-ES5 environments. This is not a hit on lodash, lodash is awesome. Please leave any feedback in the comments.

@whitlockjc
whitlockjc / example.el
Created March 9, 2016 18:25
Emacs linum-format that works around whitespace-mode and padding
;; Linum mode
(global-linum-mode t)
;; Custom face/function to pad the line number in a way that does not conflict with whitespace-mode
(defface linum-padding
`((t :inherit 'linum
:foreground ,(face-attribute 'linum :background nil t)))
"Face for displaying leading zeroes for line numbers in display margin."
:group 'linum)