Skip to content

Instantly share code, notes, and snippets.

View togakangaroo's full-sized avatar

George Mauer togakangaroo

View GitHub Profile
@togakangaroo
togakangaroo / jquery-ui-shim-uninitializedWidgetBridge.js
Created November 1, 2012 19:20
Shim to revert updated jQuery Ui Widget Bridge to older behavior
var slice = Array.prototype.slice;
var _originalBridge = $.widget.bridge;
$.widget.bridge = function (name, object) {
var fullName = object.prototype.widgetFullName;
$.fn[name] = function (options) {
var isMethodCall = typeof options === "string",
args = slice.call(arguments, 1),
returnValue = this;
@togakangaroo
togakangaroo / Wrap-InMigrationTemplate.ps1
Created November 12, 2012 23:03
Generate ScriptSync wrapped files
param(
[Parameter(Position=0,Mandatory=1)] [string]$name,
[Parameter(Position=1,Mandatory=1)] [string]$appVersion,
[Parameter(Position=2,Mandatory=1)] $script,
[string]$globalVersion = '1.0 - 01'
)
@"
--Will cause the transaction to abort if any errors are thrown for statements within it
SET XACT_ABORT ON
GO
@togakangaroo
togakangaroo / knockoutifyUnderscore
Created December 26, 2012 23:44
Make a limited set of underscore functions transparently unwrap knockout observables while not affecting non-observables
//make a limited set of underscore functions transparently unwrap knockout observables
(function knockoutifyUnderscore(_) {
var unwrap = ko.utils.unwrapObservable;
//These can be shimed in a standard way
var koFriendly = ['map', 'filter', 'find', 'each', 'findBy', 'first', 'last', 'head', 'tail', 'union', 'compact', 'flatten', 'difference', 'without'];
var oldMap = _.map;
for (var _i = 0; _i < koFriendly.length; _i++) {
(function(fnName) {
var originalFn = _[fnName];
@togakangaroo
togakangaroo / Generate List off Numbers.sql
Created June 28, 2013 16:05
Generate a list of numbers in sql server. Cause I aalways forget how to do this.
SELECT TOP 10 ROW_NUMBER() OVER (order by id) FROM sysobjects
@togakangaroo
togakangaroo / knockout.dialog.js
Last active December 20, 2015 07:49
dialog binding for doing dialogs in an mvvm manner.
// Elements with this binding will appear as a jquery ui dialog when the bound value exists
// This binding works similar to the 'with' data-binding in that its contents will only exist when its bound parameter is truthy.
// Also like with, it will start a new binding context.
// Unlike the 'with' binding, when the contents are visible this will not appear in place but instead be initialized in a
// jquery ui dialog. This dialog will close if the bounded value becomes falsy. Conversely, if the bound value is observable,
// closing the dialog will empty the observable.
var dialogDomDataKey = '__ko_dialogBindingData';
ko.bindingHandlers.dialog = {
init: function(el, valueAccessor) {
var $el = $(el)
!function(){
//Initialize a jQuery Ui Widget on this element.
//<button id="click-here" data-bind="widget: {name: 'button' options: 'label:\'Click Here\', disabled: true'}, click: doSomething">Click Here</button>
//will have the same effect as
//<button id="click-here" data-bind="click: doSOmething">Click Here</button>
//<script>$(function(){ $('#click-here').button(label: 'Click Here'), disabled: true })</script>
//In the more common case when options are not needed you may simply write
//<button id="click-here" data-bind="widget: 'button', click: doSomething">Click Here</button>
ko.bindingHandlers.widget = {
init: function(el, valueAccessor){
@togakangaroo
togakangaroo / defr-promise-converter
Last active December 25, 2015 03:09
defr little flow control library to turn callback apis into promises
w = window
w.defr = (fnOrCtx, fnOrUndef) ->
ctx = if fnOrUndef then fnOrCtx else window
fn = if fnOrUndef then fnOrUndef else fnOrCtx
submittedArgs = null
getDeferredGenerator = (_.find(defr.conversions, (c)->c.canAdapt fn, ctx)?.adapt || defr.defaultConversion)
getDeferred = _.wrap getDeferredGenerator(fn, ctx), (fn, args...) ->
submittedArgs = _.toArray args
fn.apply @, args
@togakangaroo
togakangaroo / hgignore for .net
Created November 6, 2013 19:05
.hgignore for .net
syntax: glob
# Ignore Visual Studiofiles
*.obj
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
@togakangaroo
togakangaroo / Transfer-SvnToHgCommits.ps1
Created November 7, 2013 16:17
Check out a range of Subversion revisions and recommit them to Mercurial
<#
.SYNOPSIS
Check out a range of Subversion revisions and recommit them to Mercurial
.DESCRIPTION
In the case where you already have an svn and an hg repository and you are transferring commits from one to the other (this is relevant when slowly transitioning svn to hg) you might get in a situation where several commits are made to the svn repository but not to the hg one. In this case you might want to check these out of svn one by one and re-commit to mercurial. This script automates the process.
This script requires an svn and an hg command to exist in your powershell environment. You can do this (assuming Tortoise) by adding 'C:\Program Files\TortoiseSVN\bin' and 'C:\Program Files\TortoiseHg' to your PATH or setting up the appropriate aliases.
.PARAMETER FromRevision
SVN revision to start checking out at.
.PARAMETER FromRevision
SVN revision to stop checking out at.
$tempDir = ([system.io.path]::GetTempPath())
Import-Module pscx 2>$null
$Pscx:Preferences['TextEditor'] = 'C:\Program Files\Sublime Text 3\subl.exe'
set-alias edit Edit-File -Scope Global
Set-Alias vim 'C:\Program Files (x86)\vim\vim74\vim.exe'
Set-Alias vi vim
Import-Module z
#if(-not $env:OwPassword) {