Skip to content

Instantly share code, notes, and snippets.

pre {outline: 1px solid #ccc; padding: 5px; margin: 5px; }
.string { color: green; }
.number { color: darkorange; }
.boolean { color: blue; }
.null { color: magenta; }
.key { color: red; }
@jonathancounihan
jonathancounihan / ko.subscribeChanged .js
Last active August 29, 2015 14:02
knockout subscribeChanged (Thanks to mbest!)
ko.subscribable.fn.subscribeChanged = function (callback) {
var savedValue = this.peek();
return this.subscribe(function (latestValue) {
var oldValue = savedValue;
savedValue = latestValue;
callback(latestValue, oldValue);
});
};
@jonathancounihan
jonathancounihan / ko.bindingHandlers.iCheck
Created June 25, 2014 09:42
knockout binding for iCheck
ko.bindingHandlers.iCheck = {
init: function (element, valueAccessor) {
var $el = $(element);
var observable = valueAccessor();
$el.iCheck({
radioClass: 'iCheck_radio_class',
inheritClass: true
});
$el.on('ifClicked', function (e) {
  1. Plain Strings (207): foo
  2. Anchors (208): k$
  3. Ranges (202): ^[a-f]*$
  4. Backrefs (201): (...).*\1
  5. Abba (169): ^(.(?!(ll|ss|mm|rr|tt|ff|cc|bb)))*$|^n|ef
  6. A man, a plan (177): ^(.)[^p].*\1$
  7. Prime (286): ^(?!(..+)\1+$)
  8. Four (199): (.)(.\1){3}
  9. Order (198): ^[^o].....?$
  10. Triples (507): (^39|^44)|(^([0369]|([147][0369]*[258])|(([258]|[147][0369]*[147])([0369]*|[258][0369]*[147])([147]|[258][0369]*[258])))*$)
@jonathancounihan
jonathancounihan / knockout html
Last active August 29, 2015 14:04
knockout iCheck binding
<div>
<label>
<input type="checkbox" data-bind="iCheckBox: SmokerCheckBox" />
<span class="icheck-label">&nbsp;Is Smoker</span>
</label>
</div>
<div data-bind="text: ko.toJSON(vm)">
</div>
@jonathancounihan
jonathancounihan / dupfinder.cmd
Last active August 29, 2015 14:11
How to use JetBrains Duplicate Finder with using Twitter Bootstrap Styling.
pushd "C:/Projects/Software/Dev/"
"C:\Tools\jb-commandline-8.0.0.39\dupfinder.exe" /idle-priority /show-stats /show-text /debug /normalize-types /exclude-code-regions="Windows Form Designer generated code;Component Designer generated code" /o="dupfinder.%date%.xml" /e="**/*.Designer.cs;**/*.generated.cs;**/Model.cs;**/Reference.cs" "C:/Projects/Software/Dev/SolutionName.sln"
popd
@jonathancounihan
jonathancounihan / GenerateJsonFromGitLog.ps1
Last active October 12, 2016 19:45
Generate json from git logs in powershell
<#
Generate the change log in json
#>
param(
[ValidateSet("True","False", 0, 1)]
[ValidateNotNullOrEmpty()]
[string]$OutputAsString = "False",
[string]$OutputFilename = "changelog.json",
[string]$GitDirectory = ""
)
@jonathancounihan
jonathancounihan / RoboCopyWithErrorChecking.ps1
Created October 7, 2016 10:37
Robocopy From powershell
function InvokeRoboCopyCommandWithErrorChecking ($command, $errorMessage) {
$global:LASTEXITCODE = 0
[int[]]$errorCodes = @(8,16)
#Write-Host $command
Invoke-Expression $command -ErrorAction Stop
$roboCopyExitCode = $global:LASTEXITCODE;
# Below is taken from http://stackoverflow.com/questions/21428632/powershell-bitwise-comparison-for-robocopy-exit-codes
@jonathancounihan
jonathancounihan / XE_Dynamic_Shred__LongRunningQueries
Created December 12, 2016 09:24 — forked from mbourgon/XE_Dynamic_Shred__LongRunningQueries
Using Extended Events to find long-running queries, with a dynamic XML shred and PIVOT to simplify the code
--written by MDB and ALM for TheBakingDBA.Blogspot.Com
-- basic XE session creation written by Pinal Dave
-- http://blog.sqlauthority.com/2010/03/29/sql-server-introduction-to-extended-events-finding-long-running-queries/
-- mdb 2015/03/13 1.1 - added a query to the ring buffer's header to get # of events run, more comments
-- mdb 2015/03/13 1.2 - added model_end events, filtering on hostname, using TRACK_CAUSALITY, and multiple events
-- mdb 2015/03/18 1.3 - changed header parse to dynamic, courtesy of Mikael Eriksson on StackOverflow
-- This runs on at 2008++ (tested on 2008, 2008R2, 2012, and 2014). Because of that, no NOT LIKE exclusion
------------------------------
-- Create the Event Session --
------------------------------
@jonathancounihan
jonathancounihan / index.html
Created November 20, 2017 10:43 — forked from nimbupani/index.html
Showing latest post on home page with Jekyll
---
layout: default
---
<div class="blog-index">
{% assign post = site.posts.first %}
{% assign content = post.content %}
{% include post_detail.html %}
</div>