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
@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;
@n3dst4
n3dst4 / nginx-0.8.54-installer.py
Created March 26, 2011 09:14 — forked from robflaherty/nginx-0765-installer.txt
Webfaction install script for nginx 0.8.54
-----BEGIN WEBFACTION INSTALL SCRIPT-----
#!/bin/env python2.7
"""
Nginx 0.8.54 Installer New
"autostart": not applicable
"extra info": Enter domain name for the nginx app
"""
@n3dst4
n3dst4 / bypassing_c_sharp_accessmodifiers.cs
Created March 21, 2011 15:10
How to use reflection to bypass access modifiers and execute a private method of an ancestor.
using System.Reflection;
private object ExecutePrivateMethod(string name, params object[] args)
{
MethodInfo method =
GetType().BaseType.GetMethod(name, BindingFlags.NonPublic | BindingFlags.Instance);
if (method == null)
throw new NotImplementedException("Cannot find method " + name);
return method.Invoke(this, args);
@n3dst4
n3dst4 / screening.js
Last active March 28, 2019 16:16 — forked from rmurphey/screening.js
Rebecca Murphey's JS screening questions. Answers below.
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
@n3dst4
n3dst4 / count_jquery.js
Created August 3, 2010 08:40
jQuery-counting bookmarklet
(function (g) {
var v = [],
i=0,
j=g.jQuery,
d=g.$;
while (g.jQuery) {
v.push(g.jQuery.fn.jquery);
g.jQuery.noConflict(true);
i++ ;
}