Skip to content

Instantly share code, notes, and snippets.

View ryankirkman's full-sized avatar

Ryan Kirkman ryankirkman

View GitHub Profile
@ryankirkman
ryankirkman / merge.md
Created August 26, 2011 04:10
the 'perfect' web.config starting point - rpk
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
@ryankirkman
ryankirkman / HtmlHelperExtensions.cs
Created September 9, 2011 01:59
Html Helper to return the raw DisplayName attribute of a property of a Model
using System;
using System.Linq.Expressions;
using System.Web.Mvc;
namespace MvcHtmlHelpers
{
public static class HtmlHelperExtensions
{
/// <summary>
/// Return the raw DisplayName attribute of a property of a Model,
@ryankirkman
ryankirkman / gist:1667568
Created January 24, 2012 03:13
nodebits wiki challenge npm install fail
[ryankirkman@cloud9]:/workspace$ npm install
npm ERR! Error: No compatible version found: trycatch@'>=0.1.0- <0.2.0-'
npm ERR! Valid install targets:
npm ERR! ["0.0.1","0.0.2","0.0.3","0.0.4","0.0.5","0.0.6","0.0.7","0.0.8","0.0.9"]
npm ERR! at installTargetsError (/mnt/ws/users/ryankirkman/npm/lib/cache.js:424:10)
npm ERR! at /mnt/ws/users/ryankirkman/npm/lib/cache.js:406:17
npm ERR! at saved (/mnt/ws/users/ryankirkman/npm/lib/utils/npm-registry-client/get.js:136:7)
npm ERR! at Object.cb [as oncomplete] (/mnt/ws/users/ryankirkman/npm/node_modules/graceful-fs/graceful-fs.js:36:9)
npm ERR! Report this *entire* log at:
npm ERR! <http://github.com/isaacs/npm/issues>;
@ryankirkman
ryankirkman / index.md
Created March 16, 2012 04:02 — forked from lancejpollard/index.md
Math for Coders

Sets == Arrays of unique items

(A,B)

Ordered set.

[1, 2] != [2, 1]
byDateGroup: {
map: function(doc) {
if (doc.date && (doc.group == "group1" || doc.group == "group2")) {
emit(doc.date, null);
}
}
}
@ryankirkman
ryankirkman / ProxyRequest.cs
Created May 30, 2012 03:51
ProxyRequest proxies a request to a JSON-based API to avoid the cross origin request issue.
// ProxyRequest proxies a request to a JSON-based API
// to avoid the cross origin request issue.
// It assumes the API supports POST.
// JsonResult is an ASP.NET MVC construct.
private JsonResult ProxyRequest(string url, string data)
{
HttpWebRequest wr = (HttpWebRequest)HttpWebRequest.Create(url);
wr.Method = "POST";
wr.ContentType = "application/json";
@ryankirkman
ryankirkman / cross_domain_proxy.js
Created May 30, 2012 10:13
Call an external JSON API via a local cross domain proxy
// See: http://api.jquery.com/jQuery.ajaxPrefilter/
$.ajaxPrefilter( function( options ) {
if ( options.crossDomain ) {
var newData = {};
// Copy the options.data object to the newData.data property.
// We need to do this because javascript doesn't deep-copy variables by default.
newData.data = $.extend({}, options.data);
newData.url = options.url;
// Reset the options object - we'll re-populate in the following lines.
@ryankirkman
ryankirkman / total_rows.sql
Created July 12, 2012 00:11
Get the total number of rows in all user tables (Microsoft SQL Server)
-- Sourced from: http://decipherinfosys.wordpress.com/2007/02/13/counting-number-of-records-for-all-the-tables-sql-server/
-- with only slight modifications
SELECT SUM(ind.rows) AS Total_Rows_in_all_user_tables
FROM sysobjects AS obj
INNER JOIN sysindexes AS ind
ON obj.id = ind.id
WHERE obj.xtype = 'u'
AND ind.indid < 2
@ryankirkman
ryankirkman / SqlServerTableCreatorFromODBC.cs
Created July 12, 2012 00:28
Generate a Microsoft SQL Server Table from an ODBC Data Source table and bulk copy its contents. For my real world use case (servers on the same LAN) I get ~6800 rows / second for a 2 million record dataset when using this class via the Parallel class in
using System;
using System.Data.Odbc;
using System.Data.SqlClient;
namespace ODBC_Import
{
// Sourced from: http://darrylagostinelli.com/2011/06/27/create-a-sql-table-from-a-datatable-in-c-net/
// with modifications for copying from an ODBC data source
class SqlServerTableCreator
{
// You need to have the following installed:
// https://github.com/admc/wd
// https://github.com/kriskowal/q
// https://github.com/holidayextras/node-saucelabs
var wd = require('wd')
, Q = require('q')
, assert = require('assert')
, sauce = require('saucelabs')
, host = "ondemand.saucelabs.com"