Skip to content

Instantly share code, notes, and snippets.

View ndarville's full-sized avatar

N. Darville ndarville

  • Europe
View GitHub Profile
@ndarville
ndarville / sordid-crysis2-physics
Created March 6, 2011 17:59
Sordid Crysis 2 variables
variable: cc_breast_gravity
type: float
current: -9
help: Gravity for breast simulation.
variable: cc_breast_lowerDamper
type: float
current: 1
help: Lower damper for breast simulation.
@ndarville
ndarville / diff.mdown
Created July 23, 2012 20:33
Paul Heckel's Diff Algorithm

[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 / secret-key-gen.py
Created August 24, 2012 17:01
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 `settings.py`
This snippet
1. uses `SystemRandom()` instead to generate a random key
2. saves a local `secret.txt`
@ndarville
ndarville / django-pagination.html
Created September 2, 2012 15:45
Django Pagination Code
{% if page.has_other_pages %}
<div class="pagination">
<!-- Older page -->
{% if page.has_previous %}
<a href="?page={{ page.previous_page_number }}" title="Go to the older threads.">&lt;&nbsp;Older</a>
{% endif %}
<!-- First page -->
{% if current_page > 4 %}
<a href="?page=1">1</a>&nbsp;&#8943;
@ndarville
ndarville / settings.py
Last active April 13, 2020 08:18
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
ndarville / idiomatic-d3js.mdown
Created October 7, 2012 00:44
Idiomatic d3.js JavaScript

Assigning Variables

When assigning variables, instead of doing this:

var r = 3;
var h = 5;
var l = 10;
var padding = 15;
@ndarville
ndarville / Procfile
Created November 12, 2012 13:31
Django on Heroku
web: gunicorn myproject.wsgi -b 0.0.0.0:$PORT
# web: sh ...
@ndarville
ndarville / sublime_settings.js
Created November 24, 2012 16:36
Sublime 2 Settings
{
"color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme",
"tab_size": 4,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"ensure_newline_at_eof_on_save": true,
"default_line_ending": "unix"
@ndarville
ndarville / sublime_bindings.js
Created November 24, 2012 16:46
Sublime Text 2 Key Bindings
[
// Swaps the default behaviour of copy-pasting code
// to automatically indent pasted code properly
// Mac
{ "keys": ["super+v"], "command": "paste_and_indent" },
{ "keys": ["super+shift+v"], "command": "paste" },
// Windows
{ "keys": ["ctrl+v"], "command": "paste_and_indent" },
{ "keys": ["ctrl+shift+v"], "command": "paste" }
]
@ndarville
ndarville / installed_apps_order_test.py
Created November 30, 2012 12:34
Testing the order of your installed Django apps
from django.conf import settings
from django_nose import FastFixtureTestCase as TestCase
def get_apps():
apps = {}
for i, app in enumerate(settings.INSTALLED_APPS):
apps[app] = i