Skip to content

Instantly share code, notes, and snippets.

View gregmac's full-sized avatar

Greg MacLellan gregmac

View GitHub Profile
@gregmac
gregmac / gist:2255984
Created March 30, 2012 22:06
Miniprofiler javascript side
(function(){
var init = function() {
var load = function(s,f){
var sc = document.createElement("script");
sc.async = "async";
sc.type = "text/javascript";
sc.src = s;
var l = false;
sc.onload = sc.onreadystatechange = function(_, abort) {
@gregmac
gregmac / gist:2646830
Created May 9, 2012 17:13
Hubot script for subway's sub of the day
# Subway sub of the day
#
# subway me - See today's sub of the day
module.exports = (robot) ->
#"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"
subofday = ["Oven Roasted Chicken Breast","Steak & Cheese","Subway Melt","Sweet Onion Chicken Teryaki","Turkey Breast","Tuna","Subway Club"]
robot.respond /(subway|sub of (the )?day)/i, (msg) ->
msg.reply subofday[(new Date()).getDay()]
@gregmac
gregmac / readme.md
Last active December 19, 2015 06:39 — forked from jkp/readme.md

Want to fork your own gists? No fork button? No problem!

Install this Gist by saving to disk (click "Raw"), and then locate it on your machine, and drag it to your Extensions tab in Chrome.

@gregmac
gregmac / error.php
Last active December 19, 2015 08:59
Simple php script for getting a HTTP server to return a specific HTTP status code for testing purposes. Go to error.php/501 to get a 501 error, etc.
<?php
$http_codes = array(
100 => 'Continue',
101 => 'Switching Protocols',
102 => 'Processing',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
@gregmac
gregmac / CallTargetsParallel.tasks
Last active August 29, 2015 13:56
MSBuild CallTargetsParallel task
<!--=======================================================================================
Licensed under BSD (http://opensource.org/licenses/bsd-license.php)
Copyright (c) 2014, Greg MacLellan
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
@gregmac
gregmac / SingleCall.cs
Created March 27, 2014 22:17
SingleCall - method singleton
/// <summary>
/// Creates a wrapper that ensures a passed method can only be invoked once, even if
/// called on multiple threads. If invocation has already started by another thread,
/// blocks until that the actual call is complete.
/// </summary>
public class SingleCall
{
private readonly object _lock = new object();
private bool called = false;
@gregmac
gregmac / gist:10157265
Created April 8, 2014 17:08
sp_spaceused alternative
-- Returns the same results of MS SQL Server sp_spaceused, but in a single result set
select
-- from first result set of 'exec sp_spacedused'
db_name() as [database_name]
,ltrim(str((convert (dec (15,2),sf.dbsize) + convert (dec (15,2),sf.logsize)) * 8192 / 1048576,15,2) + ' MB') as [database_size]
,ltrim(str((case when sf.dbsize >= pages.reservedpages then
(convert (dec (15,2),sf.dbsize) - convert (dec (15,2),pages.reservedpages))
* 8192 / 1048576 else 0 end),15,2) + ' MB') as [unallocated space]
@gregmac
gregmac / jira-paste-tablizied.js
Last active August 29, 2015 13:58
JIRA paste table helper
/*
Listens for a paste event into a JIRA wiki textarea
If there is at least one tab and newline in the pasted text,
and then every line contains the same number of tabs,
it is turned into a table using JIRA wiki markup syntax.
By Greg MacLellan, 2014-04-09. BSD License.
*/
jQuery('textarea.wiki-textfield').live('paste', function() {
var self = jQuery(this);
var originalText = self.val();
@gregmac
gregmac / signtool.msbuild.tasks
Created December 12, 2014 01:40
SignTool MSBuild Task
<!--
Sign .exe files using signtool.exe.
(c) 2014 Greg MacLellan, Licensed under MIT http://opensource.org/licenses/MIT
Features:
* Hides password from being displayed in build output
* Retries against multiple timestamp servers if the server returns an invalid response (fairly common)
Usage:
@gregmac
gregmac / gist:977437ce7fd49d7a0475
Last active August 29, 2015 14:11
Make Windows 8 Not Suck

For my own reference, settings that are necessary to make Windows 8/8.1 nice.

Start menu

StartIsBack or Start8. Either work, and this is absolutely essential.

Disable forced auto-update

This inevitably happens during something important. Glad to see MS forces updates -- but... I will restart when I restart.