Skip to content

Instantly share code, notes, and snippets.

Michael Jackson majgis

Block or report user

Report or block majgis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@majgis
majgis / .zshrc
Last active May 31, 2018
docker run helper function
View .zshrc
# Execute docker run with --rm --network shared
# The shared network will be created if it dosn't already exist
dr () {
docker network inspect shared > /dev/null 2>&1
if [ $? -ne 0 ]
then
docker network create shared > /dev/null 2>&1
fi
local DOCKER_CMD="docker run --rm --network shared $@"
echo
@majgis
majgis / .zshrc
Last active Dec 6, 2018
automatically call nvm use if .nvmrc is present
View .zshrc
# Taken from here:
# https://github.com/creationix/nvm#zsh
# place this after nvm initialization!
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
View CodeChallenge.js
// var depPairs = [
// "KittenService: ",
// "Leetmeme: Cyberportal",
// "Cyberportal: Ice",
// "CamelCaser: KittenService",
// "Fraudstream: Leetmeme",
// "Ice: "
// ];
//
// Turn that into: `'KittenService, Ice, Cyberportal, Leetmeme, CamelCaser, Fraudstream'`
View storedTemplate.js
const storedTemplate = (a,b,c) => `a:${a}, b:${b}, c:${c}`
storedTemplate(1,2,3)
@majgis
majgis / run.js
Last active Aug 29, 2015
Browserify - expose
View run.js
var fs = require( 'fs' );
var b = require( 'browserify' )();
var outputFile = fs.createWriteStream( './output.js' );
b.add( './index.js' );
b.require( './test.js', {expose: 't'} );
b.bundle().pipe( outputFile );
@majgis
majgis / gulpfile.js
Created Nov 23, 2014
find protractor selenium jar
View gulpfile.js
var gulp = require('gulp');
var lib = require('./lib');
var protractor = require("gulp-protractor").protractor;
var jarPath = lib.getProtractorSeleniumJarPath();
gulp.task('default', function(){
gulp.src(["./spec/*.js"])
.pipe(protractor({
configFile: "protractor.config.js",
@majgis
majgis / gist:9680084
Last active Aug 29, 2015
Rough Node.js Hierarchical Queue
View gist:9680084
var http = require('http');
function RequestQueue() {
this._maxRequests = 3;
this._pendingCount = 0;
this._queue = [];
this.count = 0;
this._uriInQueue = {};
}
View gist:9558866
#-- Start pm-ops-utils dev --#
# Remove local modules and npm cache
alias npmPurge="
rm -rf node_modules
npm cache clean
"
# Ugly, but it is a fail-safe way of generating npm-shrinkwrap.json
alias updateShrinkwrap="
@majgis
majgis / collection.py
Last active Dec 17, 2015
A defaultnamedtuple which creates a namedtuple with default values when none are given.
View collection.py
""" Additional collections to augment Python's collections module.
"""
from collections import namedtuple
def defaultnamedtuple(
typename,
field_names,
verbose=False,
rename=False,
@majgis
majgis / interview.py
Last active Dec 16, 2015
Answer to an interview question.
View interview.py
""" Interview question
Write a method that takes a string, and returns the string in reverse.
For instance, if passed abc123 it should return 321cba
"""
class StringUtil(object):
""" Utility for strings
You can’t perform that action at this time.