Skip to content

Instantly share code, notes, and snippets.

View gabeio's full-sized avatar

Gabe De Luca gabeio

View GitHub Profile
/*
moduble: setupDB.ls
Run this to setup the level db with arrays
*/
require! {
'levelup'
'leveldown'
'bcrypt'
}
@gabeio
gabeio / amazon.js
Last active August 29, 2015 14:14
My Browser, Website Mods
window.location.href = window.location.href.split('www.amazon.com')[0]+"smile.amazon.com"+window.location.href.split('www.amazon.com')[1];
@gabeio
gabeio / makeapp.sh
Last active August 29, 2015 14:14 — forked from demonbane/makeapp.sh
#!/bin/sh
echo "What should the Application be called (no spaces allowed e.g. GCal)?"
read inputline
name="$inputline"
echo "What is the url (e.g. https://www.google.com/calendar/render)?"
read inputline
url="$inputline"
@gabeio
gabeio / gulpfile.js
Created February 7, 2015 20:17
yo-no-say
var del, gulp, gulpMocha, gulpLivescript, livescript, paths;
del = require('del');
gulp = require('gulp');
gulpMocha = require('gulp-mocha');
gulpLivescript = require('gulp-livescript');
livescript = gulpLivescript != null ? gulpLivescript : void 8;
paths = [
{
scripts: './src/*.ls',
tests: './test/*.ls'

I've developed a useful feature in KeystoneJS that lets you populate a relationship from either side, while only storing the data on one side, and am looking for feedback on whether it is something that could / should be brought back into mongoose itself. (It might be possible to add as a separate package but I suspect there'd be too much rewriting of mongoose internals for that to be a good idea).

I've added this as an issue in mongoose for consideration: #1888 but am leaving this gist in place because the examples are easier to read.

I've used Posts and Categories as a basic, contrived example to demonstrate what I'm talking about here; in reality you'd rarely load all the posts for a category but there are other real world cases where it's less unreasonable you'd want to do this, and Posts + Categories is an easy way to demo it.

The problem

The built-in population feature is really useful; not just for

@gabeio
gabeio / install
Created February 27, 2015 18:20
brew.sh
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby
# This script installs to /usr/local only. To install elsewhere you can just
# untar https://github.com/Homebrew/homebrew/tarball/master anywhere you like or
# change the value of HOMEBREW_PREFIX.
HOMEBREW_PREFIX = '/usr/local'
HOMEBREW_CACHE = '/Library/Caches/Homebrew'
HOMEBREW_REPO = 'https://github.com/Homebrew/homebrew'
module Tty extend self
def blue; bold 34; end
@gabeio
gabeio / .vimrc
Last active March 1, 2016 22:02
my vim settings
set nocompatible
execute pathogen#infect()
syntax on
set backspace=2
set ignorecase
set smartcase
set autoindent
set noexpandtab
set tabstop=4
set shiftwidth=4
@gabeio
gabeio / nginx.conf
Created April 24, 2015 18:22
nginx
X-Forwarded-Protocol: https
X-Forwarded-Ssl: on
X-Url-Scheme: https
X-Forwarded-Proto: https
Front-End-Https: on
X-FORWARDED-PROTOCOL: https
@gabeio
gabeio / generator.ls
Created June 26, 2015 03:09
random generator in livescript
lower = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
upper = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
num = ["0","1","2","3","4","5","6","7","8","9"]
alphanum = lower ++ upper ++ num
newpass = []
for x from 1 to 7 # change 7 to length of password you want
index = Math.floor alphanum.length * Math.random()
newpass.push alphanum[index]
console.log newpass.join ''
@gabeio
gabeio / bash
Created July 17, 2015 04:35
listen to ports
sudo tcpflow -p -c -i eth0 port 8010