Here is a checklist to follow if you want maximum battery life -- for instance if you're about to get on a long plane flight.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PEP: 423 | |
Title: Naming conventions and recipes related to packaging | |
Version: $Revision$ | |
Last-Modified: $Date$ | |
Author: Benoît Bryon <benoit@marmelune.net> | |
Discussions-To: <distutils-sig@python.org> | |
Status: Deferred | |
Type: Informational | |
Content-Type: text/x-rst | |
Created: 24-May-2012 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Create a RAM disk with same perms as mountpoint | |
# Script based on http://itux.idev.pro/2012/04/iservice-speed-up-your-xcode-%D0%BD%D0%B5%D0%BA%D0%BE%D1%82%D0%BE%D1%80%D1%8B%D0%B5-%D1%81%D0%BF%D0%BE%D1%81%D0%BE%D0%B1%D1%8B/ with some additions | |
# Usage: sudo ./xcode_ramdisk.sh start | |
USERNAME=$(logname) | |
TMP_DIR="/private/tmp" | |
RUN_DIR="/var/run" | |
SYS_CACHES_DIR="/Library/Caches" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httplib | |
import base64 | |
import contextlib | |
import simplejson | |
import urllib | |
from django.conf import settings | |
def stripe_fetch(resource, method='GET', params=None, secret=settings.STRIPE_SECRET, prefix='/v1'): |
Sequel::Factory implements a tiny DSL on Sequel::Model that allows you to create factories for objects of a model class. A factory is simply a Ruby block that gets evaluated each time a new object is generated. Inside the block you can call methods that correspond to the names of attributes of the object you're creating. If a value is given to the method, it will set the value for that attribute. Regardless, the method will always return the current value for that attribute.
Factories have names (the default name is :default
) and you can include a factory in another. When you do this, the included factory will run first.
A simple factory for a User
class might look like this:
User.factory do
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import math | |
def calculate_orthodromic_distance(pointA, pointB): | |
""" | |
Calculates the great circle distance between two points. | |
The great circle distance is the shortest distance. | |
This function uses the Haversine formula : | |
- https://en.wikipedia.org/wiki/Haversine_formula |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Parse (absolute and relative) URLs. | |
urlparse module is based upon the following RFC specifications. | |
RFC 3986 (STD66): "Uniform Resource Identifiers" by T. Berners-Lee, R. Fielding | |
and L. Masinter, January 2005. | |
RFC 2732 : "Format for Literal IPv6 Addresses in URL's by R.Hinden, B.Carpenter | |
and L.Masinter, December 1999. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'matrix' | |
require 'lingua/stemmer' | |
require 'csv' | |
require 'erb' | |
require 'iconv' | |
require 'sanitize' | |
require './cleaner.rb' | |
STEMMER = Lingua::Stemmer.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
NB: this is works-for-me quality code, completely not suitable for production. | |
Please use it as inspiration, but please test it better than I have before | |
you use it in your own projects! | |
""" | |
from django import db | |
from django.conf import settings | |
from django.db import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 Jed Schmidt <http://jed.is> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |