Skip to content

Instantly share code, notes, and snippets.

Avatar
👽
[object Object], NaN

Shawn Stedman pxwise

👽
[object Object], NaN
View GitHub Profile
@pxwise
pxwise / yarn-prune.js
Last active Jan 30, 2019
Approximate `npm prune --production` using `yarn remove`
View yarn-prune.js
/**
* Approximate `npm prune --production` using `yarn remove`.
* @see https://github.com/yarnpkg/yarn/issues/696
*/
const exec = require('child_process').exec;
const devDependencies = Object.keys(require('./package.json').devDependencies).join(' ');
const command = 'yarn remove ' + devDependencies;
const child = exec(command, (err, stdout, stderr) => {
if (err) throw err;
View async-ng-module-loader.ts
import {Injectable, NgModuleFactory, NgModuleFactoryLoader, Compiler, Type} from '@angular/core';
class LoaderCallback {
constructor(public callback) {}
}
export let load: Type = (callback: Function) => {
return new LoaderCallback(callback);
};
View lite-touch-event-converter.js
/**
* Lightweight script to convert touch handlers to mouse handlers
* credit: http://stackoverflow.com/a/6141093
*/
(function() {
function touchHandler(e) {
var touches = e.changedTouches;
var first = touches[0];
var type = "";
@pxwise
pxwise / nginx.conf
Last active Sep 25, 2019
HTML5 pushState nginx configuration
View nginx.conf
# HTML5 pushState nginx configuration
#
# @see: http://stackoverflow.com/a/30515169/1774183
#
# Server block for a client side app with directories:
#
# /
# /foo
# /foo/bar
# /foo/bar/baz
@pxwise
pxwise / gist:69a67f504249746718b7
Last active Aug 29, 2015
Casperjs bind polyfill
View gist:69a67f504249746718b7
/**
* CasperJS .bind()
*
* Adds .bind() capability missing from PhantomJS < 2.0.0 for CasperJS.
* Needed for some types of evaluations on the remote page as well as
* screenshots.
*/
casper.on('page.initialized', function() {
casper.evaluate(function() {
var isFunction = function(o) {
@pxwise
pxwise / getQueryVariable.js
Created Mar 31, 2015
vanilla js query string parser
View getQueryVariable.js
// https://css-tricks.com/snippets/javascript/get-url-variables/
// cleaned up a bit
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] === variable) {
@pxwise
pxwise / ng-watcher-counter
Last active Aug 29, 2015
Utility to count watchers in an AngularJS app. The higher the number of watchers, the slower your app will run.
View ng-watcher-counter
/**
* Utility to count watchers in an AngularJS app.
*/
function countWatchers() {
var root = angular.element(document.getElementsByTagName('body'));
var watchers = [];
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
@pxwise
pxwise / .my.cnf
Last active Aug 29, 2015
Percona Configuration for Drupal 7
View .my.cnf
[mysql]
# CLIENT #
port = 3306
[mysqld]
# GENERAL #
user = mysql
@pxwise
pxwise / nginx.conf
Last active Aug 29, 2015
Nginx Configuration for Drupal 7
View nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;