Skip to content

Instantly share code, notes, and snippets.

View NickJosevski's full-sized avatar

Nick Josevski NickJosevski

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
function Select-Folder($message='Select a folder', $path = 0) {
$object = New-Object -comObject Shell.Application
$folder = $object.BrowseForFolder(0, $message, 0, $path)
if ($folder -ne $null) {
$folder.self.Path
}
}
function Add-Zip
@NickJosevski
NickJosevski / NSubIssueTests.cs
Created October 19, 2011 01:29
Mocking extension methods
//I saw this and thought there was a simple way around subbing extension methods
//http://blogs.clariusconsulting.net/kzu/how-to-mock-extension-methods/
//My choice of solution was to just refactor the IRepo interface
namespace NSubIssueTests
{
[TestFixture]
public class ExtensionOnInterfaceTests
{
@NickJosevski
NickJosevski / gist:1559695
Created January 4, 2012 11:42
Playing with Routes
routes.MapRoute("Shortcuts",
"{whereToGo}",
new
{
controller = "TheRouter",
action = "TryRoute"
});
@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 / 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 / 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 / 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 / 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 / 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