Skip to content

Instantly share code, notes, and snippets.

View halhenke's full-sized avatar
:octocat:
Segge Fallt

Hal Henke halhenke

:octocat:
Segge Fallt
View GitHub Profile
# Print Git commit statistics for a specific author
# Usage: git-stats "Linus Torvalds"
git-stats() {
author=${1-`git config --get user.name`}
echo "Commit stats for \033[1;37m$author\033[0m:"
git log --shortstat --author $author -i 2> /dev/null \
| grep -E 'files? changed' \
| awk 'BEGIN{commits=0;inserted=0;deleted=0} \
{commits+=1; if($5!~"^insertion") { deleted+=$4 } \
@halhenke
halhenke / nodeURLDeploy
Created December 9, 2014 08:38
Simple code deploy by visiting a URL with connect-githubhook module
var express = require('express'),
cgh = require('connect-githubhook'),
sites = {'/secret-update-url': {url: 'https://github.com/user/repo',
branch: 'master'},
app = express.createServer();
var handler = function(repo, payload) {
console.log('Code change detected. Restarting now...');
setTimeout(function() {
process.exit(1);
@halhenke
halhenke / arrayWrap.coffee
Created March 23, 2015 11:24
lodash mixin for function similar to Ruby's Array.wrap
lo = require("lodash")
###
Similar to Ruby Array.wrap function
- if arg is already an array simply returns the arg
- otherwise returns argument wrapped in an Array
###
lo.mixin lo, {
arrayWrap: (val) ->
if lo.isArray(val)
@halhenke
halhenke / 0_reuse_code.js
Last active August 29, 2015 14:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@halhenke
halhenke / new_gist_file.js
Created April 3, 2015 09:04
Add to webpack.config.js when you get the error: "Module not found: Error: Cannot resolve module 'fs'" See https://github.com/webpack/jade-loader/issues/8
node: {
fs: "empty"
}
@halhenke
halhenke / .tags
Created July 2, 2015 02:04
Tags File that Killed Atom
This file has been truncated, but you can view the full file.
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 0 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.8 //
html /Users/hal.henke/code/zoo/meteor_monitor/.meteor/local/build/programs/server/assets/packages/boilerplate-generator/boilerplate_web.browser.html /^<html {{htmlAttributes}}>$/;" function line:1
head /Users/hal.henke/code/zoo/meteor_monitor/.meteor/local/build/programs/server/assets/packages/boilerplate-generator/boilerplate_web.browser.html /^<head>$/;" function line:2
script /Users/hal.henke/code/zoo/meteor_monitor/.meteor/local/build/programs/server/assets/packages/boilerplate-generator/boilerplate_web.browser.html /^<script type='text\/javascript'>__meteor_runtime_config__ = JSON.parse(decodeURIComponent({{meteorRuntimeConfig}}));<\/script>$/;" function line:6
script /Users/hal
--languages=-javascript
--langdef=js
--langmap=js:.js
--langmap=js:+.jsx
//
// Constants
//
// A constant: AAA0_123 = { or AAA0_123: {
function getComputedStyle( dom ) {
var style;
var returns = {};
// FireFox and Chrome way
if(window.getComputedStyle){
style = window.getComputedStyle(dom, null);
for(var i = 0, l = style.length; i &lt; l; i++){
var prop = style[i];
var val = style.getPropertyValue(prop);
returns[prop] = val;
@halhenke
halhenke / new_gist_file_0
Created September 8, 2015 07:44
From http://student.wordflyers.com/#/learn/grade_levels Get the maximum z-index (or potentially any style attribute on a page (uses jQuery)
(Math.max.apply(Math,
$.makeArray($('*')
.map(function () {
return $(this).css('z-index');
}).filter(function () {
return $.isNumeric(this);
}).map(function () {
return parseInt(this, 10);
}))));
@halhenke
halhenke / new_gist_file_0
Created September 10, 2015 09:04
From http://nerds.airbnb.com/github-pull-request-bookmarklet/ AirBNB Pull Request Template Bookmarklet
javascript:(function() {var e = document.getElementById('pull_request_body');if (e) {e.value += '# What? Why?\n\n\n# How was it tested?\n\n\ncc project_narhwal @mLewisLogic @clizzin @Raphomet @LogicWolfe';}})();