Skip to content

Instantly share code, notes, and snippets.

View pxwise's full-sized avatar
🌎
[object Object], NaN

Shawn Stedman pxwise

🌎
[object Object], NaN
View GitHub Profile
@pxwise
pxwise / experimental-tag-generator.sh
Created October 21, 2022 21:07
Experimental tag generator
# Print a tag name conforming to the React experimental guidelines
# https://reactjs.org/docs/release-channels.html#experimental-channel
echo "0.0.0-experimental-$(git rev-parse HEAD | cut -c1-9)-$(date +'%Y%m%d')"
@pxwise
pxwise / yarn-prune.js
Last active January 30, 2019 08:11
Approximate `npm prune --production` using `yarn remove`
/**
* 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;
@pxwise
pxwise / async-ng-module-loader.ts
Created November 7, 2016 00:57 — forked from brandonroberts/async-ng-module-loader.ts
Webpack Async NgModule Loader
import {Injectable, NgModuleFactory, NgModuleFactoryLoader, Compiler, Type} from '@angular/core';
class LoaderCallback {
constructor(public callback) {}
}
export let load: Type = (callback: Function) => {
return new LoaderCallback(callback);
};
/**
* 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 April 25, 2024 06:20
HTML5 pushState nginx configuration
# 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 August 29, 2015 14:20
Casperjs bind polyfill
/**
* 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 March 31, 2015 00:06
vanilla js query string parser
// 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 August 29, 2015 14:08
Utility to count watchers in an AngularJS app. The higher the number of watchers, the slower your app will run.
/**
* 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 August 29, 2015 14:04
Percona Configuration for Drupal 7
[mysql]
# CLIENT #
port = 3306
[mysqld]
# GENERAL #
user = mysql
@pxwise
pxwise / nginx.conf
Last active August 29, 2015 14:04
Nginx Configuration for Drupal 7
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;