Skip to content

Instantly share code, notes, and snippets.

Avatar

Bryan Nehl k0emt

View GitHub Profile
View startdevmongodb.bat
mongod --smallfiles --oplogSize 16 --nojournal
@k0emt
k0emt / 0_reuse_code.js
Created Feb 1, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@k0emt
k0emt / hello_world.tpl
Created Jun 24, 2013
Bottle example. The tpl file belongs in a views subdirectory.
View hello_world.tpl
%for thing in things:
<li>{{thing}}</li>
%end
@k0emt
k0emt / EnumStringExample.java
Created May 14, 2013
Example of working with enums in Java and in particular how to transform them into strings.
View EnumStringExample.java
public class EnumStringExample {
public static enum DAYS_OF_THE_WEEK {
MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;
public String toString() {
String plainName = name().toString();
String fancy = plainName.charAt(0)
+ plainName.substring(1).toLowerCase();
@k0emt
k0emt / init_replica.js
Created May 14, 2013
Companion javascript to initialize MongoDB replica set.
View init_replica.js
config = { _id: "m101", members:[
{ _id : 0, host : "localhost:27017"},
{ _id : 1, host : "localhost:27018"},
{ _id : 2, host : "localhost:27019"} ]
};
rs.initiate(config);
rs.status();
@k0emt
k0emt / create_replica_set.bat
Last active Nov 20, 2016
Helper batch file for starting up a replica set named m101. Drop the --logpath option if you want to enjoy the log text flying by in the console. The --oplogSize option is the magic sauce to avoid creation of numerous 512MB+ files up to 5% of disk space.
View create_replica_set.bat
mkdir \data\rs1 \data\rs2 \data\rs3
start mongod --replSet m101 --logpath "1.log" --dbpath \data\rs1 --port 27017 --smallfiles --oplogSize 64
start mongod --replSet m101 --logpath "2.log" --dbpath \data\rs2 --port 27018 --smallfiles --oplogSize 64
start mongod --replSet m101 --logpath "3.log" --dbpath \data\rs3 --port 27019 --smallfiles --oplogSize 64
@k0emt
k0emt / hello_world_bottle.py
Created Apr 6, 2013
Example of hello world in bottle with python
View hello_world_bottle.py
import bottle
@bottle.route('/')
def home_page():
return "Hello World\n"
@bottle.route('/testpage')
def test_page():
return "this is a test page"
@k0emt
k0emt / mongoGetKeys.py
Last active Dec 13, 2015
Utility code to get the keys from a document in a specified MongoDB database and collection.
View mongoGetKeys.py
#!/usr/local/bin/python
import sys
from pymongo import MongoClient
if len(sys.argv) < 3:
print 'usage is: ' + sys.argv[0] + ' databaseName collectionName'
sys.exit()
dbName = sys.argv[1]
@k0emt
k0emt / cities.xml
Created Feb 15, 2013
Example of XSLT Transformation with for-each-grouping. command to create: saxon -xsl:for-each-group.xsl -s:cities.xml > grouped_cities.xml
View cities.xml
<cities>
<state>
<name>Alabama</name>
<city>Abbeville</city>
<number>1</number>
</state>
<state>
<name>Alabama</name>
<city>Adamsville</city>
<number>1</number>