Skip to content

Instantly share code, notes, and snippets.

View NickJosevski's full-sized avatar

Nick Josevski NickJosevski

View GitHub Profile
@NickJosevski
NickJosevski / parseUri.coffee
Created August 23, 2012 06:16 — forked from mrclay/UFCOE.parseUri.js
Parse a URI using the browser's DOM (CoffeeScript)
class UriHelpers
parseUri: (url) ->
k = window.Common.UrlHelpers.UriParseModes
a || (a = window.document.createElement('a'))
#Let browser do the work
a.href = url
r = {}
r[k[i]] = a[k[i]] for i in [0..8]
@NickJosevski
NickJosevski / site_create.ps1
Created August 22, 2012 12:51
Multiple IIS site creation, via PowerShell
Write-Host "Remember to run in an x86 Powershell"
Import-Module WebAdministration
$start_dir = Get-Location
CD IIS:\
New-Item AppPools\test.pool
Set-ItemProperty IIS:\AppPools\test.pool -name "enable32BitAppOnWin64" -Value "true"
@NickJosevski
NickJosevski / git.config
Created August 15, 2012 00:28
Beyond Compare .GitConfig
## .gitconfig
[alias]
dt = difftool
mt = mergetool
[diff]
tool = bc3
[difftool]
prompt = false
[difftool "bc3"]
@NickJosevski
NickJosevski / hg-to-git-merge.sh
Created May 17, 2012 06:13
A neat migration bash script for migration of Hg to Git, from Paul Jenkins
Requirements: Hg, Hg-Git, Git Bash
#!/bin/sh
hg clone $2 $1
cd $1
hg bookmark -r default master
hg gexport
mv .hg/git .git
rm -rf .hg
git init
@NickJosevski
NickJosevski / myview.js.coffee
Created March 8, 2012 00:36 — forked from tarnacious/myview.js.coffee
backbone example - serialize form + update on change
window.MyView = Backbone.View.extend({
initialize: ->
_.bindAll(this,'render')
this.template = window.JST["MyView"]
this.model.bind('change', this.render)
render: ->
$(this.el).html(this.template(this.model.toJSON()))
events: {
@NickJosevski
NickJosevski / jquery.load.example.js
Created February 9, 2012 22:13
Load() callback
$("#core").load(href, function () {
setupClicks();
});
function setupClicks() {
$("a").unbind("click", clickHandler);
$("a").on("click", clickHandler);
};
/* --- vs --- */
@NickJosevski
NickJosevski / feedreadingissue.cs
Created January 15, 2012 07:25
Doesn't work for funnelweb blogs, but works fine on feedburner feed and Wordpress feed.
//just paste this code in LinqPad (having selected Language: C# Program) and try and fix it ;)
void Main()
{
//demonstrating linq to xml handing of namespaces, using the feedburner style on Scott Hanselman's blog.
var request = (System.Net.HttpWebRequest) System.Net.WebRequest.Create(@"http://feeds.feedburner.com/ScottHanselman");
//this works:
using (var response = request.GetResponse())
{
@NickJosevski
NickJosevski / linq2xmlNameSpaceDemo.cs
Created January 14, 2012 11:55
linq to xml handing of namespaces on node selection
void Main()
{
//demonstrating linq to xml handing of namespaces, using the feedburner style on Scott Hanselman's blog.
var request = (System.Net.HttpWebRequest) System.Net.WebRequest.Create(@"http://feeds.feedburner.com/ScottHanselman");
using (var response = request.GetResponse())
{
var xmlDoc = XDocument.Load(response.GetResponseStream());
@NickJosevski
NickJosevski / NJ-QUnitTestBasics.js
Created January 5, 2012 10:14
Some QUnit basics as part of a blog post
/// more info: http://blog.nick.josevski.com/2012/01/05/unit-testing-javascript-methods-that-contain-jquery-ajax-calls
test("check if methodUnderTest completes successfully (mockJax way)", function () {
// Arrange
var jsonText = '{"id": "123","fieldName": "mj-fbs", "data": "fbs-text"}',
fieldBeingSaved = $('<input name="mj-fbs" Text="fbs-text"></input>'),
busyImg = $('<img id="mj-fbs-loading" alt="should-get-replaced-by-success-method"></img>');
$.mockjax({
@NickJosevski
NickJosevski / gist:1559695
Created January 4, 2012 11:42
Playing with Routes
routes.MapRoute("Shortcuts",
"{whereToGo}",
new
{
controller = "TheRouter",
action = "TryRoute"
});