Skip to content

Instantly share code, notes, and snippets.

View lajunta's full-sized avatar
🌴
On vacation

lajunta lajunta

🌴
On vacation
View GitHub Profile
@mmrwoods
mmrwoods / mongod
Created October 26, 2010 16:11
Mongo DB init script for Linux and OSX
#!/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'
@lajunta
lajunta / autobackupmongo.rb
Created November 6, 2010 17:09
auto backup mongo (ruby version and very concise)
#!/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")
@lajunta
lajunta / iptables
Created November 12, 2010 07:44
some rules for iptables
#!/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
@chischaschos
chischaschos / .gitignore
Created January 24, 2011 20:09
Mongo mapper examples
*.log
@boj
boj / score.rb
Created February 22, 2011 10:18
MongoMapper MapReduce Example
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
@mxcl
mxcl / uninstall_homebrew.sh
Created August 26, 2011 11:25
Uninstall Homebrew
#!/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
@robertjwhitney
robertjwhitney / gist:1207453
Created September 9, 2011 22:03 — forked from ekampf/gist:847741
A ruby snippet to sanitize Html (and specifically Microsoft Word's messy HTML) (based on https://gist.github.com/139987)
# 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'],
@sasha-id
sasha-id / README
Created March 23, 2012 15:03
MongoDB multiple instance upstart scripts: mongodb, mongod --configsvr and mongos
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:
@witscher
witscher / unicorn.conf
Created July 27, 2012 13:40
Upstart script for unicorn, bundler and a user contained rvm installation
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
@justincase
justincase / gist:5469009
Created April 26, 2013 17:45
Print struct with field names and values. From http://blog.golang.org/2011/09/laws-of-reflection.html
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++ {