Skip to content

Instantly share code, notes, and snippets.

View abombss's full-sized avatar

Adam Tybor abombss

  • Accenture
  • Chicago, IL
View GitHub Profile
@abombss
abombss / FixNuget.ps1
Created July 18, 2012 19:47
Fix All Nuget Packages in Solution
Get-Project -All | %{ $proj = $_; Get-Package -Project $_.Name | %{ $pkg = $_; Uninstall-Package -Id $pkg.Id -ProjectName $proj.Name -Force; Install-Package -Id $pkg.Id -ProjectName $proj.Name -Version $pkg.Version } }
@abombss
abombss / WebRequestExtensions.cs
Created May 17, 2012 18:25
Cloning Web/HttpRequests in .Net
public static class WebRequestExtensions
{
public static HttpWebRequest CloneRequest(this HttpWebRequest originalRequest, Uri newUri)
{
return CloneHttpWebRequest(originalRequest, newUri);
}
public static WebRequest CloneRequest(this WebRequest originalRequest, Uri newUri)
{
var httpWebRequest = originalRequest as HttpWebRequest;
@abombss
abombss / git-submodule-reload.ps1
Created November 20, 2011 21:06
Powershell to re-clone all git submodules
$hash = @{}; $list = cat .gitmodules | where { $_ -like "*=*" } | foreach { $_.Split("=")[1].Trim() }; while ($list) { $key, $value, $list = $list; $hash[$key]=$value }; $hash.GetEnumerator() | foreach { & git submodule add $_.Value $_.Name }
@abombss
abombss / getTypeName.js
Created November 8, 2011 07:34
Javascript Type / Class Name
function getTypeName(value) {
if (value === null) {
return "null";
}
var t = typeof value;
switch (t) {
case "function":
case "object":
if (value.constructor && value.constructor.name) {
@abombss
abombss / toggle-list-sep.ps1
Created August 6, 2011 19:18
Powershell script to toggle and change the windows regional settings for the list separator to make outputting CSV files from excel using different delimiters much easier
function toggle-list-sep
{
$path = "hkcu:\Control Panel\International"
$key = "sList"
$cur_sep = (Get-ItemProperty -path $path -name $key).$key
if ($args.Length -gt 0) { $value = $args[0] }
elseif ($cur_sep -eq ",") { $value = "|" }
else { $value = "," }
@abombss
abombss / jquery-cascadingselect.js
Created June 17, 2011 05:40
JQuery plugin for Cascading Selects
(function ($) {
/// <summary>JQuery plugin for handling cascading html select lists</summary>
/// <param name="$" type="jQuery">JQuery</param>
$.fn.cascadingSelect = function() {
this.each(function() {
var $e = $(this);
var $p = $($e.attr("data-ui-cascading-parent"));
$e.data('cascading-opts', $e.find("option:gt(0)"));
@abombss
abombss / Extensions.cs
Created June 17, 2011 04:49
C# Safe navigation operator as extension
public static class Extensions
{
public static TResult SafeInvoke<TModel, TResult>(this TModel model, Func<TModel, TResult> expression, TResult nullValue = default(TResult))
{
try
{
return expression(model);
}
catch (NullReferenceException)
{
@abombss
abombss / jquery-iebuttonfix.js
Created June 15, 2011 07:28
JQuery plugin to fix the html <button> issue when submitting forms in IE <= 7
(function ($) {
/// <param name="$" type="jQuery">JQuery</param>
$.fn.iebuttonfix = function() {
return $(this).each( function() {
var $f = $(this);
if ($f.prop("nodeName").toLowerCase() === "form") {
$f.submit(function() {
$("button", $f).each(function() {
var $b = $(this);
if ($b.data("ie.btnfix.clicked")) {
@abombss
abombss / CQRS.cs
Created June 4, 2011 05:15 — forked from ToJans/CQRS.cs
Simple concept code to show how CQRS works
//---><8--------------------------- UI loads viewmodels and generates commands ----
UI.Viewmodel = ViewModelStore.Query(UI.SomeParameters);
UI.HandleInput = GeneratedCommand => CommandStore.Add(GeneratedCommand);
//---><8--------------------------- Commands to events -----------------------------------------
// This uses an iterator because a command should only be handled once
while(CommandStore.HasCommands)
@abombss
abombss / gist:937804
Created April 22, 2011 22:13
Fugly mvc
var model = new
{
Accounts = accounts.Select(x => x.ToExpando()),
TotalUsers = totalUsers,
Page = page,
};
return View(model.ToExpando());