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
In [64]: lines = [] | |
In [65]: l = glob.glob('/home/watson/Downloads/attorney_master/*.png') | |
In [66]: for file in l: | |
line = '<h3>'+file+'</h3>'+'<img style="page-break-after:always;" src="' + file + '"</img>' | |
lines.append(line) | |
....: | |
In [67]: f = open('/home/watson/Downloads/attorney_master/index.html', 'w') |
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
... | |
# ==> Configuration for any authentication mechanism | |
# Configure which keys are used when authenticating a user. The default is | |
# just :email. You can configure it to use [:username, :subdomain], so for | |
# authenticating a user, both parameters are required. Remember that those | |
# parameters are used only when authenticating and not when retrieving from | |
# session. If you need permissions, you should implement that in a before filter. | |
# You can also supply a hash where the value is a boolean determining whether | |
# or not authentication should be aborted when the value is not present. | |
config.authentication_keys = [ :login ] |
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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
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 | |
''' | |
Based on http://ginstrom.com/scribbles/2012/05/10/continuous-integration-in-python-using-watchdog/ | |
Dependencies: ``watchdog`` (pip install watchdog) | |
Montiors the whole tree for changes. | |
Check for all changes to any files and test the associated package; we might want to test changes to a pyramid test.ini, say, or a file rename as part of a refactor. |
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
from email.mime.text import MIMEText | |
from subprocess import Popen, PIPE | |
msg = MIMEText("You don't have to have password access to someone's email account to send email as them.") | |
msg["From"] = "FirstName LastName <[email protected]>" | |
msg["To"] = "FirstName LastName <[email protected]>, FirstName LastName <[email protected]>" | |
msg["Subject"] = "This is the subject." | |
p = Popen(["/usr/sbin/sendmail", "-t"], stdin=PIPE) | |
p.communicate(msg.as_string()) |
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
## The Problem | |
Standard practices say no non-root process gets to talk to the Internet on a port less than 1024. How, then, could I get Node talking on port 80 on EC2? (I wanted it to go as fast as possible and use the smallest possible share of my teeny tiny little micro-instance's resources, so proxying through nginx or Apache seemed suboptimal.) | |
## The temptingly easy but ultimately wrong solution: | |
Alter the port the script talks to from 8000 to 80: | |
}).listen(80); |
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 | |
# Ejabberd extauth : Authenticate phpbb users against PostgreSQL with Peewee | |
# Original Author: Lukas Kolbe <[email protected]> | |
import sys | |
import logging | |
import struct | |
from hashlib import md5 |
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
# Convert any YouTube video into an audio file you can listen to on the go, using: | |
# http://rg3.github.com/youtube-dl/ | |
{ ~ } > brew install ffmpeg | |
{ ~ } > wget https://raw.github.com/rg3/youtube-dl/2012.02.27/youtube-dl | |
{ ~ } > chmod u+x youtube-dl | |
# Pick which video format you want to download.. (use any YT video link) | |
{ ~ } > ./youtube-dl -s -F http://www.youtube.com/watch?v=vT1KmTQ-1Os |
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 d3py | |
import numpy as np | |
import pandas | |
T = 10 | |
df = pandas.DataFrame({ | |
"time" : range(T), | |
"pressure": np.random.rand(T), | |
"temp" : np.random.rand(T) | |
}) | |
print df |
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/ruby | |
show_unmerged = ARGV[0] == '-u' | |
branches = `git branch -r`.split("\n") | |
branches.each do |branch| | |
is_merged = `git branch --contains #{branch}` =~ /master/ | |
puts branch if show_unmerged ^ is_merged | |
end |