Skip to content

Instantly share code, notes, and snippets.

@wtarr
wtarr / gist:4510579
Last active December 10, 2015 23:38
Git commands
#add a file
git add Transform.cs
#show list of branches
git branch
#create a branch
git branch mynewbranch
#switch to that branch
@wtarr
wtarr / gist:5860398
Created June 25, 2013 17:21
JQuery UI accordion mouseover to open and mouseleave to close.
$(function () {
$("#accordion").accordion({
heightStyle: "fill",
collapsible: true,
active: false,
event: "mouseover"
}).on('mouseleave', function () {
$(this).accordion("option", "active", false);
});
});
@wtarr
wtarr / gist:5860469
Created June 25, 2013 17:29
LINQ list join
var query = from o1 in list1
join o2 in list2
on o1.common equals o2.common
select new
{
o1.name,
o2.address,
o2.phone
};
@wtarr
wtarr / gist:5861509
Created June 25, 2013 19:21
MVC pass data from controller to a view.
//in the controller
IDictionary<string, int> performance = new Dictionary<string, int>();
performance.Add("cpu", 30);
return View(performance);
...
...
//in the view give the model its type
@model IDictionary<string, int>
@wtarr
wtarr / gist:5894837
Created June 30, 2013 11:34
Find percentage used physical memory - with aid of WMI code generator http://www.microsoft.com/en-ie/download/details.aspx?id=8572
using System;
using System.Management;
namespace WMIQuery
{
public class UsedPhysicalMemoryQuery
{
public static void Main()
{
try
@wtarr
wtarr / gist:5968890
Last active December 19, 2015 14:19
Open bootstrap modal on div click and build content via js - credit goes to http://stackoverflow.com/a/14577631 for the modal div click
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bootstrap, from Twitter</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
@wtarr
wtarr / gist:6069861
Created July 24, 2013 11:48
VBS -> C# translation of http://msdn.microsoft.com/en-us/library/windows/desktop/aa394317%28v=vs.85%29.aspx determine number socket / cores and display percent processor load for each core and total for the socket.
using System;
using System.Management;
namespace WMISample
{
public class MyWMIQuery
{
public static void Main()
{
try
@wtarr
wtarr / gist:6209058
Created August 12, 2013 08:25
Loading a embedded resource
var doc = new XmlDocument();
using (var stream = this.GetType().Assembly.GetManifestResourceStream("MyNameSpace.Configurations.xml"))
{
if (stream != null) doc.Load(stream);
}
_xmlcontents = doc.InnerXml;
@wtarr
wtarr / mockjaxsample.js
Last active December 21, 2015 01:59
Mockjax test: All calls to the server will be intercepted and replaced with the mockjax response text. Output will be MOCKJAX!!!! x 3
$(document).ready( function() {
$.mockjax({
// This should trigger a success and use my data
// as oppose to the data received from server
url: "http://localhost:8000/",
responseTime: 10,
dataType: 'text/json',
responseText: { "name" : "MOCKJAX!!!!" }
});
@wtarr
wtarr / qunittest.js
Created August 17, 2013 17:22
Qunit test of ko observable array after a (mocked) ajax call
module("module", {
setup: function () {
$.mockjax( {
url: "*",
responseTime: 1,
dataType: 'text/json',
responseText: [{'name' : 'wally'},{ "name":"molly" }]
});
},
teardown: function () {