Skip to content

Instantly share code, notes, and snippets.

@loopmode
loopmode / jsbeautifier-es6-hacks
Last active July 12, 2016 13:25
Some (ugly!) hacks to fix es6/es7 formatting problems in jsbeautifier. I use it with the "html/css/js prettify" plugin for Sublime Text
// in Sublime Text, Preferences -> Browse Packages, find HTML-CSS-JS Prettify/scripts/node_modules/js-beautify/js/lib/beautify.js
// find the last line of the 'beautify' function, and place the next lines just before 'return sweet_code';
// https://gist.github.com/loopmode/d091bce3b76efaf15d63
// es7 decorators
sweet_code = sweet_code.replace(/@\n/g, '@');
sweet_code = sweet_code.replace(/\)@\s/g, ')\n@');
sweet_code = sweet_code.replace(/ @ /g, ' @');
sweet_code = sweet_code.replace(/@\s/g, '\n@');
sweet_code = sweet_code.replace(/\];@/g, '];\n@');
@brennanMKE
brennanMKE / .bash_profile
Last active June 20, 2018 23:12
Open in Visual Studio Code
# Add the alias below to ~/.bash_profile on a Mac
# Save the file and run: source ~/.bash_profile
alias code='open $@ -a "Visual Studio Code"'
@wilsonwc
wilsonwc / stateMock.js
Created January 10, 2014 17:24
Angular Mock for properly resolving ui-router $state in Karma unit tests
angular.module('stateMock',[]);
angular.module('stateMock').service("$state", function($q){
this.expectedTransitions = [];
this.transitionTo = function(stateName){
if(this.expectedTransitions.length > 0){
var expectedState = this.expectedTransitions.shift();
if(expectedState !== stateName){
throw Error("Expected transition to state: " + expectedState + " but transitioned to " + stateName );
}
}else{
@stefanjudis
stefanjudis / detailedMetrics.js
Created November 10, 2013 14:39
Chrome snippet to show performance of document
javascript:( function() {
console.group( 'Performance Information for all entries of ' + window.location.href );
console.log( '\n-> Duration is displayed in ms\n ' )
var entries = window.performance.getEntries();
entries = entries.sort( function( a, b ) {
return b.duration - a.duration;
} );
@justinklemm
justinklemm / orderObjectBy.html
Last active December 23, 2015 10:49
AngularJS Filter for Ordering Objects (Associative Arrays or Hashes) with ngRepeat
<ul>
<li ng-repeat="item in items | orderObjectBy:'color':true">{{ item.color }}</li>
</ul>
@fightingtheboss
fightingtheboss / haproxy.cfg
Created June 23, 2013 01:17
HAProxy configuration file for deploying Meteor application to private VPN. Fronted by nginx for static assets, backed by multiple app instances. See https://gist.github.com/fightingtheboss/5843323 for Nginx setup.
global
daemon
defaults
mode http
timeout connect 86400000
timeout server 86400000
timeout client 86400000
timeout check 5s
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"