Skip to content

Instantly share code, notes, and snippets.

View asanghi's full-sized avatar
🧠
Rebuilding RiseMoney

Aditya Sanghi asanghi

🧠
Rebuilding RiseMoney
  • Rising Sun
  • Dubai, UAE
  • 15:59 (UTC +04:00)
View GitHub Profile

Keybase proof

I hereby claim:

  • I am asanghi on github.
  • I am adity (https://keybase.io/adity) on keybase.
  • I have a public key ASDisOwJVwAOz3VRPxF28kZ9Q00xwnLB4R63BvMoa4qqgwo

To claim this, I am signing this object:

@asanghi
asanghi / sockethandler.rb
Created August 17, 2012 08:52
Celluloid IO connection handler
def read_until_eot(socket)
eot_found = false
message = ''
begin
message += socket.read()
eot_found = message['\004'].present? # <-- ughh what can i do?
end until eot_found
message
end
@asanghi
asanghi / cars_controller.rb
Created July 29, 2012 11:29
Action View Resolver -- Company scoped
class CarsController < ApplicationController
def index
@user = load_user # Load the user
prepend_view_path @user.resolver # Get the resolver
end
end
@asanghi
asanghi / gist:1360583
Created November 12, 2011 14:25
environment
CONTENT_LENGTH
"0"
DOCUMENT_ROOT
"/u/apps/punchh/production/current/public"
HTTP_ACCEPT_ENCODING
"gzip"
HTTP_ACCEPT_LANGUAGE
"en-US,*"
HTTP_CONNECTION
"Keep-Alive"
@asanghi
asanghi / gist:1360571
Created November 12, 2011 14:20
backtrace
[GEM_ROOT]/gems/dalli-1.1.3/lib/active_support/cache/dalli_store.rb:165:in `to_proc'
[GEM_ROOT]/gems/actionpack-3.0.10/lib/action_controller/metal/instrumentation.rb:22:in `map'
[GEM_ROOT]/gems/actionpack-3.0.10/lib/action_controller/metal/instrumentation.rb:22:in `process_action'
[GEM_ROOT]/gems/actionpack-3.0.10/lib/abstract_controller/base.rb:119:in `process'
[GEM_ROOT]/gems/actionpack-3.0.10/lib/abstract_controller/rendering.rb:41:in `process'
@asanghi
asanghi / migration4.0.rb
Created May 7, 2011 14:31
Why instance methods?
# Wouldnt it be cool if the Migration was further DSLed up to be just
class CreatePosts < ActiveRecord::Migration
change(:raise_down_error => false, :no_foreign_key_index => true) do
create_table :posts do |t|
t.string :title
t.text :body
t.timestamps
end
@asanghi
asanghi / gist:869281
Created March 14, 2011 15:09
Exception using Dropbox
===========================================================================
Exception that got raised:
Broken pipe
===========================================================================
/usr/local/ruby-enterprise/lib/ruby/1.8/net/protocol.rb:177:in `write'
/usr/local/ruby-enterprise/lib/ruby/1.8/net/protocol.rb:177:in `write0'
/usr/local/ruby-enterprise/lib/ruby/1.8/net/protocol.rb:153:in `write'
/usr/local/ruby-enterprise/lib/ruby/1.8/net/protocol.rb:168:in `writing'
/usr/local/ruby-enterprise/lib/ruby/1.8/net/protocol.rb:152:in `write'
/usr/local/ruby-enterprise/lib/ruby/1.8/net/http.rb:1563:in `send_request_with_body_stream'
en:
formtastic:
labels:
user:
%{nested_model}:
name: Formtastic is looking for this key user.%{nested_model}.name!!
#----------------------------------------------------------------------------
# Gems
#----------------------------------------------------------------------------
puts "=" * 80
puts "Setup Gemfile"
puts "=" * 80
remove_file "Gemfile"
create_file "Gemfile"
gem 'faker'
def import
file_param = params[:excel_file]
Spreadsheet.client_encoding = 'UTF-8'
begin
spreadsheet = Spreadsheet.open(file_param.local_path)
# do stuff with spreadsheet here using the spreadsheet api
rescue Exception => e
flash[:error] = "Error uploading Excel file : #{e.to_s}"
end
redirect_to root_path