Skip to content

Instantly share code, notes, and snippets.

View mrichie's full-sized avatar

Richie Min mrichie

View GitHub Profile
@mrichie
mrichie / guide.sh
Created May 24, 2012 04:29 — forked from teamon/guide.sh
Pow + nginx configuration aka give me back my 80 port!
# Install pow
$ curl get.pow.cx | sh
# Install powder
$ gem install powder
# See that firewall is fucked
$ sudo ipfw show
00100 0 0 fwd 127.0.0.1,20559 tcp from any to me dst-port 80 in <- THIS ONE!!!
65535 81005 28684067 allow ip from any to any
@mrichie
mrichie / extend_and_method_call_bench.rb
Created May 24, 2012 05:32 — forked from mlomnicki/extend_and_method_call_bench.rb
Extend + method call VS method call
require 'benchmark'
module Foo
def bar
end
def baz
end
#save it as config/initializers/html_in_json.rb
ActiveSupport.escape_html_entities_in_json = true
#next line is not really compulsory. It just sanitizes output(not just replaces with \u values of html entities) to protect you from DOM XSSes.
ActiveSupport::JSON::Encoding::ESCAPED_CHARS.merge! '<' => '&lt;'
@mrichie
mrichie / active_admin_mongoid_patch
Created May 30, 2012 08:24
hook active_admin for support mongoid
require "active_admin"
require 'inherited_resources'
require "active_admin/resource_controller"
require 'mongoid'
module ActiveAdmin
module Mongoid
end
class Namespace
@mrichie
mrichie / gist:2849763
Created June 1, 2012 07:06 — forked from rrobe53/gist:976610
Node.js File Extension Content Type
exports.ext = function () {
var extTypes = {
"3gp" : "video/3gpp"
, "a" : "application/octet-stream"
, "ai" : "application/postscript"
, "aif" : "audio/x-aiff"
, "aiff" : "audio/x-aiff"
, "asc" : "application/pgp-signature"
, "asf" : "video/x-ms-asf"
, "asm" : "text/x-asm"
@mrichie
mrichie / rails_template_for_mongoid.rb
Created June 11, 2012 04:12 — forked from huacnlee/rails_template_for_mongoid.rb
A custom Rails template for Mongoid.
# coding: utf-8
# This is a Rails init template with MongoDB projects
#
# Mongoid, Devise, Bootstrap, jQuery, Redis, Cells, will_paginate, Carrierwave, simple_form, Settingslogic, Thin
#
# Usage
#
# $ rails new app_name -m https://raw.github.com/gist/2168014
#
@mrichie
mrichie / activeadmin-cancan.rb
Created July 9, 2012 03:01
Deep integration of CanCan into ActiveAdmin
# blog post:
# Before using this initializer, you must set up Cancan. First, add the gem to your Gemfile:
#
# gem 'cancan'
#
# Next, generate and edit an Ability class:
#
# rails generate cancan:ability
#
#!/bin/bash
#
# MongoDB Backup Script
# VER. 0.1
# Note, this is a lobotomized port of AutoMySQLBackup
# (http://sourceforge.net/projects/automysqlbackup/) for use with
# MongoDB.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@mrichie
mrichie / MongoDB Backup Script
Created October 17, 2012 01:42 — forked from wahyusumartha/MongoDB Backup Script
MongoDB Backup Script
#!/bin/bash
#!/usr/bin/env ruby
#########################################
# Define source and destinations
MONGO_DBS=""
BACKUP_TMP=~/tmp
BACKUP_DEST=~/backups
MONGODUMP_BIN=/Users/wahyusumartha/Documents/mongodb-db/bin/mongodump
TAR_BIN=/usr/bin/tar
@mrichie
mrichie / Gemfile
Created October 30, 2012 08:15 — forked from HungYuHei/Gemfile
followable with redis Sorted-Set
# Gemfile
gem 'redis', '~> 3.0.1'