Skip to content

Instantly share code, notes, and snippets.

@joseym
joseym / gitlias.sh
Created February 18, 2012 04:46
SSH: Git Aliases
# Git Cheats
# ===========================
alias gs="git status"
alias gl="git log --stat"
alias gap="git add -p"
alias gd="git diff"
alias gs="git status"
alias gp="git push"
@joseym
joseym / vagrantcheats.sh
Created February 18, 2012 04:47
SSH: Vagrant Aliases
# Vagrant Cheats
# ===========================
alias vup="vagrant up"
alias vh="vagrant halt"
alias vs="vagrant suspend"
alias vr="vagrant resume"
alias vrld="vagrant reload"
alias vssh="vagrant ssh"
alias vstat="vagrant status"
@joseym
joseym / sshhop.sh
Created February 18, 2012 04:50
SSH: Server Hop
Host [server 2]
ProxyCommand ssh [server1] exec nc %h %p
User [username]
@joseym
joseym / secretPrint.js
Created June 22, 2015 21:02
I needed a way to print a section of the page without any redirects or extra rendering
/**
* usage: `<button print="#elementId">Print Me Foo!</button>`
**/
angular.module('ngApp', []).directive('print', function ($location, $timeout) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
@joseym
joseym / prettyErrors.js
Created June 22, 2015 21:12
I wanted to have better error returns in my node apps, this gives a better stack trace for json responses
// Usage
var err = new Error('Hey th\'upid, you didn\'t Catch your shenanigans!');
console.log(err.toJSON());
// If run in the chrome console
// this is exceptionally usefully if debuggong locally, but stacks aren't so great in production
return {
stack: "Error: Hey th'upid, you didn't Catch your shenanigans! <anonymous>:2:13 at Object.InjectedScript._evaluateOn (<anonymous>:895:140) at Object.InjectedScript._evaluateAndWrap (<anonymous>:828:34)at Object.InjectedScript.evaluate (<anonymous>:694:21)",
message: "Hey th'upid, you didn't Catch your shenanigans!"
}
@joseym
joseym / phantomjs-waitFor.js
Last active May 26, 2017 21:48
waitFor port for `phantomjs-node`
var async = require('async');
module.exports = waitFor;
/**
* waitFor port used with
* @see {@link https://github.com/ariya/phantomjs/blob/master/examples/waitfor.js}
* @see {@link https://github.com/sgentle/phantomjs-node}
* @callback testFx - Test function, will repeat until true or timeout limit is reached
* @callback onReady - Fires if/when `testFx` passes.
@joseym
joseym / npm-cheat-sheet.md
Created August 12, 2016 16:51 — forked from AvnerCohen/npm-cheat-sheet.md
Node.js - npm Cheat Sheet

Node.js - npm Cheat Sheet

(Full description and list of commands at - https://npmjs.org/doc/index.html)

##List of less common (however useful) NPM commands

######Prepand ./bin to your $PATH Make sure to export your local $PATH and prepand relative ./node_modules/.bin/:

@joseym
joseym / mixin.js
Last active March 23, 2017 18:06
One method to add as many mixins as you'd like to your NodeJS Classes
// Items we'd like to have mixed into our class
const { EventEmitter } = require('events');
const { Writable } = require('stream');
// ... moar
// Create the mixin mixer, we'll extend this. always.
const Mixin = (...args) => {
// Parent class, this constant needs to return a constructor
// so we'll have the constructor map all of our classes into it
return class Mixin {
[Container] 2018/10/05 16:39:06 Waiting for agent ping
[Container] 2018/10/05 16:39:06 Waiting for DOWNLOAD_SOURCE
[Container] 2018/10/05 16:39:14 Phase is DOWNLOAD_SOURCE
[Container] 2018/10/05 16:39:14 CODEBUILD_SRC_DIR=/codebuild/output/src423135217/src/github.com/ScoutGroup/fdc_backend
[Container] 2018/10/05 16:39:14 YAML location is /codebuild/output/src423135217/src/github.com/ScoutGroup/fdc_backend/buildspec.yml
[Container] 2018/10/05 16:39:14 Processing environment variables
[Container] 2018/10/05 16:39:14 Moving to directory /codebuild/output/src423135217/src/github.com/ScoutGroup/fdc_backend
[Container] 2018/10/05 16:39:14 Registering with agent
[Container] 2018/10/05 16:39:14 Phases found in YAML: 3
[Container] 2018/10/05 16:39:14 BUILD: 3 commands
@joseym
joseym / dbUtility.ts
Created January 21, 2019 20:54
TypeORM DB Connection Stubs
import * as typeorm from 'typeorm';
import { AlreadyHasActiveConnectionError } from 'typeorm/error/AlreadyHasActiveConnectionError';
import { Driver } from 'typeorm/driver/Driver';
import { DriverFactory } from 'typeorm/driver/DriverFactory';
import { PostgresDriver } from 'typeorm/driver/postgres/PostgresDriver';
import { stub } from 'sinon';
// Load all of my entities from the index
import * as entities from './../../src/entity'