Skip to content

Instantly share code, notes, and snippets.

Hal Carleton halcarleton

Block or report user

Report or block halcarleton

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View git-prune-tracking-branches.md
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
View .eslintrc.react.json
{
"plugins": [
"react"
],
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"jsx": true,
"experimentalObjectRestSpread": true
},
@halcarleton
halcarleton / .eslintrc.node.json
Last active Dec 14, 2016
ESLint config file for node
View .eslintrc.node.json
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "script"
},
"parser": "espree",
"env": {
"node": true,
"es6": true
},
@halcarleton
halcarleton / SuperConstructor.js
Last active Oct 17, 2016
Super Constructor Pattern for future reference
View SuperConstructor.js
// 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 / callNew.js
Last active Dec 6, 2016
call/apply with `new` operator
View callNew.js
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 / Jekyll-Gulpfile.js
Last active Aug 29, 2015
Jekyll Gulpfile [WIP]
View Jekyll-Gulpfile.js
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 Jul 22, 2014
A function which allows you to sort an array of objects by properties of the objects.
View Sort By Property
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 Aug 29, 2015
boolean to integer shorthand
View boolean-to-integer
+!!true === 1;
+!!false === 0;
--------------------
true === true;
false === false;
!true === false;
!false === true;
!!true === true;
!!false === false;
@halcarleton
halcarleton / SublimeText-Project-Line-Count
Last active Nov 15, 2019 — forked from Hexodus/count_total_project_code_lines_in_sublime
Count total lines of code in a Sublime Text Project or Directory
View SublimeText-Project-Line-Count
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
You can’t perform that action at this time.