Skip to content

Instantly share code, notes, and snippets.

View gabeio's full-sized avatar

Gabe De Luca gabeio

View GitHub Profile
@gabeio
gabeio / peek-a-boo-button.php
Created December 16, 2015 06:52
a button that is only available to poke at certain times
<?php
$timez = time();
// $timez = strtotime('Monday, December 21st 9:20am');
if( (date("l",$timez)=="Monday" || date("l",$timez)=="Wednesday") && ( intval(date("Hi",$timez)) > intval("930") && intval(date("Hi",$timez))<intval("1045") ) ){
?>
<button>hello I am here!</button>
<?php
}else{
?>
sorry this is not a pre-approved time
@gabeio
gabeio / .vimrc
Last active December 23, 2017 06:03
Default Vim Settings
syntax on
"execute pathogen#infect() "optional
set nocompatible
set backspace=2
set ignorecase
set smartcase
set autoindent
set number "show line numbers
set ruler "show ruler
set relativenumber "show relative line numbers
@gabeio
gabeio / regex
Created October 26, 2015 14:56
find ,'s that are too squished
,(?![\ ||\n])
@gabeio
gabeio / lissome-intro.md
Last active August 29, 2015 14:26
lissome-intro

HI

and welcome to lissome. I hope you like how simple it is to use! If you have any suggestions for lissome please leave me a note over here

@gabeio
gabeio / bash
Created July 17, 2015 04:35
listen to ports
sudo tcpflow -p -c -i eth0 port 8010
@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 / 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 / .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 / 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

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