Skip to content

Instantly share code, notes, and snippets.

Avatar

Niclas Darville ndarville

View GitHub Profile
@ndarville
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
ndarville / business-models.md
Last active Oct 22, 2020
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.
View business-models.md

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@ndarville
ndarville / webm.md
Last active Oct 20, 2020
4chan’s guide to converting GIF to WebM - https://boards.4chan.org/g/res/41212767
View webm.md

Grab ffmpeg from https://www.ffmpeg.org/download.html

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
ndarville / secret-key-gen.py
Created Aug 24, 2012
Generating a properly secure SECRET_KEY in Django
View secret-key-gen.py
"""
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 `settings.py`
This snippet
1. uses `SystemRandom()` instead to generate a random key
2. saves a local `secret.txt`
@ndarville
ndarville / README.md
Last active Sep 15, 2020
From CSV to HTML table (Simple)
View README.md

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
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)\Battle.net\Battle.net"
start /min "" "%LOCALAPPDATA%\Discord\app-0.0.297\Discord.exe"
@ndarville
ndarville / README.md
Last active May 18, 2020
Confidence Interval
View README.md

(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
ndarville / settings.py
Last active Apr 13, 2020
Django on Travis CI
View settings.py
"""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
ndarville / README.md
Last active Mar 15, 2020
How to export and rehost your Tumblr site
View README.md

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
ndarville / examples.mdown
Last active Dec 9, 2019
“We’ve Been Hacked” Boilerplate Announcement
View examples.mdown

How Companies Communicated Being Hacked

Evernote

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.

Twitter

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.