Skip to content

Instantly share code, notes, and snippets.

View jmervine's full-sized avatar

Joshua Mervine jmervine

View GitHub Profile
@jmervine
jmervine / function.sh
Created January 31, 2014 18:03
Simple Ruby version switcher...
# add this to your .bashrc / .zshrc / etc
if test -e ~/scripts/renv.sh; then
function chrb {
CURRENT_VERSION="$1" source ~/scripts/renv.sh
}
fi
@jmervine
jmervine / gist:8788669
Created February 3, 2014 17:46
Strip specials in BASH
# replaces numbers, commas, periods, asterisks, slashes (forward and back), all brackets and parentheses
#
# note: I'd like to get this working with less '-e' calls but it wasn't for me on
#
# $ sed --version
# GNU sed version 4.2.1
sed -r -e 's/[0-2,\.\*\\\/]/_/g' -e 's/\[/_/g' -e 's/\]/_/g' -e 's/\{/_/g' -e 's/\}/_/g' -e 's/\(/_/g' -e 's/\)/_/g' -e 's/_{2,}/_/g' -e 's/_$//'
@jmervine
jmervine / .travis.yml
Last active August 29, 2015 13:56
request -> requets-lite
language: node_js
node_js:
- 0.8
- 0.10
@jmervine
jmervine / ssl.js
Created February 17, 2014 00:19
MaxCDN working SSL cert upload.
#!/usr/bin/env node
/*********************************************************
* Example script for uploading ssl certs to maxcdn
* pull zone.
*
*
* Setup to run this script:
*
* $ npm install maxcdn http-debug
*
Server running on port 8000
-> /mervine_net
undefined:1
s%2Fheads%2Fmaster%22%2C%22after
f%22%3A%22refs%2Fheads%2Fmaster%22%2C%22after
^
// http://cdn.zoker.me/tools/tab-helper.js
$("input:text").focus(function(){
$(this).select();$(this).mouseup(function(a){
a.preventDefault();
})
});
$(window).load(function() {
var hash;
var hash_suffix='_tab';
@jmervine
jmervine / 0node-maxcdn.md
Last active August 29, 2015 13:56
MaxCDN Node.js Blog Draft

An Introduction to MaxCDN on Node.js

In addition to [MaxCDN]'s powerful [Oauth] API, they offer a number of simple modules for various languages. Here I'll be covering they're [Node.js] module.

In this post, I'll go over some basic examples of how to display reports and purge caches using the [MaxCDN Node module], which like all of [MaxCDN]'s modules, is open sourced at [github.com/MaxCDN/node-maxcdn].

If you're like me and prefer to read up on the technologies you'll be using in this post before diving in, here's what we'll be using:

  • [Node.js], "a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications"
  • [npm], "Node Packaged Modules"
'use strict';
var express = require('express');
var MaxCDN = require('maxcdn');
// Initialize maxcdn from environment.
var maxcdn = new MaxCDN(process.env.ALIAS,
process.env.KEY,
process.env.SECRET);
// For this example, I'll restrict to a single zone,
@jmervine
jmervine / Gemfile
Created February 26, 2014 06:40
Simple Web Interface to Purge Caches via MaxCDN
source "https://rubygems.org"
gem "sinatra"
gem "haml"
gem "maxcdn"
@jmervine
jmervine / 1test.js
Last active August 29, 2015 13:56
cluster
var cluster = require('cluster');
var numCPUs = require('os').cpus().length;
var results = [];
var responded = 0;
if (cluster.isMaster) {
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}