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
# section1.1.7 from SICP written in python .. was just making sure I understood how it all worked. | |
def square(x): | |
return x * x | |
def sqrt_iter(guess, x): | |
if good_enough(guess, x): | |
return guess | |
else: | |
return sqrt_iter(improve(guess, x), x) |
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
server { | |
2 listen 98.129.237.54:80; | |
3 server_name www.mysite.com; | |
4 rewrite ^/(.*) http://mysite.com/$1 permanent; | |
5 } | |
6 | |
7 server { | |
8 listen 98.129.237.54:80; | |
9 server_name mysite.com; | |
10 |
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
# Place this in its own file and add it to your `AUTHENTICATION_BACKENDS` setting in settings.py | |
from django.conf import settings | |
from django.contrib.auth.models import User | |
class EmailModelBackend(object): | |
def authenticate(self, username=None, password=None): | |
kwargs = {'email': username} | |
try: |
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
# This configuration assumes you are running some kind of PHP FastCGI daemon to send for processing. | |
# I've commented parts of the file for clarity if someone does not understand what's going on. | |
# Here we simply rewrite the `www` out of the domain name because it's useless in most cases. | |
# Totally optional. | |
server { | |
listen 80; | |
server_name www.example.com; | |
rewrite ^/(.*) http://example.com/$1 permanent; | |
} |
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
#!/usr/bin/env python | |
""" | |
PDF To Image Converter Class. | |
The base of this script was derived from the pdfpeek package by David Brenneman: | |
http://pypi.python.org/pypi/collective.pdfpeek | |
Simply wanted something in a single file. Could use a bit of adjustments in | |
how files are saved, but this was mostly playing around to see how previewing PDF files works. |
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
def get_primes(n): | |
numbers = set(range(n, 1, -1)) | |
primes = [] | |
while numbers: | |
p = numbers.pop() | |
primes.append(p) | |
numbers.difference_update(set(range(p*2, n+1, p))) | |
return primes |
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
""" | |
This program is free software: you can redistribute it and/or modify | |
it under the terms of the GNU General Public License as published by | |
the Free Software Foundation, either version 3 of the License, or | |
(at your option) any later version. | |
This program is distributed in the hope that it will be useful, | |
but WITHOUT ANY WARRANTY; without even the implied warranty of | |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
GNU General Public License for more details. |
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
/* | |
* A simple Google maps Javascript widget which will display a map and | |
* a marker with the ability to move the marker, then setting the | |
* lat/lng of the marker into the specified (or default) fields. | |
*/ | |
var google_map_location = new function() { | |
var jQuery; | |
var init_options; | |
var geocoder; |
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
""" | |
If you're having trouble building node.js on OSX (Snow Leopard seems to be problematic here) with an error like this: | |
"""" | |
$ brew install node | |
==> Downloading http://nodejs.org/dist/node-v0.4.2.tar.gz | |
File already downloaded and cached to /Users/bartekc/Library/Caches/Homebrew | |
==> ./configure --prefix=/usr/local/Cellar/node/0.4.2 | |
==> make install | |
........ |
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
{"Canada": "+1", "East Timor": "+670", "Réunion": "+262", "Montenegro": "+382", "Mali": "+223", "Cambodia": "+855", "Switzerland": "+41", "Ethiopia": "+251", "Saudi Arabia": "+966", "Aruba": "+297", "Swaziland": "+268", "Argentina": "+54", "Cameroon": "+237", "Wallis and Futuna Islands": "+681", "Bahrain": "+973", "Korea, Democratic People's Republic of": "+850", "Mayotte": "+262", "Haiti ": "+509", "Bosnia and Herzegovina": "+387", "Micronesia, Federated States of": "+691", "Jordan": "+962", "United States": "+1", "United States Minor Outlying Islands": "+1", "Trinidad and Tobago": "+1-868", "Greece": "+30", "Burkina Faso": "+226", "Senegal ": "+221", "Cuba (Guantanamo Bay)": "+5399", "Guantanamo Bay": "+5399", "Togo": "+228", "Spain": "+34", "Liberia": "+231", "French Antilles": "+596", "Nepal": "+977", "Tanzania, United Republic of": "+255", "Martinique": "+596", "Hungary": "+36", "Christmas Island": "+61-8", "French Guiana": "+594", "Niue": "+683", "Monaco": "+377", "Chatham Island (New Zealand)": "+64", |
OlderNewer