Skip to content

Instantly share code, notes, and snippets.

@tmurphree
tmurphree / mongoose-cheatsheet.md
Last active April 17, 2024 18:50 — forked from subfuzion/mongoose-cheatsheet.md
mongoose cheatsheet

Definitely not comprehensive. This is meant to be a basic memory aid with links to get more details. I'll add to it over time.

Install

$ npm install mongoose --save

Connect

const mongoose = require('mongoose');

const connectionString = process.env.MONGO_URI || 'mongodb://localhost/databasenamegoeshere';

@tmurphree
tmurphree / postgres-cheatsheet.md
Last active October 31, 2016 21:29 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PostgreSQL

Links

Selected Commands

Command Description Link
@tmurphree
tmurphree / restful_routes.md
Created October 31, 2016 17:27 — forked from alexpchin/restful_routes.md
7 Restful Routes
URL HTTP Verb Action
/photos/ GET index
/photos/new GET new
/photos POST create
/photos/:id GET show
/photos/:id/edit GET edit
/photos/:id PATCH/PUT update
/photos/:id DELETE destroy
@tmurphree
tmurphree / docker.md
Last active April 21, 2017 16:51
Docker

DockerMoby Cheat Sheet

Content started from wsargent's github.

A Tasteful Plug for Lightbend

I work for Lightbend on the Play team. I think the company is awesome, and if you're looking at containers because you're moving to the cloud and thinking about distributed systems, you should keep reading.

Lightbend make microservices happen. Developers use Lagom to put together resilient ("chaos monkey resistant") microservices. In production, there's Conductr to orchestrate containers -- including Docker. Finally, there's monitoring to tell you wha

@tmurphree
tmurphree / npm-reference.md
Last active September 11, 2017 03:22
npm-reference

NPM reference

List global libraries

npm list -g --depth=0

Remove global libraries

npm uninstall -g \

@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() {
@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 / 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 .
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 / 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.