Skip to content

Instantly share code, notes, and snippets.

View prathamesh-sonpatki's full-sized avatar
🏠
Working from home

प्रथमेश Sonpatki prathamesh-sonpatki

🏠
Working from home
View GitHub Profile
@prathamesh-sonpatki
prathamesh-sonpatki / y2g.rb
Created June 29, 2012 11:36
Program to convert yacc files to grammar files (.y to to .grammar)(Incomplete)(Section#1 and Section#2 are completed, Working on Section# 3)
def match_package(str)
str.match /package\s.*;/
end
def match_import(str)
str.match /import\s.*;/
end
def match_class(str)
@bbrowning
bbrowning / TorqueBox on Heroku.md
Last active December 9, 2015 16:19
TorqueBox on Heroku

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
@prathamesh-sonpatki
prathamesh-sonpatki / email.rb
Last active December 11, 2015 05:48
Shoulda-matchers validation error
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
@prathamesh-sonpatki
prathamesh-sonpatki / 1.1.1_atoms.el
Last active December 11, 2015 08:08
Code examples from book "An Introduction to Programming in Emacs Lisp"
;; 1.1.1 Lisp atoms
;; If a list is preceded by single quote, we are telling lisp interpreter to take it as it is
'(sachin
rahul
saurav
laxman)
;; 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))
@satran
satran / github-issues.py
Created April 29, 2013 05:33
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.
BASE_URL = "https://api.github.com"
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}
end
def _wrap klass; Fiddle::Pointer.new Fiddle.dlwrap klass; end
end
@cheeaun
cheeaun / rdrc2015.md
Last active September 15, 2016 08:49
RedDotRubyConf 2015 links & resources 😘
@cheeaun
cheeaun / rdrc2016.md
Last active June 13, 2018 08:39
RedDotRubyConf 2016 links & resources 😘
@matthewrudy
matthewrudy / db-structure-clean.rake
Created February 26, 2017 23:40
Clean differences from your rake db:structure:dump - it seems to work for 9.4, 9.5 and 9.6
# frozen_string_literal: true
namespace :db do
namespace :structure do
STRUCTURE_PATH = 'db/structure.sql'
def clean_structure_file
original = File.read(STRUCTURE_PATH)
cleaned = original.dup
@manigandand
manigandand / slice_append.go
Created April 25, 2021 17:22
Slice: append vs set performance comparison
package main
import (
"fmt"
"reflect"
"strings"
"unsafe"
)
func main() {