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 bottle | |
def check(user, passwd): | |
if user == 'ben': | |
return True | |
return False | |
@bottle.route('/') | |
@bottle.auth_basic(check) | |
def index(location): |
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 urllib2, base64 | |
(user, password) = ('ben', 'xyz') | |
request = urllib2.Request("http://localhost:8080/") | |
base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '') | |
request.add_header("Authorization", "Basic %s" % base64string) | |
result = urllib2.urlopen(request) | |
print result.read() |
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
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine | |
# This is how I upload my new Sol Trader builds (http://soltrader.net) | |
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash | |
S3KEY="my aws key" | |
S3SECRET="my aws secret" # pass these in | |
function putS3 | |
{ | |
path=$1 |
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 | |
import sys | |
import pika | |
connection = pika.BlockingConnection(pika.ConnectionParameters( | |
'localhost')) | |
channel = connection.channel() | |
channel.queue_declare(queue='hello', durable=True) |
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
curl \ | |
--digest \ | |
--user-agent "MyCurlClient/1.0" \ | |
-o data/metadata.xml \ | |
--show-error \ | |
--dump-header data/headers.txt \ | |
-u "username:password" \ | |
--header "RETS-Version: RETS/1.5" \ | |
--cookie-jar data/cookies.txt \ | |
--cookie data/cookies.txt \ |
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
''' | |
Determination of the day of the week | |
Jan 1st 1 AD is a Monday in Gregorian calendar. | |
So Jan 0th 1 AD is a Sunday [It does not exist technically]. | |
Every 4 years we have a leap year. But xy00 cannot be a leap unless xy divides 4 with reminder 0. | |
y/4 - y/100 + y/400 : this gives the number of leap years from 1AD to the given year. As each year has 365 days (divdes 7 with reminder 1), unless it is a leap year or the date is in Jan or Feb, the day of a given date changes by 1 each year. In other case it increases by 2. | |
y -= m<3 : If the month is not Jan or Feb, we do not count the 29th Feb (if it exists) of the given year. | |
So y + y/4 - y/100 + y/400 gives the day of Jan 0th (Dec 31st of prev year) of the year. (This gives the reminder with 7 of the number of days passed before the given year began.) |
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
Go to: chrome://settings/searchEngines | |
Add a new search engine with the following settings | |
Gif | Gif | https://www.google.com/search?q=%s&tbm=isch&tbs=itp:animated | |
Type gif in the address bar press TAB and enter your search query |
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 sys | |
from boto.sqs.connection import SQSConnection | |
conn=SQSConnection('AWS_ACCESS_KEY_ID','AWS_SECRET_KEY') | |
q=conn.get_queue(sys.argv[1]) | |
attrib = q.get_attributes("ApproximateNumberOfMessages") | |
print int(attrib['ApproximateNumberOfMessages']) |
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
# Debian 7 x64, Ubuntu 14.04 x64, Ubuntu 12.04.4 x64 | |
*NOTE (tested on Digital Ocean VM's w/ > 512MB of RAM - gcc runs out of memory on VM's <= 512 MB) | |
apt-get update | |
aptitude safe-upgrade | |
apt-get install build-essential libboost-all-dev libcurl4-gnutls-dev autoconf antlr swig python-dev | |
*NOTE (for python 3 support add 'python3-dev' to the end of line 5) | |
cd /tmp | |
wget https://github.com/NationalAssociationOfRealtors/libRETS/archive/1.6.1.tar.gz |
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 ldap | |
def check_credentials(username, password): | |
"""Verifies credentials for username and password. | |
Returns None on success or a string describing the error on failure | |
# Adapt to your needs | |
""" | |
LDAP_SERVER = 'ldap://xxx' | |
# fully qualified AD user name | |
LDAP_USERNAME = '%s@xxx.xx' % username |
OlderNewer