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 / api_blueprint_notes.md
Created March 6, 2014 14:15
API Blueprint Language notes

API Blueprint

Start with:

FORMAT: 1A
@n3dst4
n3dst4 / bash_here.bat
Last active August 29, 2015 14:04
Start bash in Console2 with $HOME set to a folder of your choice
@echo off
rem If Windows's idea of $HOME is wrong for you, you can use
rem Console2 and instead of using bash directly, use this batch
rem file instead. It will set $HOME to wherever it is located.
set PATH=%PATH%;%~dp0
set HOME=%~dp0
rem adjust path to suit
@n3dst4
n3dst4 / requireTime.js
Created August 13, 2014 08:15
Time how long all your require()s take
/*
* requireTime.js
*
* require()s every thing in your node_modules and tells you how long each one
* took.
*
* USAGE:
* $ cd your_project_folder
* $ node loadTest.js
*
@n3dst4
n3dst4 / browserify_transforms.markdown
Created September 22, 2014 07:52
Troubleshooting how Browserify transforms get applied (i.e. why isn't my code getting processed by Reactify?)

If you're using Browserify and Reactify to write React components and build them for the browser, you may, depending on your setup, see errors along the lines of "unexpected token <", which means that your code is not getting Reactified properly. You will either see this in Gulp, because some subsequent step in the pipeline can't parse your code, or in the browser.

Here's how browserify decides how to apply transforms:

  1. Anything specified when you actually call browserify (i.e. in a gulpfile or on the command line) will be run first. Calls here can specify {global: true}, which will make them be applied to dependencies as well as code in the current module.
  2. If there is a browserify.transform key in package.json, it can list transforms which should be applied, in the order that they should be applied.

You need to specify reactify before anything else which is going to want to parse the code, because obvs. it isn't valid es5 until it's been reactified (so e.g. having `["browserify-shim", "reactify"

@n3dst4
n3dst4 / dw-sorter.clj
Created August 2, 2015 16:22
DW sorter
(defn episode-number [file]
(def match (re-matches
#"\d{4}-\d{2}-\d{2} - (S\d\d E\d\d) - .*"
(.getName file)))
(if (= match nil)
nil
(match 1)))
(def episodes (partition-by episode-number files))
@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 / 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
{