Skip to content

Instantly share code, notes, and snippets.

@jpoehls
jpoehls / GadgetController.cs
Last active December 26, 2015 18:58
Basic ASP.NET MVC controller / data layer interaction architecture example.
class GadgetController : Controller {
// Each MVC controller has a complementing '*ControllerContext' class.
private readonly IGadgetControllerContext _context;
GadgetController()
: this(new GadgetControllerContext()) { }
// Unit testing ctor. Allows passing in mock repositories.
GadgetController(IGadgetControllerContext context) {
_context = context;
package main
import (
"bufio"
"fmt"
"os"
"time"
)
const numWorkers = 3
@jpoehls
jpoehls / gist:5521004
Created May 5, 2013 14:43
hasOwnProperty() example
function rightWay(obj) {
for (var key in obj) {
// Ignore properties that are inherited.
if (!obj.hasOwnProperty(key)) {
continue;
}
console.log(key);
}
}
@jpoehls
jpoehls / markup.htm
Created October 30, 2012 13:29
div-grid-hover-enlarge (http://cssdesk.com/xnKDc)
<!-- http://cssdesk.com/xnKDc -->
<div class="wrap">
<div class="r"><div class="c"><div>1</div></div><div class="c"><div>2</div></div><div class="c"><div>3</div></div><div class="c"><div>4</div></div></div>
<div class="r"><div class="c"><div>5</div></div><div class="c"><div>6</div></div><div class="c"><div>7</div></div><div class="c"><div>8</div></div></div>
<div class="r"><div class="c"><div>9</div></div><div class="c"><div>10</div></div><div class="c"><div>11</div></div><div class="c"><div>12</div></div></div>
<div class="r"><div class="c"><div>13</div></div><div class="c"><div>14</div></div><div class="c"><div>15</div></div><div class="c"><div>16</div></div></div>
</div>
@jpoehls
jpoehls / page.aspx
Created September 24, 2012 20:02
Do async work in OnClientClick before OnClick PostBack event
<asp:LinkButton ID="btnSave" OnClientClick="return prepareForSave(this);" OnClick="btnSave_Click" runat="server" Text="Save" />
@jpoehls
jpoehls / SmartGroupingResultTransformer.cs
Created August 3, 2012 16:17
SmartGroupingResultTransformer for NHibernate
/// <summary>
/// SQL results like this:
/// StateId Name Cities_CityId Cities_Name Counties_CountyId Counties_Name
///
/// Would be grouped into a distinct list of States.
/// If the State object had collection properties for Cities and Counties
/// then they would be populated appropriately.
///
/// Only supports a single level of collection. That is you can't have Cities_Residents_Name returned
/// and expect it to populate a State.Cities.Residents collection. Instead it would be ignored,
@jpoehls
jpoehls / RestfulRouteModule.cs
Created July 25, 2012 18:21 — forked from Grummle/RestfulRouteModule.cs
Http Module to write Route 'pattern' to server_variables
using System;
using System.Diagnostics;
using System.Web;
using System.Web.Routing;
using YourApp.Infrastructure.Framework;
namespace YourApp.Web.UI
{
public class RestfulRouteModule : IHttpModule
{
@jpoehls
jpoehls / toggle-hidden-files.scpt
Created June 26, 2012 20:04
Toggle hidden files in Finder. (AppleScript)
-- Save this to your documents and tell Alfred to look for (and execute AppleScripts).
-- There has never been an easier to way to toggle hidden files in Finder.
try
set state to do shell script "defaults read com.apple.finder AppleShowAllFiles" as string
if state is "0" then
do shell script "defaults write com.apple.finder AppleShowAllFiles -bool TRUE"
else
do shell script "defaults write com.apple.finder AppleShowAllFiles -bool FALSE"
end if
@jpoehls
jpoehls / blink_ip.pl
Created June 10, 2012 15:59 — forked from chrismeyersfsu/blink_ip.pl
Raspberry Pi Blink Ip Address
@jpoehls
jpoehls / mklink.psm1
Created June 7, 2012 19:40
Native PowerShell wrapper for MKLINK.