Skip to content

Instantly share code, notes, and snippets.

View ryankirkman's full-sized avatar

Ryan Kirkman ryankirkman

View GitHub Profile
@ryankirkman
ryankirkman / ZumeroResult.cs
Last active December 18, 2015 08:29
Parse the Zumero result string described at http://zumero.com/docs/zumero_core.html#zumero_sync into a strongly typed class
using System;
namespace ZumeroUtils
{
public class ZumeroResult
{
public int Partial { get; private set; }
public int Quarantine { get; private set; }
public int BytesUpFull { get; private set; }
public int BytesDownFull { get; private set; }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System.Collections.ObjectModel;
using System.Reflection;
namespace Destrier
{
// 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"
// 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"
@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
{
@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 / 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 / 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";
byDateGroup: {
map: function(doc) {
if (doc.date && (doc.group == "group1" || doc.group == "group2")) {
emit(doc.date, null);
}
}
}
@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]