Skip to content

Instantly share code, notes, and snippets.

View piyushranjan's full-sized avatar

Piyush Ranjan piyushranjan

View GitHub Profile
<html>
<head>
<script src="http://cdn.peerjs.com/0.3/peer.js"></script>
<title>Client</title>
</head>
<body>
<div class="error"></div>
<div id="container"></div>
<script type="text/javascript" src="/webrtc/client.js"></script>
</body>
merb : worker (port 4000) ~ undefined method `get' for nil:NilClass - (NoMethodError)
/usr/lib/ruby/gems/1.8/gems/dm-core-0.10.1/lib/dm-core/associations/relationship.rb:510:in `regions'
/home/piyush/Code/Intellecap/mostfit/app/controllers/staff_members.rb:114:in `show'
/usr/lib/ruby/gems/1.8/gems/merb-action-args-1.0.13/lib/merb-action-args/abstract_controller.rb:42:in `__send__'
/usr/lib/ruby/gems/1.8/gems/merb-action-args-1.0.13/lib/merb-action-args/abstract_controller.rb:42:in `_call_action'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.13/lib/merb-core/controller/abstract_controller.rb:289:in `_dispatch'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.13/lib/merb-core/controller/merb_controller.rb:252:in `_dispatch'
/usr/lib/
PURE DM
start=Time.now; puts Branch.get(3).centers(:fields => [:id]).clients(:fields => [:id]).loans(:fields => [:id, :amount]).sum(:amount); puts Time.now-start
~ (0.000063) SET sql_auto_is_null = 0
~ (0.000048) SET SESSION sql_mode = 'ANSI,NO_BACKSLASH_ESCAPES,NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION,NO_UNSIGNED_SUBTRACTION,TRADITIONAL'
~ (0.000140) SELECT `id`, `name`, `code`, `created_at`, `creation_date`, `area_id`, `manager_staff_id` FROM `branches` WHERE `id` = 3 ORDER BY `id` LIMIT 1
~ (0.000058) SELECT `id` FROM `centers` WHERE `branch_id` = 3 ORDER BY `id`
~ (0.000106) SELECT `id`, `center_id` FROM `clients` WHERE `deleted_at` IS NULL AND `center_id` IN (5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 3
require "dm-core"
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, 'mysql://test@localhost/dm_test')
class Amount
include DataMapper::Resource
property :id, Serial
property :amount_1, Integer
>> Loan.first(:amount.not => :amount_applied_for)
~ (0.001025) SELECT `id`, `discriminator`, `amount`, `amount_applied_for`, `amount_sanctioned`, `interest_rate`, `installment_frequency`, `number_of_installments`, `scheduled_disbursal_date`, `scheduled_first_payment_date`, `applied_on`, `approved_on`, `rejected_on`, `disbursal_date`, `written_off_on`, `validated_on`, `created_at`, `updated_at`, `loan_product_id`, `applied_by_staff_id`, `approved_by_staff_id`, `rejected_by_staff_id`, `disbursed_by_staff_id`, `written_off_by_staff_id`, `validated_by_staff_id`, `verified_by_user_id`, `created_by_user_id`, `cheque_number`, `cycle_number`, `original_amount`, `original_disbursal_date`, `original_first_payment_date`, `taken_over_on`, `taken_over_on_installment_number`, `occupation_id`, `funding_line_id`, `client_id` FROM `loans` WHERE `deleted_at` IS NULL AND `discriminator` IN ('Loan', 'DefaultLoan', 'A50Loan', 'EquatedWeekly', 'BulletLoan', 'BulletLoanWithPeriodicInterest', 'PararthRounded', 'TakeOverLoan', 'Take
require "dm-core"
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, 'mysql://test@localhost/dm_test')
class Amount
include DataMapper::Resource
property :id, Serial
property :amount_1, Integer
Mostfit::Business::Rule.prepare do |rule|
rule.allow :name => :number_of_branches_in_area, :model => Branch, :on => :create, :condition => ["area.branches.count", :less_than_equal, 5]
rule.allow :name => :loans_more_than_10k, :model => Loan, :on => :save, :precondition => {:disbursal_date.not => nil, :amount.gt => 10000}, :condition => {:disbursed_by => "client.center.branch.staff_member"}
rule.reject :name => :max_centers_in_area, :model => Center, :on => :create, :condition => ["branch.area.branches.centers.count", :greater_than_equal, 100]
rule.allow :name => :max_centers_in_branch, :model => Loan, :on => :create, :condition => ["client.center.branch.centers.count", :less_than_equal, 50]
rule.allow :name => :min_centers_in_branch, :model => Loan, :on => :create, :condition => ["client.center.branch.centers.count", :greater_than_equal, 5]
rule.allow :name => :min_clients_in_branch, :model => Loan, :on => :create, :condition => ["client.center.bran
function create_remotes(){
$("a._remote_").live('click', function(){
href=$(this).attr("href");
method="GET";
if($(this).hasClass("self")){
href=href+(href.indexOf("?")>-1 ? "&" : "?")+$(this).parent().serialize();
method="POST";
}
a=$(this);
a.after("<img id='spinner' src='/images/spinner.gif'/>");
require "json"
require "csv"
csv_file = File.open("processedcr.csv", "w")
CSV.build(csv_file) do |csv|
Dir.foreach("resale"){|f|
file = File.join("resale", f)
next unless File.file?(file)
next if File.size(file) == 0
require "json"
csv_file = File.open("processedcr.csv", "w")
CSV.build(csv_file) do |csv|
Dir.foreach("natural"){|f|
file = File.join("natural", f)
next unless File.file?(file)
next if File.size(file) == 0
json_str = File.read(file)