Skip to content

Instantly share code, notes, and snippets.


David Sanders shangxiao

View GitHub Profile
premek /
Last active May 8, 2022
Rename files in linux / bash using mv command without typing the full name two times
# Put this function to your .bashrc file.
# Usage: mv oldfilename
# If you call mv without the second parameter it will prompt you to edit the filename on command line.
# Original mv is called when it's called with more than one argument.
# It's useful when you want to change just a few letters in a long name.
# Also see:
# - imv from renameutils
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste)
alexhayes / Force All Email Delivery To A Single Email Address.rst
Last active Dec 8, 2015
Force all email delivery in Ubuntu to a particular address
View Force All Email Delivery To A Single Email Address.rst

Force All Email Delivery To A Single Email Address

So, you're a developer testing lots of codes and you want to ensure that you don't accidentally send out email to people during testing.

However, you also want to actually view emails in a real email client, not a console.

This is how you can do it using Ubuntu and Exim ensuring that the email gets sent out through Google apps.

kezabelle /
Created Sep 17, 2015
Just give me the damn Site when I need it mang.
from django.contrib.sites.shortcuts import get_current_site
from django.utils.functional import SimpleLazyObject
def current_site(request):
def wrapped_get_current_site():
return get_current_site(request=request)
return {
'CURRENT_SITE': SimpleLazyObject(wrapped_get_current_site),
staltz /
Last active Sep 28, 2022
The introduction to Reactive Programming you've been missing
branneman /
Last active Sep 20, 2022
Better local require() paths for Node.js

Better local require() paths for Node.js


When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

sloria /
Last active Sep 22, 2022
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General


  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
koniiiik / proposal.rst
Last active Mar 20, 2019
Google Summer of Code 2013 proposal: Composite Fields, vol. 2
View proposal.rst

Composite Fields, vol. 2


Two years ago, as part of GSoC 2011, I started working on an implementation of composite fields as a means to support multi-column primary keys in models. While the project was successful, the timeframe wasn't sufficient to finish it and get it into a state where it

dergachev /
Last active Sep 28, 2022
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF


To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

thomseddon / gist:3511330
Last active Mar 2, 2022
AngularJS byte format filter
View gist:3511330
app.filter('bytes', function() {
return function(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'],
number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
jlong / uri.js
Created Apr 20, 2012
URI Parsing with Javascript
View uri.js
var parser = document.createElement('a');
parser.href = "";
parser.protocol; // => "http:"
parser.hostname; // => ""
parser.port; // => "3000"
parser.pathname; // => "/pathname/"; // => "?search=test"
parser.hash; // => "#hash"; // => ""