Welcome to Python 101 at PyOhio 2013!
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
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D | |
rails_env = ENV['RAILS_ENV'] || 'production' | |
# 16 workers and 1 master | |
worker_processes (rails_env == 'production' ? 16 : 4) | |
# Load rails+github.git into the master before forking workers | |
# for super-fast worker spawn times | |
preload_app 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
Factory.define :application do |factory| | |
factory.attachment(:sample, "public/samples/sample.doc", "application/msword") | |
end |
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/python | |
#usage python show.py <local_port> | |
''' | |
Taken from: https://gist.github.com/932137 (found in http://news.ycombinator.com/item?id=2467107 ) | |
Let's say you have a webapp running in localhost (with `manage.py runserver` in django or `ruby script.rb` in sinatra or `rails server` or whatever) and you want others to be able to see it with a public url without deploying remotely. | |
ssh provides a neat facility for that: tunneling. You set up a "tunnel" from the remote host to yours and vice-versa and then you give the remote host's url and it will send all of its requests to your local daemon. |
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
# Usage: show <local-port> <subdomain> | |
function show() { | |
DOMAIN=".webhostology.com" | |
REMOTE="$2$DOMAIN" | |
ssh -tR 8080:127.0.0.1:$1 vps "sudo ssh -Nl \$USER -L $REMOTE:80:127.0.0.1:8080 localhost" | |
} |
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
var safariDebug = ( navigator.platform.indexOf("iPhone") < 0 && navigator.platform.indexOf("iPod") < 0 && navigator.platform.indexOf("iPad") < 0 ); | |
if(safariDebug) | |
{ | |
PhoneGap.run_command = function() | |
{ | |
if (!PhoneGap.available || !PhoneGap.queue.ready) | |
return; |
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 can copy this into IRB or just run it as a file | |
require "net/http" | |
require "uri" | |
url = "http://localhost:3000/login" | |
yaml = %{ --- !ruby/object:Time {} } | |
xml = %{<?xml version="1.0" encoding="UTF-8"?><foo type="yaml">#{yaml}</foo>}.strip | |
uri = URI.parse(url) |
These are a list of scripts sampled for Python 101 for PyOhio 2013.
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
package main | |
import ( | |
"log" | |
"net/mail" | |
"encoding/base64" | |
"net/smtp" | |
"fmt" | |
"strings" |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout. This is also called reflow or layout thrashing, and is common performance bottleneck.
elem.offsetLeft
,elem.offsetTop
,elem.offsetWidth
,elem.offsetHeight
,elem.offsetParent
elem.clientLeft
,elem.clientTop
,elem.clientWidth
,elem.clientHeight
elem.getClientRects()
,elem.getBoundingClientRect()
OlderNewer