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 / 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++ ;
}
@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 / 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 / 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 / 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;
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 / 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
});
});
@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@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 / 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