Skip to content

Instantly share code, notes, and snippets.

View gerrard00's full-sized avatar

Gerrard Lindsay gerrard00

  • NYC
View GitHub Profile
@gerrard00
gerrard00 / NodeLamdaDockerfile
Created February 22, 2017 16:50
Dockerfile for running a container that can be used to test AWS Lambda functions written in node
FROM amazonlinux
RUN curl -O https://nodejs.org/dist/v4.3.0/node-v4.3.0-linux-x64.tar.gz
RUN tar --strip-components 1 -xzvf node-v* -C /usr/local
RUN rm node-v4.3.0-linux-x64.tar.gz
CMD ["/bin/bash"]
@gerrard00
gerrard00 / javascript-queue.js
Created January 31, 2017 13:59
Simple javascript queue implementation for several test projects.
'use strict';
function Queue() {
return {
entries: [],
enqueue(value) {
this.entries.push(value);
},
dequeue() {
return this.entries.shift();
@gerrard00
gerrard00 / questionResponse.json
Last active December 9, 2016 15:46 — forked from wallyuva/questionResponse.json
Question Response Sample
{
question: {
questionId: '',
response: [
// HISTORICAL
{
score: ''
answerId: ''
},
{
@gerrard00
gerrard00 / sort-strings-backwards.js
Last active August 28, 2016 16:56
Sort an array of strings backwards in js...I don't know why
// an array of strings mangled with this function will sort
// backwards. You can then mangle them again after the sorting
// to get your original words. of course, you could just do sort().reverse(), but
// I was curious. So, completely useless.
const maxUnicodeValue = 0x10FFFF;
function invertString(input) {
let result = '';
for(let c of input) {
const oldCode = c.codePointAt(0);
@gerrard00
gerrard00 / pgsl_execfile.sh
Created August 11, 2016 18:50
Show postgresql query results in terminal with a nicer format than psql
pgsql_execfile () {
clear
echo "\n"
tmpfile="$(mktemp).html"
nodemon --exec "psql -U postgres -h localhost -p 5433 -d $1 -f $2 --html -- > $tmpfile && w3m -dump $tmpfile && echo " $2
}
@gerrard00
gerrard00 / fib.c
Created August 4, 2016 17:12
Fib in c
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
unsigned long int fib(unsigned long int x);
char *ptr;
unsigned long int input = strtoul(argv[1], &ptr, 10);
unsigned long int result = fib(input);
printf("result: %lu\n", result);
@gerrard00
gerrard00 / pwdx_and_portpwdx_for_mac.bash
Last active November 1, 2018 10:11 — forked from tobym/pwdx_for_mac.bash
pwdx for mac. Usage: pwx pid also portpwdx that finds the pwd for the process that owns a port. Usage: portpwdx port
function pwdx {
# note: NF is the number of columns, so $NF gives us the last column
lsof -a -p $1 -d cwd -n | tail -1 | awk '{print $1, "\t", $NF}'
}
function portpwdx {
# pid=$(lsof -i :5858 | tail -1 | perl -pe 's/[^\s]+\s+([^\s]+)\s.*/$1/')
pid=$(lsof -i :$1 | tail -1 | perl -pe 's/[^\s]+\s+([^\s]+)\s.*/$1/')
if [[ ! -z $pid ]]; then
echo $pid
@gerrard00
gerrard00 / fun-with-arguments.js
Last active June 12, 2016 00:18
A little javascript test for rotating arguments
const delimiterMap = {
'[': ']',
'(': ')',
'<': '>',
};
function getArgumentsArray(input) {
let current = '';
const result = [];
let delimiterEnd;
@gerrard00
gerrard00 / Stow Check
Created February 5, 2016 16:23
A lil' zsh script to check what stow has stowed before you stow. Run it in the root of your dotfiles repo.
#! /bin/zsh
DEFAULT_WARNING="WARNING: in simulation mode so not modifying filesystem."
for folder in */; do
# for folder in */; do
echo "- ${folder}";
# capture stderr, but send stdout to /dev/tty like normal
output="$(stow -n -v ${folder} 2>&1)"