Skip to content

Instantly share code, notes, and snippets.

Avatar

David Sanders shangxiao

View GitHub Profile
@premek
premek / mv.sh
Last active May 8, 2022
Rename files in linux / bash using mv command without typing the full name two times
View mv.sh
# 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
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
kezabelle / crapsite_contextprocessor.py
Created Sep 17, 2015
Just give me the damn Site when I need it mang.
View crapsite_contextprocessor.py
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
staltz / introrx.md
Last active Sep 28, 2022
The introduction to Reactive Programming you've been missing
View introrx.md
@branneman
branneman / better-nodejs-require-paths.md
Last active Sep 20, 2022
Better local require() paths for Node.js
View better-nodejs-require-paths.md

Better local require() paths for Node.js

Problem

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
sloria / bobp-python.md
Last active Sep 22, 2022
A "Best of the Best Practices" (BOBP) guide to developing in Python.
View bobp-python.md

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

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

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@koniiiik
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

Abstract

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
dergachev / GIF-Screencast-OSX.md
Last active Sep 28, 2022
OS X Screencast to animated GIF
View GIF-Screencast-OSX.md

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

Instructions

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

@thomseddon
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
jlong / uri.js
Created Apr 20, 2012
URI Parsing with Javascript
View uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"