Skip to content

Instantly share code, notes, and snippets.

View chriswitko's full-sized avatar

Chris Witko chriswitko

View GitHub Profile

Sample PHP+Mongo app on Heroku

  1. Install any of the Mongo add-ons available at http://addons.heroku.com

  2. Vendor the Mongo driver with your application. You can download it here:

    https://github.com/wuputah/heroku-libraries/raw/master/php/mongo/mongo.so
    

    Add it to a folder like "ext".

@donut
donut / getBGImgURLsFromCSSs.js
Created October 17, 2011 21:08
Builds a list of images found in the linked style sheets
/* Builds a list of images found in the linked style sheets
*
* Adapted from stackoverflow.com/questions/2430503/list-of-all-background-images-in-dom/2453880#2453880
*
* This method has the advantage of finding URLs for background images that no
* element in the DOM uses yet.
*
* @return {array}
* List of unique image URLs as specified in the style sheets.
------------------------------------------------------------------------- */
@elidupuis
elidupuis / handlebars-helpers.js
Last active December 7, 2021 02:24
Simple Handlebars.js helpers
/*! ******************************
Handlebars helpers
*******************************/
// debug helper
// usage: {{debug}} or {{debug someValue}}
// from: @commondream (http://thinkvitamin.com/code/handlebars-js-part-3-tips-and-tricks/)
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
console.log("====================");
@khalsah
khalsah / deploy.sh
Created January 3, 2012 22:59
Experimental git sync & deploy hooks
#!/bin/sh
LOCAL_BRANCH="master"
LIVE_BRANCH="live"
REMOTE_NAME="deploy"
if [ "$(git symbolic-ref -q HEAD)" != "refs/heads/${LOCAL_BRANCH}" ]; then
echo "Not on ${LOCAL_BRANCH}, not deploying"
exit 1
else
@ziadoz
ziadoz / awesome-php.md
Last active May 8, 2025 07:37
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@numist
numist / irsz.js
Created January 29, 2012 06:58
dynamically resize images to fit viewport (intelligently!)
/*
* Copyright © 2012 by Scott Perry
* Released under the MIT License; its terms are at the end of this file.
*
* This file depends on:
*  jQuery (tested against 1.7.1)
* http://jquery.com/
*
* Basic logic of this file:
* + if irsz_auto is true
@wozozo
wozozo / remove-utm.user.js
Last active September 30, 2015 03:37 — forked from yudoufu/remove-utm.txt
utmのパラメータをURLから取り除くuser.js
/**
* Remove utm parameters from url
* ( Use this as bookmarklet )
*/
(function(){
var search, params, i, re;
search = location.search.replace( /^\?/, '' ).split( '&' );
params = [];
if (!search) return;
i = search.length;
var application_root = __dirname,
express = require("express"),
path = require("path"),
mongoose = require('mongoose');
var app = express.createServer();
// database
mongoose.connect('mongodb://localhost/ecomm_database');
@oodavid
oodavid / README.md
Last active November 5, 2025 05:24 — forked from aronwoost/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@rizkyabdilah
rizkyabdilah / query_array_legth_mongodb.js
Created February 16, 2012 11:33
use $where in mongodb to get query length of array, because query $size not support $gt, $lt, $lte and $gte
db.test.insert({'name': 'rizky', 'abilities': ['eat', 'sleep', 'code']});
db.test.insert({'name': 'abdilah', 'abilities': ['drink']});
db.test.insert({'name': 'median', 'abilities': null});
condition_have_ability_more_than_2 = function(){
return typeof(this.abilities) == "object" && this.abilities != null && this.abilities.length > 2;
}
// peoples have abilities more_than_2
db.test.find(condition_have_ability_more_than_2);