Skip to content

Instantly share code, notes, and snippets.

Looking for bugs 🦟

प्रथमेश Sonpatki prathamesh-sonpatki

Looking for bugs 🦟
View GitHub Profile
matthewrudy / db-structure-clean.rake
Created Feb 26, 2017
Clean differences from your rake db:structure:dump - it seems to work for 9.4, 9.5 and 9.6
View db-structure-clean.rake
# frozen_string_literal: true
namespace :db do
namespace :structure do
STRUCTURE_PATH = 'db/structure.sql'
def clean_structure_file
original =
cleaned = original.dup
cheeaun /
Last active Jun 13, 2018
RedDotRubyConf 2016 links & resources 😘
cheeaun /
Last active Sep 15, 2016
RedDotRubyConf 2015 links & resources 😘
View ticket.rb
class Ticket < ActiveRecord::Base
belongs_to :grouper
belongs_to :user
validate :user_cant_be_blacklisted, on: :confirmation
validate :user_cant_double_book, on: :confirmation
validate :grouper_cant_be_full, on: :confirmation
validate :grouper_cant_have_occurred, on: :confirmation
View python.rb
require 'fiddle'
module Python
def __class__= k
value = _wrap self
[k.object_id<<1].pack('Q').unpack('C8').each_with_index {|n,i|value[i+8]=n}
def _wrap klass; Fiddle.dlwrap klass; end
satran /
Created Apr 29, 2013
The small program used for the talk at Pune Python User Group meetup on April 2013. Please feel free to update this script and make a pull request.
# Packages and modules are imported to the scope using the import statement.
# If you wanted just a particular object from a module/package you can use
# the from <module> import <object>
import sys
import requests
# There are no constants in Python, still we can use a naming convention to
# imply that to the user of a library.
prathamesh-sonpatki / 1.1.1_atoms.el
Last active Dec 11, 2015
Code examples from book "An Introduction to Programming in Emacs Lisp"
View 1.1.1_atoms.el
;; 1.1.1 Lisp atoms
;; If a list is preceded by single quote, we are telling lisp interpreter to take it as it is
;; If a list is not preceded by single quote, lisp interpreter treats first atom of the list as a function,
;; and passes all the remaining atoms as arguments to it, and returns result of the function
(+ 2 2)
'(this list has (list inside it))
prathamesh-sonpatki / email.rb
Last active Dec 11, 2015
Shoulda-matchers validation error
View email.rb
class Email < ActiveRecord::Base
scope :by_account, -> account_id { where(account_id: account_id) }
attr_accessible :template_name, :subject, :content, :user_id, :account_id
validates :subject, presence: true
validates :template_name, presence: true
validates :template_name, uniqueness: { :scope => :account_id }
validates :content, presence: true
View TorqueBox on

With Heroku's JRuby support you may have already seen that you can run TorqueBox Lite on Heroku. But, that only gives you the web features of TorqueBox. What about scheduled jobs, backgroundable, messaging, services, and caching?

With a small amount of extra work, you can now run the full TorqueBox (minus STOMP support and clustering) on Heroku as well! I've successfully deployed several test applications, including the example Rails application from our Getting Started Guide which has a scheduled job, a service, and uses backgroundable and messaging.

This example uses TorqueBox 3.0.2, but the instructions may work with other TorqueBox versions.

Steps Required

  1. Create a JRuby application on Heroku, or convert an existing application to JRuby. Make sure your application works on JRuby on Heroku before throwing TorqueBox into the mix.
  2. Add th
ryanb /
Created Nov 29, 2012
Points on how modules can make code difficult to read.

My issues with Modules

In researching topics for RailsCasts I often read code in Rails and other gems. This is a great exercise to do. Not only will you pick up some coding tips, but it can help you better understand what makes code readable.

A common practice to organize code in gems is to divide it into modules. When this is done extensively I find it becomes very difficult to read. Before I explain further, a quick detour on instance_eval.

You can find instance_eval used in many DSLs: from routes to state machines. Here's an example from Thinking Sphinx.

class Article < ActiveRecord::Base
You can’t perform that action at this time.