Skip to content

Instantly share code, notes, and snippets.

View lukeandersen's full-sized avatar
👨‍💻

Luke Andersen lukeandersen

👨‍💻
View GitHub Profile
@lukeandersen
lukeandersen / dockerFix.sh
Last active March 16, 2020 22:59
Docker port already in use fix
docker stop $(docker ps -a -q); docker rm $(docker ps -a -q); docker volume rm $(docker volume ls -qf dangling=true)
@lukeandersen
lukeandersen / index.js
Last active March 4, 2020 02:57
Mongoose Multi Tenant
import mongoose from 'mongoose'
import schema from './schema'
const User = (namespace) => {
const db = mongoose.connection.useDb(namespace, { useCache: true })
// Add any schema plugins here
return db.model('user', schema)
}
async function get(req, res) {
@lukeandersen
lukeandersen / Dockerfile
Last active March 16, 2020 22:58
Dockerfile
FROM node:8.15-alpine
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.5.0/wait /wait
RUN chmod +x /wait
RUN mkdir -p /src/app
WORKDIR /src/app
COPY package.json /src/package.json
COPY .npmrc /src/.npmrc
RUN npm install
@lukeandersen
lukeandersen / docker-compose.yml
Last active March 14, 2019 12:18
Basic docker compose for a local Node and Mongo app
version: "3"
services:
app:
container_name: this-app
restart: always
build: ../path-to-this-app/
volumes:
- .:/src/app
- /src/app/node_modules
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@lukeandersen
lukeandersen / numbersOnly.js
Created August 8, 2016 04:33
Numbers only in text input - Angular directive
'use strict';
angular.module('myApp').directive('numbersOnly', function () {
return {
restrict: 'A',
require: 'ngModel',
scope: {
options: '=numbersOnly'
},
link: function (scope, element, attrs, ngModel) {
@lukeandersen
lukeandersen / npm-scripts.js
Created August 7, 2016 23:44
Useful React Native NPM Scripts
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"rc-start": "npm start -- --reset-cache",
"clean": "rm -rf $TMPDIR/react-* && watchman watch-del-all && npm cache clean",
"clean-start": "npm run clean && npm run rc-start",
"fresh-install": "rm -rf $TMPDIR/react-* && watchman watch-del-all && rm -rf ios/build/ModuleCache/* && rm -rf node_modules/ && npm cache clean && npm install",
"fresh-start" : "npm run fresh-install && npm run rc-start",
"tron": "node_modules/.bin/reactotron"
}
$.ajax({
type: "GET",
dataType: "jsonp",
cache: false,
url: "https://api.instagram.com/v1/users/140572/media/recent/?access_token=6277169.76495e2.ac7aa5ca54094298b10f8b6a527a9ec3", // Get user images
// Get user iD - http://instagram-uid.herokuapp.com/
// "https://api.instagram.com/v1/tags/catwalk/media/recent?client_id=6277169&access_token=6277169.76495e2.ac7aa5ca54094298b10f8b6a527a9ec3", // Get Tagged images
success: function(data) {
for (var i = 0; i < 9; i++) {
$("#instagram").append("<li><a target='_blank' rel='lightbox' href='" + data.data[i].images.standard_resolution.url + "'><img src='" + data.data[i].images.low_resolution.url +"'></img></a></li>");
@lukeandersen
lukeandersen / Exists plugin jQuery
Created August 12, 2014 13:00
Exists plugin jQuery
$.fn.exists = function () {
return this.length !== 0;
}
// usage
$('.my-item').exists();
// Switch img src for large displays
$('.rs-img').each(function() {
var baseWidth = 1140;
// get current width
var lgeScrn = $(window).innerWidth();
// activate if width is less than base width