Skip to content

Instantly share code, notes, and snippets.

View codereflection's full-sized avatar

Jeff Schumacher codereflection

View GitHub Profile
$ServerName = $args[0]
if ($serverName -eq $Null) {
$serverName= $env:COMPUTERNAME
}
$timeVal = (Get-WmiObject -ComputerName $ServerName -Query "SELECT LastBootUpTime FROM Win32_OperatingSystem").LastBootUpTime
#$timeVal
$DbPoint = [char]58
$Years = $timeVal.substring(0,4)
$Months = $timeVal.substring(4,2)
$Days = $timeVal.substring(6,2)
@codereflection
codereflection / Package Control.sublime-settings
Created May 24, 2014 16:05
Package Control.sublime-settings
{
"installed_packages":
[
"AngularJS",
"Enhanced Clojure",
"FileBrowser",
"Git",
"Highlight Whitespaces",
"HTML5",
"Jasmine BDD",
@codereflection
codereflection / CurrentThreadTaskScheduler.cs
Created December 20, 2013 20:04
Getting unit tests to run under a single thread. Just inherit the WithASingleThreadRestriction class from your unit tests and they'll run under a single thread making unit testing much easier.
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
namespace Tests
{
public class CurrentThreadTaskScheduler : TaskScheduler
{
protected override void QueueTask(Task task)
@codereflection
codereflection / 0_reuse_code.js
Created October 1, 2013 18:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
/// <summary>
/// NullTask is a task that does nothing in Null Object Pattern fashion
/// </summary>
public class NullTask : Task
{
public NullTask() : base(() => { }) { }
}
# adapted from http://notes.jimlindley.com/2008/3/25/git-svn-that-works-for-me
# initial slow setup (this will scan all of the base svn repo's history, and could take hours)
# - Change <svn_repo> to the base url of your svn repo, WITHOUT trunk at the end
# this will point master to /trunk and allow you to point git branches to svn branches
git svn clone <svn_repo> --stdlayout
# initial quick clone setup
# - Change $REV to the first revision of your repo, i.e. 24903
# - Change <svn_repo> to the base url of your svn repo, WITHOUT trunk at the end
@codereflection
codereflection / gist:4222309
Created December 6, 2012 06:55
Fake out that ToList!
dynamic cutRuleParameters = new ExpandoObject();
cutRuleParameters.ToList = (Func<List<CutRuleParameterViewModel>>)(() =>
new List<CutRuleParameterViewModel> {
new CutRuleParameterViewModel { ParamId = 77, IsDynamic = 'Y' , UIParamCode = "MedianRounding", ParamName = "MedianRounding" , ParamValue = "5000", ParamCode = "MedianRounding" },
new CutRuleParameterViewModel { ParamId = 78, ParamName = "Rounding Direction", IsDynamic = 'Y' , UIParamCode = "RoundDirection", ParamCode = "RoundingDir" }
});
@codereflection
codereflection / gist:3859562
Created October 9, 2012 15:34
Using ModelState.AddModelError for exception reporting
[HttpPost]
public ActionResult Edit(DonorViewModel model)
{
try
{
var donor = db.Donors.Get(model.Donor_ID);
model.CreatedOn = donor.CreatedOn;
model.DonorType_ID = donor.DonorType_ID;
model.ModifiedOn = DateTime.Now;
@codereflection
codereflection / gist:3438782
Created August 23, 2012 17:07
phantomjs with casperjs example
phantom.casperPath = 'D:\\Dev\\Tools\\casperjs';
phantom.injectJs(phantom.casperPath + '\\bin\\bootstrap.js');
var casper = require("casper").create({
logLevel: "debug"
});
var utils = require('clientutils').create();
casper.start("http://localhost:52125/ED/stockresearch/StockResearch", function() {
public static string ToBeTrim(this string givenString)
{
if (!string.IsNullOrEmpty(givenString))
return givenString.Trim();
return string.Empty;
}