Skip to content

Instantly share code, notes, and snippets.

@macinnir
macinnir / KendoUIJS
Last active October 9, 2015 18:17
Kendo UI Example
<html>
<head>
<title></title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="js/kendo.web.min.js"></script>
<style type="text/css">
<!--
.active { display: list-item; }
.inactive { display: none; }
@macinnir
macinnir / JQuery Validation
Created August 31, 2012 20:22
General application of JQuery Validate
/* Method for validating Zip Code */
/* Requires Jquery-latest and Jquery-Validation plugin (http://docs.jquery.com/Plugins/Validation) */
$.validator.addMethod('client_zip_cb',
function(value){
/* Apply validation code */
return value == '99999'
},
'Please enter 99999 for the zip code!'
);
@macinnir
macinnir / 0_reuse_code.js
Created April 25, 2014 07:02
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@macinnir
macinnir / object-array-loop-fail.js
Created March 12, 2015 06:08
Extending Object and Array and the unexpected results in looping
/**
* Object/Array native objects being extended via prototype produces unexpected results when
* when looping through objects/arrays respectively.
* @author Rob MacInnis
* @see http://stackoverflow.com/questions/10695506/adding-function-to-object-prototype-causes-function-to-show-up-in-all-for-x-in
*/
require('colors');
// Extending a native JS object
@macinnir
macinnir / bash-profile.sh
Last active August 29, 2015 14:20
Bash Profile
#!/bin/bash
# System-wide .profile for sh(1)
# A portion taken from http://vvv.tobiassjosten.net/git/add-current-git-branch-to-your-bash-prompt/
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
c_reset=`tput sgr0`
c_user=`tput setaf 2; tput bold`
c_path=`tput setaf 4; tput bold`
c_git_clean=`tput setaf 2`
c_git_dirty=`tput setaf 1`
else
@macinnir
macinnir / dynamically
Last active December 8, 2015 22:08
Dynamically call method on object in C#
var t = model.GetType();
var mth = t.GetMethod(action);
if (mth != null)
{
try
{
mth.Invoke(model, new object[] { });
}
catch(AmbiguousMatchException)
{
@macinnir
macinnir / CSharpDiagnostics.cs
Created December 9, 2015 09:11
C# Diagnostics
// Framework version
Console.Write(typeof(string).Assembly.ImageRuntimeVersion);
// C# Version
C:\Windows\Microsoft.NET\Framework\v4.0.30319>csc /?
package main
import (
"fmt"
"math"
)
func quadratic(a, b, c float64) (d, e float64) {
@macinnir
macinnir / .gitconfig
Created August 28, 2022 17:33
.gitconfig
# Taken from https://stackoverflow.com/questions/1838873/visualizing-branch-topology-in-git/34467298#34467298
[alias]
lg = lg1
lg1 = lg1-specific --all
lg2 = lg2-specific --all
lg3 = lg3-specific --all
lg1-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
lg2-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
lg3-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'