Skip to content

Instantly share code, notes, and snippets.

View halcarleton's full-sized avatar

Hal Carleton halcarleton

  • Seattle, WA
  • 13:21 (UTC -07:00)
View GitHub Profile
@halcarleton
halcarleton / SublimeText-Project-Line-Count
Last active August 6, 2023 16:09 — forked from Hexodus/count_total_project_code_lines_in_sublime
Count total lines of code in a Sublime Text Project or Directory
Go to menu:
Find -> Find in Files... (windows: ctrl+shift+f)
Switch on reg_ex button (windows: alt+r)
Find:
^.*\S+.*$
Where:
c:\your_folder\,*.php,*.js,*.inc,*.html,*.htm,*.scss, -*/folder_to_exclude/*, -*.min.js
git remote prune origin
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -df
{
"plugins": [
"react"
],
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"jsx": true,
"experimentalObjectRestSpread": true
},
@halcarleton
halcarleton / .eslintrc.node.json
Last active December 14, 2016 17:45
ESLint config file for node
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "script"
},
"parser": "espree",
"env": {
"node": true,
"es6": true
},
@halcarleton
halcarleton / callNew.js
Last active December 6, 2016 15:02
call/apply with `new` operator
function applyNew(constructor, args) {
return new (Function.prototype.bind.apply(constructor, [constructor].concat(args)))();
}
function callNew(func /*[, arg1[, arg2[, ...]]]*/) {
return applyNew(func, ...arguments);
}
@halcarleton
halcarleton / SuperConstructor.js
Last active October 17, 2016 18:58
Super Constructor Pattern for future reference
// Base Class
function Base(p1, p2) {
this.x = this.someMethod(p1, p2);
this.y = {
a: p1,
b: p2
};
}
Base.prototype.someMethod = funciotn(a, b) {
@halcarleton
halcarleton / Jekyll-Gulpfile.js
Last active August 29, 2015 14:15
Jekyll Gulpfile [WIP]
var gulp = require('gulp');
var fs = require('fs');
var spawn = require('child_process').spawn;
var through = require('through2');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var gutil = require('gulp-util');
var $ = require('gulp-load-plugins')();
var jshintStylish = require('jshint-stylish');
@halcarleton
halcarleton / Sort By Property
Created July 22, 2014 13:47
A function which allows you to sort an array of objects by properties of the objects.
function byProperty (prop, reverse, primer) {
if (typeof reverse === 'undefined') { reverse = false; }
if (typeof primer !== 'function') { primer = false; }
var key = primer
? function(x) {return primer(x[prop]);}
: function(x) {return x[prop];};
reverse = [1, -1][+!!reverse];
@halcarleton
halcarleton / boolean-to-integer
Last active August 29, 2015 14:00
boolean to integer shorthand
+!!true === 1;
+!!false === 0;
--------------------
true === true;
false === false;
!true === false;
!false === true;
!!true === true;
!!false === false;