Skip to content

Instantly share code, notes, and snippets.

@pizzarob
pizzarob / MongooseSingletonModel.js
Last active December 4, 2017 17:48
Mongoose Singleton Model
schema.statics = {
getSingleton: function (cb) {
this.findOne()
.sort({ updated: -1 })
.limit(1)
.exec((err, model) => {
if (err) {
cb(err, null);
} else if (!model) {
cb(err, new this());
@puppybits
puppybits / Dockerfile
Last active June 12, 2017 17:37
<10s Docker/NPM build & develop from a docker container
FROM node
RUN mkdir -p /app
WORKDIR /app
# .deps.json will only bust the cache when the package.json dependencies change
COPY .deps.json /app/package.json
RUN npm install
# cache will almost always bust here, but it's only copying files
@lgg
lgg / run_letsencrypt
Created January 10, 2016 05:16
Let's encrypt auto authenticator runner for multiply domains
#!/bin/bash
#Vars
web_service='nginx'
config_path='/usr/local/letssl/'
le_path='/opt/letsencrypt'
exp_limit=20;
#Func
function check_ssl {
@TheHeat
TheHeat / wp-admin-bump.scss
Created November 17, 2014 22:58
Mixin to include with any fixed position styles to adjust for the WordPress admin bar.
// Use wherever a fixed position is declared to adjust for that pesky WP admin bar.
@mixin wp-admin-bump{
.admin-bar & {
margin-top: 46px;
@media screen and (min-width: 782px){
margin-top: 32px;
}
}
}
@mccahill
mccahill / config.js
Last active November 18, 2021 19:00 — forked from jeffrafter/server.js
Example of a node OAuth (Twitter) and OAuth2 (Google Calendar) client that works with the version 3 Express framework. This assumes you have a config.js file holding the keys and secrets
module.exports = {
'HOSTPATH': 'http://your.host.here',
'PORT': 80,
'EXPRESS_SESSION_SECRET': '123456',
'TWITTER_CONSUMER_KEY': 'your-consumer-key-here',
'TWITTER_CONSUMER_SECRET': 'your-secret-here',
'GOOGLE_APP_ID': 'your-app-id-here',
'GOOGLE_CONSUMER_SECRET': 'your-consumer-secret-here',
};
@r10r
r10r / enable_dnsmasq_on_osx.sh
Last active October 11, 2019 04:27
Installs and configures dnsmasq on osx (for local resolution of development machines e.g virtualbox). Cudos to Alan Ivey http://www.echoditto.com/blog/never-touch-your-local-etchosts-file-os-x-again
# ----------------------
# installing dnsmasq and enable daemon
# ----------------------
brew install dnsmasq
sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
# ----------------------
# adding resolver for vbox domain
# ----------------------
[ -d /etc/resolver ] || sudo mkdir -v /etc/resolver
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/vbox'