Skip to content

Instantly share code, notes, and snippets.

@gaurish
gaurish / rt.rb
Created April 8, 2014 23:16
rtu result analysis
require_relative 'student.rb'
require 'pry'
require 'httparty'
require 'logger'
require 'csv'
URL = 'URL_HERE'
rollno_prefix, = "11CIIXX"
rollno_range = 600..656
subjects = []
@gaurish
gaurish / db.md
Created December 2, 2013 01:30
rails database best practices
  • null: false, use default value
  • use FKs
  • Use dependant destroy/delete_all/delete_error etc
  • retry ActiveRecord::RecordNotUnique, rescue_from
@gaurish
gaurish / Gemfile
Last active December 28, 2015 21:19
Web Scrapper to get election data
gem 'mechanize'
gem 'pry'
gem 'awesome_print'
gem 'logger'
gem 'activesupport'
$ rvm install jruby
$ rvm use jruby
$ bundle install
$ cd actionpack
$ ruby --client -Itest:lib test/controller/live_stream_test.rb -n test_async_stream
Run options: -n test_async_stream --seed 16798
# Running:
@gaurish
gaurish / nginx.conf
Created November 5, 2013 17:23
nginx config to run http://xyz.com as rails app and run http://xyz.com/blog as wordpress blog. uses fcgi to serve the PHP app & memcache to speed up your blog
location /blog {
index index.html index.php;
#try_files $uri $uri/ /blog/index.php?q=$uri;
try_files $uri $uri/ @memcached;
location ~ \.(css|js|jpg|jpeg|png|gif)$ {
expires 7d;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
add_header "Vary" "Accept-Encoding";
}
@gaurish
gaurish / shell.sh
Created October 1, 2013 07:47
Why this warning?
$ jruby --version
jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on Java HotSpot(TM) Server VM 1.7.0_40-b43 +indy [linux-i386]
$ bundle
Java HotSpot(TM) Server VM warning: You have loaded library /home/gaurish/.rvm/rubies/jruby-1.7.4/lib/native/x86_64-Linux/libjffi-1.2.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Fetching gem metadata from https://rubygems.org/..
TypeError: superclass mismatch for class PostgreSQLAdapter
ConnectionAdapters at /home/travis/build/rails/rails/activerecord/test/cases/adapters/postgresql/statement_pool_test.rb:4
(root) at /home/travis/build/rails/rails/activerecord/test/cases/adapters/postgresql/statement_pool_test.rb:3
require at org/jruby/RubyKernel.java:1054
require at /home/travis/build/rails/rails/activesupport/lib/active_support/dependencies.rb:228
gem list
*** LOCAL GEMS ***
actionmailer (4.0.0)
actionpack (4.0.0)
activemodel (4.0.0)
activerecord (4.0.0)
activerecord-deprecated_finders (1.0.3)
activesupport (4.0.0)
#1st form
class Foo
class << self
attr_accessor :bar
end
self.bar = true
end
#2nd form
class Foo
@gaurish
gaurish / log.rb
Created August 18, 2013 23:41
failing tests on JRUBY
1) Error:
InflectorTest#test_parameterize:
Encoding::ConverterNotFoundError: code converter not found (UTF-8 to UTF8-MAC)
org/jruby/RubyConverter.java:114:in `initialize'
/home/gaurish/code/repo/rails/activesupport/lib/active_support/multibyte/unicode.rb:231:in `tidy_bytes'
/home/gaurish/code/repo/rails/activesupport/lib/active_support/inflector/transliterate.rb:62:in `transliterate'
/home/gaurish/code/repo/rails/activesupport/lib/active_support/inflector/transliterate.rb:83:in `parameterize'
test/inflector_test.rb:235:in `test_parameterize'
org/jruby/RubyHash.java:1332:in `each'
test/inflector_test.rb:234:in `test_parameterize'