Skip to content

Instantly share code, notes, and snippets.


Niclas Darville ndarville

View GitHub Profile
ndarville / diff.mdown
Created Jul 23, 2012
Paul Heckel's Diff Algorithm
View diff.mdown

[Isolating Differences Between Files][paper]

Advantage over Other Algorithms

The diff output is more specific:

[I]f a whole block of text is moved, then all of it, rather than just the beginning and end, is detected as changed.

The algorithm described here avoids these difficulties. It detects differences that correspond very closely to our intuitive notion of difference.

ndarville /
Last active Oct 22, 2020
Business models based on the compiled list at I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models


Models Examples
Display ads Yahoo!
Search ads Google
ndarville /
Last active Oct 20, 2020
4chan’s guide to converting GIF to WebM -

Grab ffmpeg from

It's a command line tool which means you will have to type things with your keyboard instead of clicking on buttons.

The most trivial operation would be converting gifs:

ffmpeg -i your_gif.gif -c:v libvpx -crf 12 -b:v 500K output.webm
  • -crf values can go from 4 to 63. Lower values mean better quality.
  • -b:v is the maximum allowed bitrate. Higher means better quality.
ndarville /
Created Aug 24, 2012
Generating a properly secure SECRET_KEY in Django
Two things are wrong with Django's default `SECRET_KEY` system:
1. It is not random but pseudo-random
2. It saves and displays the SECRET_KEY in ``
This snippet
1. uses `SystemRandom()` instead to generate a random key
2. saves a local `secret.txt`
ndarville /
Last active Sep 15, 2020
From CSV to HTML table (Simple)

This code generates an HTML table based from a CSV file. This is from the tutorial by Christophe Viau.

In trying his code example, I discovered that the code doesn't work as-is, so I figured others might like to see a working d3.js example that did not rely on a pre-existing container HTML element.

The code remains the same except for some cosmetic tweaks.

The task of writing the CSS is left as an exercise for the reader.

ndarville / startup.bat
Last active Jun 24, 2020
Batch script to delay startup of applications after boot
View startup.bat
@echo off
timeout /t 120
start itunes
start /min %APPDATA%\Dropbox\bin\Dropbox.exe
start /min "" "C:\Program Files (x86)\\"
start /min "" "%LOCALAPPDATA%\Discord\app-0.0.297\Discord.exe"
ndarville /
Last active May 18, 2020
Confidence Interval

(This chart is a part of the d3-charts collection available [here][collection].)

This chart displays the share of votes over time between two Danish parliamentary coalitions using placeholder data. The chart here has been used for two coalitions, but can also be used for two candidates.

You will notice something enveloping the line charts, which is the [confidence interval][ci], which indicates the spectrum of the confidence in our displayed results---to use a completely unscientific definition.

Compare this to [Sam Wang's chart for the U.S. 2012 election][wang] and [Drew Linzer's charts for individual states][votamatic].

ndarville /
Last active Apr 13, 2020
Django on Travis CI
"""A basic database set-up for Travis CI.
The set-up uses the 'TRAVIS' (== True) environment variable on Travis
to detect the session, and changes the default database accordingly.
Be mindful of where you place this code, as you may accidentally
assign the default database to another configuration later in your code.
import os
ndarville /
Last active Mar 15, 2020
How to export and rehost your Tumblr site

How to export and rehost your Tumblr site

(Update: Version 3.2.0 of Jekyll looks like it's breaking a few things, so I've changed the guide to make you specifically install the version I was using, 3.1.3. I believe this is the issue: jekyll/jekyll#5145.)

You will be using jekyll-import to export your Tumblr site, Jekyll to (re)create it, and Surge to rehost it.

Update: You can also use Tumblr's native export feature in your blogs' individual settings. But rehosting that might be tricky. Read my comments below this post for how that works.

Setup and installation

ndarville / examples.mdown
Last active Dec 9, 2019
“We’ve Been Hacked” Boilerplate Announcement
View examples.mdown

How Companies Communicated Being Hacked


It’s probably a pretty bad idea to have your site go down, when people are supposed to read the blog post explaining the hack.


Notice how another site reporting the hack received more attention than Twitter’s own announcement. Why was that?

You can’t perform that action at this time.