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 / README.md
Last active February 19, 2016 16:29
Using node-retry to work around errors in Windows when using rimraf

Deleting a tree of folders using rimraf can be pretty fraught on MS Windows; the OS itself can lock files randomly, and there may be various processes getting in the way, like virus checkers or cloud file syncing apps. rimraf itself will do an exponential-backoff-and-retry for EBUSY and ENOTEMPTY errors on Windows, but you can still see EPERM and others. If you want to do exponential-backoff-and-retry for any error, see the below recipe, using node-retry.

@n3dst4
n3dst4 / api_blueprint_notes.md
Created March 6, 2014 14:15
API Blueprint Language notes

API Blueprint

Start with:

FORMAT: 1A
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) (float64, int) {
last := 0.0
z := 1.0
@n3dst4
n3dst4 / pathshrink.sh
Created November 9, 2013 13:12
This is a bash script for use in Windows (for use with Cygwin/Git Bash etc) to shrink foldernames on shitty windows. Since shitty windows's shitty FS allows you to create files with a path length greater than the maximum allowable path length (!) you can end up with an undeletable folder structure. This script recurses through and renames everyt…
#!/bin/bash
# set this to the problem folder
BASE=/c/Users/ndc/Dropbox/projects/delete-me
cd $BASE
for i in `find $BASE -depth`
do
DIR=`dirname $i`
FILE=`basename $i`
@n3dst4
n3dst4 / no_caching.cs
Created November 8, 2013 13:32
Disabling absolutely all caching on an ASP.NET MVC controller action. Because this is always so much ballache.
Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
Response.Cache.SetValidUntilExpires(false);
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
@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