Skip to content

Instantly share code, notes, and snippets.

View n3dst4's full-sized avatar
:octocat:
fgdxgfdxfg

Neil de Carteret n3dst4

:octocat:
fgdxgfdxfg
View GitHub Profile

1️⃣

🐦🍐🌳

2️⃣

🐢🐦 🐢🐦

🐦🍐🌳

@n3dst4
n3dst4 / gist:6621406
Last active December 23, 2015 10:29
{
// ...
Competition: '',
Participants: [
{
Name: "Manchester United",
Players: [
{
Name: "Fred Fredfredfred",
ShortName: "Fred",
@n3dst4
n3dst4 / co-contra-variance.cs
Created June 28, 2013 16:18
A walkthough of why .net people care about variance in generic type parameters
// generic type:
public class Bag<T> {}
// simple usage:
Bag<Fruit> myBag;
myBag = new Bag<Fruit>();
// so far so good
@n3dst4
n3dst4 / git_pretty
Created June 18, 2013 14:08
A very useful git alias, "git pretty" prints a coloured, branched diagram of your repository. Obviously there are graphical tools which will do this but if you're working from the command line it's handy not to have to fire up a whole new window. Run the command line below to add the alias to your global ".gitconfig". I also have the same comman…
git config --global --add alias.pretty "log --oneline --abbrev-commit --branches=* --graph --decorate"
@n3dst4
n3dst4 / web_config_ie_edge.xml
Last active December 17, 2015 19:58
Make IIS serve a header which will get IE into the latest standards mode
<!--
It's all about "forcing" with MS stuff. *Force* IIS to serve a header which will
*force* IE not to use it's shitty compatibility mode, even if it's an intranet
site and the client has "display intranet sites in compatibility view" ticked in
their compatibility prefs.
The alternative is to include the equivalent <meta http-equiv...> in your
markup, but that will sometimes be ignored.
This header is discouraged by MS for production environments. Then again, MS is
n3dst4@lesster2:~/438231 (master) $ date; w
Sun Mar 17 17:05:27 EDT 2013
17:09:52 up 4:18, 0 users, load average: 139.84, 120.85, 91.34
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
@n3dst4
n3dst4 / gist:3979599
Created October 30, 2012 10:53
Autofiller REST service
-->
POST /tasks/autofiller/101
{
object: {
id: 101,
description: 123,
building: 234,
site: 345,
reporter: 456
@n3dst4
n3dst4 / gist:3979183
Created October 30, 2012 09:15
Registering an exception handler
pageModel.registerExceptionHandler("FeedbackNeeded", function (exception, ready) {
doStuff(exception);
doSomethingAsynchronousWithACallback(function(response){
if (response.good) {
exception.handled = true;
}
ready(); // tell the exception broker we're ready to go on
});
});
public string ZoneDataJSON
{
get
{
var newCount = 0L;
if (EntityInstance.IsNew()) return BlankZoneDataJSON;
var members = IoCContainer.Resolve<IZoneService>().
GetImmediateZoneMembers(this.EntityId).ToList<IZoneMember>().
Select(mem => new
{
@n3dst4
n3dst4 / shortening.js
Created September 27, 2012 09:07
How to shorten some really wordy code
// Original: even without reading the code, it looked wrong. Lots of very
// obvious repetition. And switches are so often a code smell.
switch (modeName) {
case "Manual":
alert(self.options.messages.pleaseSet + self.options.messages.Manual);
break;
case "Automatic":
alert(self.options.messages.pleaseSet + self.options.messages.Automatic);
break;