Skip to content

Instantly share code, notes, and snippets.

@tmurphree
tmurphree / deployLambda.sh
Created December 2, 2020 16:01
AWS Lambda zip deployment bash script
#!/bin/bash
FILE_PATH="tmp/lambdaDeployment.zip";
FUNCTION_NAME="tm-test";
rm -f $FILE_PATH;
# make zip with with a whitelist
zip -r $FILE_PATH . -i package*.json "src/*" "node_modules/*";
@tmurphree
tmurphree / docker-compose.yaml
Last active November 12, 2020 21:00
docker-compose file for postgres with a volume mapped to localhost
version: '3.8'
# see https://hub.docker.com/_/postgres for information on the environment variables
services:
database:
image: postgres:13.0-alpine
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: example
@tmurphree
tmurphree / docker-compose.yaml
Created February 28, 2020 04:06
docker-compose file for elasticsearch with kibana
# elasticsearch will be available on http://localhost:9200
# kibana will be available on http://localhost:5601
version: '3.7'
services:
elasticsearchnode01:
environment:
# Use single node discovery in order to disable production mode and avoid bootstrap checks
# see https://www.elastic.co/guide/en/elasticsearch/reference/current/bootstrap-checks.html
discovery.type: single-node
@tmurphree
tmurphree / docker-rm-images.md
Last active January 10, 2019 20:33 — forked from alferov/docker-rm-images.md
Remove all (untagged) images and containers from Docker

Clean up the whole mess

docker system prune

For the rest, syntax is:

  • bash
  • PowerShell

Delete all containers

docker rm $(docker ps -aq)

@tmurphree
tmurphree / Include-in-Sequelize.md
Created November 13, 2018 14:53 — forked from zcaceres/Include-in-Sequelize.md
using Include in sequelize

'Include' in Sequelize: The One Confusing Query That You Should Memorize

When querying your database in Sequelize, you'll often want data associated with a particular model which isn't in the model's table directly. This data is usually typically associated through join tables (e.g. a 'hasMany' or 'belongsToMany' association), or a foreign key (e.g. a 'hasOne' or 'belongsTo' association).

When you query, you'll receive just the rows you've looked for. With eager loading, you'll also get any associated data. For some reason, I can never remember the proper way to do eager loading when writing my Sequelize queries. I've seen others struggle with the same thing.

Eager loading is confusing because the 'include' that is uses has unfamiliar fields is set in an array rather than just an object.

So let's go through the one query that's worth memorizing to handle your eager loading.

The Basic Query

@tmurphree
tmurphree / curl.md
Created May 17, 2018 14:39 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

That’s one of the real strengths of Docker: the ability to go back to a previous commit. The secret is simply to docker tag the image you want.
Here’s an example. In this example, I first installed ping, then committed, then installed curl, and committed that. Then I rolled back the image to contain only ping:
$ docker history imagename
IMAGE CREATED CREATED BY SIZE
f770fc671f11 12 seconds ago apt-get install -y curl 21.3 MB
28445c70c2b3 39 seconds ago apt-get install ping 11.57 MB
8dbd9e392a96 7 months ago 131.5 MB
@tmurphree
tmurphree / Docker shell commands.sh
Created December 2, 2017 05:01 — forked from bahmutov/Docker shell commands.sh
A personal cheat sheet for running local Node project in a Docker container
# See list of docker virtual machines on the local box
$ docker-machine ls
NAME ACTIVE URL STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.100:2376 v1.9.1
# Note the host URL 192.168.99.100 - it will be used later!
# Build an image from current folder under given image name
$ docker build -t gleb/demo-app .
@tmurphree
tmurphree / encrypt_decrypt_example.js
Created November 1, 2017 16:32 — forked from erans/encrypt_decrypt_example.js
Example of encryption and decryption in node.js
var crypto = require("crypto")
function encrypt(key, data) {
var cipher = crypto.createCipher('aes-256-cbc', key);
var crypted = cipher.update(text, 'utf-8', 'hex');
crypted += cipher.final('hex');
return crypted;
}
@tmurphree
tmurphree / jasmine-this-vars.md
Created September 27, 2017 20:56 — forked from traviskaufman/jasmine-this-vars.md
Better Jasmine Tests With `this`

Better Jasmine Tests With this

On the Refinery29 Mobile Web Team, codenamed "Bicycle", all of our unit tests are written using Jasmine, an awesome BDD library written by Pivotal Labs. We recently switched how we set up data for tests from declaring and assigning to closures, to assigning properties to each test case's this object, and we've seen some awesome benefits from doing such.

The old way

Up until recently, a typical unit test for us looked something like this:

describe('views.Card', function() {