This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Nasty, intentionally verbose script to start/stop mongod | |
# Mark Woods - March 2010 | |
RUNTIME_USER='nobody' # only applicable on Linux, otherwise runs as current user | |
LOGPATH='/var/log/mongodb/mongod.log' | |
CONFIGFILE='/etc/mongod.conf' | |
DBPATH='/opt/mongodb/data/db' | |
BINPATH='/opt/mongodb/bin/mongod' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/ruby/bin/ruby -w | |
Dbpath = "/data/db" # database path | |
Backpath = "/data/dbbackup" # backup directory | |
Host = "" # mongo host to connect,empty is for local | |
Database = "" # database to use. empty is for all | |
Collection = "" # collection to use | |
User = "" | |
Passwd = "" | |
Now = Time.now | |
DATE = Now.strftime("%Y-%m-%d") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
iptables -F | |
iptables -X | |
iptables -P INPUT DROP | |
iptables -P FORWARD DROP | |
iptables -P OUTPUT DROP | |
iptables -t nat -F | |
iptables -t nat -P PREROUTING ACCEPT | |
iptables -t nat -P POSTROUTING ACCEPT | |
iptables -t nat -P OUTPUT ACCEPT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Score | |
include MongoMapper::Document | |
key :user_id, ObjectId, :index => true | |
key :stage, String, :index => true | |
key :score, Integer | |
timestamps! | |
def self.high_score_map | |
<<-MAP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Just copy and paste the lines below (all at once, it won't work line by line!) | |
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY! | |
function abort { | |
echo "$1" | |
exit 1 | |
} | |
set -e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This function cleans up messy HTML that was pasted by a user to a WYSIWYG editor. | |
# Specifically it also handles messy Word\Outlook generated HTML while keeping its original formattings. | |
require 'rubygems' | |
require 'sanitize' | |
def clean_up_document(html) | |
elements = %w[p b h1 h2 h3 h4 h5 h6 strong li ul ol i br div pre p] | |
attributes = { | |
'a' => ['href', 'title'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MongoDB upstart scripts for Ubuntu. | |
Run following commands after installing upstart scripts: | |
ln -s /lib/init/upstart-job /etc/init.d/mongoconf | |
ln -s /lib/init/upstart-job /etc/init.d/mongodb | |
ln -s /lib/init/upstart-job /etc/init.d/mongos | |
To start services use: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
description "Unicorn" | |
# starting unicorn with bundler, and a user contained rvm: | |
start on filesystem or runlevel [2345] | |
stop on runlevel [!2345] | |
chdir /path/to/current |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type T struct { | |
A int | |
B string | |
} | |
t := T{23, "skidoo"} | |
s := reflect.ValueOf(&t).Elem() | |
typeOfT := s.Type() | |
for i := 0; i < s.NumField(); i++ { |
OlderNewer