Skip to content

Instantly share code, notes, and snippets.

@thzinc
thzinc / gzip.js
Created June 3, 2016 00:40 — forked from kig/gzip.js
TarGZ = function(){};
// Load and parse archive, calls onload after loading all files.
TarGZ.load = function(url, onload, onstream, onerror) {
var o = new TarGZ();
o.onload = onload;
o.onerror = onerror;
o.onstream = onstream;
o.load(url);
return o;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
namespace Sonorous.Core.Services
{
public static class StructExtensions
{
public delegate bool TryParseDelegate<T>(string input, out T value);
@thzinc
thzinc / test-gateway.sh
Created February 21, 2015 01:17
Test Spreedly Gateway
#!/bin/bash
ENVIRONMENT_KEY=Spreedly_Environment_Key
SECRET=Spreedly_Secret
GATEWAY=Spreedly_Gateway_Token
echo Tokenize request
curl https://core.spreedly.com/v1/payment_methods.json\?environment_key=$ENVIRONMENT_KEY \
-H 'Origin: http://localhost' \
-H 'X-Requested-With: XMLHttpRequest' \
-H 'Content-Type: application/json' \
@thzinc
thzinc / Add numbered bullet points to li items.jquery.js
Created April 10, 2013 13:48
jQuery-based JavaScript to add numbers to each <li/> element in a document. (Particularly useful for HTML generated by FreeMind)
(function($) {
$("li").each(function(i, e) {
var current = $(e);
var parent = current.parents("li");
var id = [];
if (parent.length) {
id = parent.data("id").map(function(e) { return e; });
id.push(current.prevAll("li").length + 1);
}
@thzinc
thzinc / status.sql
Last active December 16, 2015 00:28
T-SQL query to get information from SQL Server 2008 (and R2) about all running requests, along with percentage of completion. Originally got it from a blog somewhere... Can't remember whose it was.
SELECT
r.session_id,
t.text,
r.status,
r.command,
database_name = DB_NAME(r.database_id),
r.cpu_time,
r.total_elapsed_time,
r.percent_complete
FROM sys.dm_exec_requests r
@thzinc
thzinc / sortabletable.js
Created April 9, 2013 16:44
Quick jQuery-powered script to make tables sortable if they have a <thead/> and <th/> elements.
(function($) {
$(function() {
function sortTable(event) {
var header = $(event.currentTarget);
var column = header.prevAll().length;
var table = header.closest("table");
var body = table.find("tbody");
var rows = body.find("tr");