Skip to content

Instantly share code, notes, and snippets.

View jrschumacher's full-sized avatar
🤏

Ryan Schumacher jrschumacher

🤏
View GitHub Profile
@jrschumacher
jrschumacher / sub2path.pl
Created January 11, 2012 09:10
Wildcard domain for local development using Apache Mod Rewrite
#!/usr/bin/perl
###
# Sub2Path is a little script which convert a url with subdomains to a path
#
# To be used with Apache ModRewrite RewriteMap found: http://goo.gl/8WUvm
# Follow the conversation at: http://goo.gl/Mzc5E
# Props to 42foo.com: http://goo.gl/mut77
#
# MIT license
@jrschumacher
jrschumacher / test_php_skill.php
Created April 11, 2012 22:15
Test PHP Skill
<?php
/*****************************************
* Created this test for job interviews. *
*****************************************/
/**
* Directions
*
* Read the direction in the Q and respond below A.
$TTL 60
$ORIGIN dev.
@ 1D IN SOA localhost. root.localhost. (45 3H 15M 1W 1D)
1D IN NS localhost.
1D IN A 127.0.0.1
*.dev. 60 IN A 127.0.0.1
go.dev. 60 IN A 127.0.0.1
*.go.dev. 60 IN A 127.0.0.1
@jrschumacher
jrschumacher / MongoId2.php
Created December 5, 2012 17:48
MongoId to handle psudo MongoId objects (especially when dealing with json)
<?php
class MongoId2 extends MongoId {
public function __construct($id = null) {
if(is_array($id)) {
$id = (object) $id;
}
if(is_object($id) && isset($id->{'$id'})) {
$id = $id->{'$id'};
}
@jrschumacher
jrschumacher / MongoQueryStr.php
Created September 1, 2013 05:44
Convert a PHP Mongo query with Mongo* classes to MongoDB js query. Currently supports MongoId => ObjectId, MongoDate => ISODate, and MongoRegex => RegExp. [VERY ROUGH] -- Wrote this because I was tired of getting stuck and having to port the query by hand.
<?php
class MongoQueryStr {
protected static $indent = 0;
public static function convert($query) {
if(!is_array($query)) {
return false;
}
@jrschumacher
jrschumacher / headjs.min.js.cached
Created November 14, 2013 19:18
HeadJS v0.99 diff
(function(n,t){"use strict";function r(n){a[a.length]=n}function k(n){var t=new RegExp(" \\b"+n+"\\b");c.className=c.className.replace(t,"")}function p(n,t){for(var i=0,r=n.length;i<r;i++)t.call(n,n[i],i)}function tt(){var t,e,f,o;c.className=c.className.replace(/ (w-|eq-|gt-|gte-|lt-|lte-|portrait|no-portrait|landscape|no-landscape)\d+/g,""),t=n.innerWidth||c.clientWidth,e=n.outerWidth||n.screen.width,u.screen.innerWidth=t,u.screen.outerWidth=e,r("w-"+t),p(i.screens,function(n){t>n?(i.screensCss.gt&&r("gt-"+n),i.screensCss.gte&&r("gte-"+n)):t<n?(i.screensCss.lt&&r("lt-"+n),i.screensCss.lte&&r("lte-"+n)):t===n&&(i.screensCss.lte&&r("lte-"+n),i.screensCss.eq&&r("e-q"+n),i.screensCss.gte&&r("gte-"+n))}),f=n.innerHeight||c.clientHeight,o=n.outerHeight||n.screen.height,u.screen.innerHeight=f,u.screen.outerHeight=o,u.feature("portrait",f>t),u.feature("landscape",f<t)}function it(){n.clearTimeout(b),b=n.setTimeout(tt,50)}var y=n.document,rt=n.navigator,ut=n.location,c=y.documentElement,a=[],i={screens:[240,320,480,
@jrschumacher
jrschumacher / mongodb-shell-underscorejs.md
Last active August 29, 2015 13:57 — forked from vidoss/gist:2178987
MongoDB provides a Javascript shell. But Javascript is no fun without Underscore.js (http://underscorejs.org/). Here is how to add Underscore.js

MongoDB provides a Javascript shell. But Javascript is no fun without Underscore.js

Turned out its straight forward to use Underscore.js while scripting mongodb.

Here are the steps:

  1. Download or clone Underscore.js and run...
% mongo server:27017/dbname underscore.js my_commands.js
@jrschumacher
jrschumacher / travis-ci-test-mongo-connectivity.yml
Created March 14, 2014 17:41
Travis-CI test for MongoDB connectivity before script
# This script will test for MongoDB connectivity.
# If MongoDB is available then it continues else it tries X times then fails.
#
# Use: Add this to your `before_script` option
before_script:
- |
echo "Testing MongoDB connection...";tries=4;
i=0;
while [ $i -lt $tries ]; do fail=$(mongo --eval db 2>&1 >/dev/null | grep "connect failed");
@jrschumacher
jrschumacher / gist:58e5189942f28053a9e1
Created January 16, 2015 18:03
docker latest no port issue
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
32b9ac00b8fa dokku/coach:latest "/bin/bash -c '/star About an hour ago Up About an hour determined_bardeen
ed13cc0c60b6 dokku/helloworld:latest "/bin/bash -c '/star About an hour ago Up About an hour 0.0.0.0:49154->5000/tcp dreamy_hopper
@jrschumacher
jrschumacher / build-and-deploy.sh
Last active April 23, 2019 17:38
Ionic Automated Build and Deploy to HockeyApp
#!/bin/bash
PROJECT_NAME=MyApp
SCHEME_NAME=MyApp
STARTTIME=$(date +%s);
set -e
set -x
### Install dependencies
echo "--- Install dependencies [Time Elapsed $(($(date +%s) - $STARTTIME))s]"