Skip to content

Instantly share code, notes, and snippets.

@andikan
andikan / pg.sh
Created April 5, 2014 17:19 — forked from cjolly/pg.sh
newpg=9.3.2
oldpg=9.2.4 # set this to your current PG version
# Stop current Postgres server
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
# Backup current db
mv /usr/local/var/postgres/ /usr/local/var/postgres-$oldpg
# Homebrew
class ArticleImageUploader < ImageUploader
process :fix_exif_rotation
process :strip
process :convert => 'jpg'
process :quality => 85 # Percentage from 0 - 100
version :gallery_thumb do
process :resize_to_fill => Settings.images.article_images.processing.gallery_thumb #44x44
end
@andikan
andikan / api.js
Created March 10, 2014 18:48 — forked from fwielstra/api.js
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');

Vagrant Setup

This tutorial guides you through creating your first Vagrant project.

We start with a generic Ubuntu VM, and use the Chef provisioning tool to:

  • install packages for vim, git
  • create user accounts, as specified in included JSON config files
  • install specified user dotfiles (.bashrc, .vimrc, etc) from a git repository

Afterwards, we'll see how easy it is to package our newly provisioned VM

@andikan
andikan / install.md
Last active August 29, 2015 13:56
Install OpenCV in Mac OS X 10.8.5

Welcome to GaussBits

Prerequirements

  1. HomeBrew
  2. OpenCV
  3. Xcode 4.6.2
  4. Xcode Command Line Tools
module PgArrayHstoreFix
def self.included(base)
base.class_eval do
before_save :serialize_array_hash
end
def serialize_array_hash
self.class.attribute_names.each do |attribute|
column_definition = self.column_for_attribute(attribute)
if column_definition.array && column_definition.type == :hstore
vector<Point*> Mesh::getSimplifiedPointEdgeSet(vector<Point*> &edgePoints)
{
vector<Point*> simplePointEdgeSet;
vector<Point*> tempPoints;
bool existJointPoint = false;
cout << "edgePoints : " << edgePoints.size() / 2 << endl;
for(int i=0; i<edgePoints.size(); i++)
{
vector<Point*> neighborPoints;
COUNTRIES = [
"Afghanistan",
"Aland Islands",
"Albania",
"Algeria",
"American Samoa",
"Andorra",
"Angola",
"Anguilla",
"Antarctica",
@andikan
andikan / gist:7761709
Created December 3, 2013 00:21 — forked from pioz/gist:967559
require 'rubygems'
require 'activemerchant'
ActiveMerchant::Billing::Base.mode = :test
paypal_options = {
:login => 'xxx',
:password => 'yyy',
:signature => 'zzz'
}
::PAYPAL_EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)
# Add this to your application.rb
config.middleware.use Rack::Cors do
allow do
origins '*'
# location of your API
resource '/api/*', :headers => :any, :methods => [:get, :post, :options, :put]
end
end