Skip to content

Instantly share code, notes, and snippets.

View drhayes's full-sized avatar
🐱

David Hayes drhayes

🐱
View GitHub Profile
@staltz
staltz / introrx.md
Last active May 9, 2025 12:50
The introduction to Reactive Programming you've been missing
@razwan
razwan / _baseline.scss
Created April 14, 2014 16:20
Aligning type to baseline the right way with SASS
$base-font-size: 16px;
$base-line-height: 1.5;
// this value may vary for each font
// unitless value relative to 1em
$cap-height: 0.68;
@mixin baseline($font-size, $scale: 2) {
@igroff
igroff / getTimezoneOffsetHoursAndMinutes.js
Last active September 4, 2015 15:39
getTimezoneOffsetHoursAndMinutes -- Really, is this not already somewhere?
// name is still bad, have yet to figure what would be more correct
// sign change differences make re-using the TimezoneOffset verbage
// confusing
Date.prototype.getTimezoneOffsetHoursAndMinutes = function(){
// offset in minutes
var tzo = this.getTimezoneOffset();
// determine 'direction' from GMT we are
// if offset is positive, we're 'in the past'
var behindGMT = tzo > 0;
// work in positive
@danpe
danpe / Sublime Text 3 Environment Variables
Created October 15, 2013 18:56
Sublime Text 3 Environment Variables
List of all Sublime Text 3 Environment Variables to be used by Snippet Makers / Plugin Developers
$SELECTION The text that was selected when the snippet was triggered.
$TM_CURRENT_LINE Content of the line the cursor was in when the snippet was triggered.
$TM_CURRENT_WORD Current word under the cursor when the snippet was triggered.
$TM_FILENAME File name of the file being edited including extension.
$TM_FILEPATH File path to the file being edited.
$TM_FULLNAME User’s user name.
$TM_LINE_INDEX Column the snippet is being inserted at, 0 based.
$TM_LINE_NUMBER Row the snippet is being inserted at, 1 based.
@abeppu
abeppu / feelbetter.js
Last active February 6, 2021 19:06
Implementation of @FeelBetterBot
var Twit = require("twit");
var config = require('./oauthconfig');
console.log("config:");
console.log(config);
var T = new Twit({
consumer_key: config.consumer_key,
consumer_secret: config.consumer_secret,
access_token: config.access_token,
@brianleroux
brianleroux / harp-mod-request.md
Created October 12, 2013 20:53
fantasizing about some future integrations. - bringing harp some awareness of smart directories to build concat/min into convention - browserify for harp would be sweet - topcoatify does not yet exist but increasingly we something like it should exist - next www can just 'disappear' as that it becomes a build artifact
|- node_modules/
|- src/
|   |
|   |- index.js/ <----------- uses browserify so anything in node_modules is game for require()
|   |  |- index.js
|   |  '- foo.coffee
|   |
|   |- index.css/ <---------- uses topcoatify so anything in node_modules is game. how import/etc works needs consideration

| | |- index.css

@kirbysayshi
kirbysayshi / lib_game_entities.js
Created July 29, 2013 04:25
rotatablegame.js: Rotate the camera in an impactjs game! Underscores in filenames indicate directories.
ig.module(
'game.entities.square'
)
.requires(
'impact.entity'
)
.defines(function(){
EntitySquare = ig.Entity.extend({
@getify
getify / f1.js
Last active December 19, 2015 19:58
Improve the string serialization output of Error objects using `.stack`, if it's available (recent Chrome and Firefox do!)
// hopefill to wrap the built-in Error.prototype.string() with an improved version
(function(){
var errToString = Error.prototype.toString;
Error.prototype.toString = function() {
var stack;
// some browsers track the much more useful `.stack`, so use it!
if (this.stack) {
// some print the name/message in .stack, some don't. normalize it.
stack = (this.stack + "").replace(new RegExp(this.name + ": " + this.message + "\n"),"");
@mjackson
mjackson / color-conversion-algorithms.js
Last active April 1, 2025 17:53
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation