Skip to content

Instantly share code, notes, and snippets.

#region Usings
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Serialization;
#endregion
@mps
mps / import-vins.rb
Created March 7, 2011 17:00
Refactored using FasterCSV
#!/usr/bin/env ruby
require 'optparse'
require 'rubygems'
#require 'excelsior'
require 'mongo'
require 'fastercsv'
load 'progressbar.rb'
options = { :server => "localhost", :port => "27017", :db => "AccuAuto" }
@mps
mps / gist:876691
Created March 18, 2011 19:33
Excluded
Func<PersDriver, bool> unverifiableMvr = d => d.Mvr == null || d.Mvr.MvrStatusCd != MvrStatus.Received || d.ViolationsChanged;
Func<PersDriver, bool> notExcluded = d => d.DriverStatusCd != DriverStatus.Excluded;
Func<PersVehicle, bool> requirePhoto = v => (((p.EffectiveDt.Year - v.ModelYear) + (p.EffectiveDt.Month >= 10 ? 1 : 0)) > 13) && !v.IsLiabilityOnly;
Func<bool> requireReceipt = () => p.Vehicles.Count / p.RatedDriverCount > 3;
if (p.Drivers.Any(unverifiableMvr) && p.Drivers.Any(notExcluded))
{
pd["suspenseheader1"] = "Unverifiable MVR. Please fax an enlarged copy of current driver's license for:";
pd["suspense1"] = p.Drivers.Where(unverifiableMvr).Where(notExcluded).Aggregate("", (current, d) => current + d.Name.FullName + "\r\n");
}
@mps
mps / gist:884992
Created March 24, 2011 12:45
Delete everything for an Agency
private static void Delete(string customerCode)
{
MongoInitializer.Initialize();
var connectionString = ConfigurationManager.ConnectionStrings["AccuAutoMongo"];
MServer = MongoServer.Create(connectionString.ConnectionString);
MDatabase = MServer[ConfigurationManager.AppSettings["DbName"] ?? "AccuAuto"];
var clientCollection = MDatabase.GetCollection<Mongo.Data.Client>("Client");
var paymentCollection = MDatabase.GetCollection<Mongo.Data.Payment>("Payment");
var attachmentCollection = MDatabase.GetCollection<Mongo.Data.FileAttachment>("FileAttachment");
var commissionCollection = MDatabase.GetCollection<Mongo.Data.ManagementCommission>("ManagementCommission");
var umpd = "NON";
foreach (var rv in r.Vehicles)
{
if (rv.UmpdLimit.Equals("NONE"))
{
data["umpdlimit" + (rv.VehicleIndex + 1)] = "NON";
}
else
{
data["umpdlimit" + (rv.VehicleIndex + 1)] = rv.UmpdLimit;
@mps
mps / RateBreakdownWindowPresenterBase.cs
Created August 9, 2011 20:29
Proposed Upload change
protected virtual void OnUploadCommandExecute(object debugObj)
{
UploadDebug = debugObj == null ? false : debugObj.Equals("true");
var dateDiff = Policy.EffectiveDt.Subtract(DateTime.UtcNow);
if (dateDiff.Days > 30 || dateDiff.Days < 0)
{
AlertWindow.Alert("Cannot upload a policy unless the effective date is within 30 days of today.", "Invalid effective date");
return;
}
@mps
mps / IR_Black.dvtcolortheme
Created August 16, 2011 20:56 — forked from osteslag/IR_Black.dvtcolortheme
IR_Black theme for Xcode 4, based on IR_Black for Xcode 3 by David Zhou, based on IR_Black for TextMate by Todd Werth. See links in comments below.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.811765 0.796078 0.564706 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Inconsolata - 16.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>1 1 1 1</string>
@mps
mps / gist:2890074
Created June 7, 2012 17:03
Mono File Upload
public void UploadFile ()
{
var uri = new Uri ("http://my_file_upload_handler.com");
var client = new WebClient ();
client.UploadFileCompleted += UploadComplete;
client.UploadFileAsync(uri, "local_file.png");
}
public void UploadComplete (object sender, UploadFileCompletedEventArgs args)
{
@mps
mps / gist:2890181
Created June 7, 2012 17:24
Mono for Android Shared Preferences
// Store Preferences
SharedPreferences pref = context.getSharedPreferences("MY_PREFERENCE", MODE_PRIVATE);
Editor editor = pref.edit();
editor.clear();
editor.putString("my_stored_value", "some_value");
editor.commit();