Skip to content

Instantly share code, notes, and snippets.

View piyushranjan's full-sized avatar

Piyush Ranjan piyushranjan

View GitHub Profile
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)
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
<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>
window={};
window.BlobBuilder = require("BlobBuilder");
location={};
location.protocol="http";
BinaryPack = require("binary-pack");
XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var wrtc = require("wrtc");
%webengage{:license => <license_number>}
%script{:id => "_webengage_script_tag", :type => "text/javascript"}
(function(){var _we = document.createElement('script');_we.type = 'text/javascript';_we.async = true;_we.src = "//widgets.webengage.com/js/widget/webengage-min-v-2.0.js";var _sNode = document.getElementById('_webengage_script_tag');_sNode.parentNode.insertBefore(_we, _sNode);})();
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'/>");
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
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
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