Skip to content

Instantly share code, notes, and snippets.

Avatar
🤏

Ryan Schumacher jrschumacher

🤏
View GitHub Profile
@jrschumacher
jrschumacher / MongoQueryStr.php
Created Sep 1, 2013
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.
View MongoQueryStr.php
<?php
class MongoQueryStr {
protected static $indent = 0;
public static function convert($query) {
if(!is_array($query)) {
return false;
}
@jrschumacher
jrschumacher / MongoId2.php
Created Dec 5, 2012
MongoId to handle psudo MongoId objects (especially when dealing with json)
View MongoId2.php
<?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 / sub2path.pl
Created Jan 11, 2012
Wildcard domain for local development using Apache Mod Rewrite
View sub2path.pl
#!/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
View gist:58e5189942f28053a9e1
$ 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 / travis-ci-test-mongo-connectivity.yml
Created Mar 14, 2014
Travis-CI test for MongoDB connectivity before script
View travis-ci-test-mongo-connectivity.yml
# 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 / mongodb-shell-underscorejs.md
Last active Aug 29, 2015 — 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
View mongodb-shell-underscorejs.md

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
You can’t perform that action at this time.