Skip to content

Instantly share code, notes, and snippets.

View diatmpravin's full-sized avatar

Pravin Mishra diatmpravin

View GitHub Profile
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', '3.2.12'
gem 'arel'
gem 'mysql2'
GEMFILE
system 'bundle'
end
@diatmpravin
diatmpravin / ar-has_many_throught
Created February 2, 2014 06:33
AR bug with circular destroy: I am able to replicate this issue for later release including 4.0.0 for has_many relationship. It's fine for earlier release.
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', '3.2.12'
gem 'arel'
gem 'mysql2'
GEMFILE
system 'bundle'
end
@diatmpravin
diatmpravin / ar-has_one_throught
Last active August 29, 2015 13:55
AR bug with circular destroy: I am able to replicate this issue for later release including 4.0.0 for has_one relationship. It's fine for earlier release.
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', '3.2.12'
gem 'arel'
gem 'mysql2'
GEMFILE
system 'bundle'
end
@diatmpravin
diatmpravin / go_mongodb_sample_app
Created March 11, 2014 12:04
Go+Martini+mgo(mongodb driver) Sample Application
package main
import (
"fmt"
"github.com/codegangsta/martini" // loading in the Martini package
"github.com/martini-contrib/render"
"labix.org/v2/mgo" // loading in the mgo MongoBD driver package
"labix.org/v2/mgo/bson" // loading in the bson package
"net/http"
)
@diatmpravin
diatmpravin / task.go
Created March 12, 2014 18:34
Revel Sample Controller
package controllers
import (
"github.com/revel/revel"
"ToGo/app/models"
"ToGo/app/routes"
"github.com/jinzhu/gorm"
type Task struct {
ModelController
@diatmpravin
diatmpravin / chef_error
Created March 13, 2014 14:46
chef error
vagrant up
/opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- vagrant/util/downloader (LoadError)
from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/ubuntu/.vagrant.d/gems/gems/vagrant-omnibus-1.3.1/lib/vagrant-omnibus/action/install_chef.rb:20:in `<top (required)>'
from /home/ubuntu/.vagrant.d/gems/gems/vagrant-omnibus-1.3.1/lib/vagrant-omnibus/plugin.rb:35:in `require_relative'
from /home/ubuntu/.vagrant.d/gems/gems/vagrant-omnibus-1.3.1/lib/vagrant-omnibus/plugin.rb:35:in `block in <class:Plugin>'
from /opt/vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/action/runner.rb:37:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/action/runner.rb:37:in `block (2 levels) in run'
from /opt/vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/action/runner.rb:36:in `tap'
from /opt/vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/action/runner.rb:36:in `block in run'
@diatmpravin
diatmpravin / validation.go
Last active August 29, 2015 14:00
validation.go
package revel
import (
"fmt"
"net/http"
"net/url"
"regexp"
"runtime"
)
package revel
import (
"fmt"
"reflect"
"regexp"
"time"
)
type Validator interface {
@diatmpravin
diatmpravin / go_couchdb
Created June 27, 2014 06:53
Sample CouchBD Golang connecting code
package main
import (
"log"
"fmt"
"github.com/couchbaselabs/go-couchbase"
)
var (
bucket *couchbase.Bucket
@diatmpravin
diatmpravin / cf-postgresql.yml
Created October 13, 2014 03:56
CF PostgreSQL service deployment config file
---
name: cf-services-contrib
director_uuid: 0ddre47e-5gfb-4095-859e-5a08f9eacf02 # CHANGE
releases:
- name: cf-services-contrib
version: 1
compilation:
workers: 3