Skip to content

Instantly share code, notes, and snippets.

__author__ = 'bordy'
def checkio(data):
if (len(data)<10) or (data==data.upper()) or (data==data.lower()):
return False
else:
digits = [i for i in data if i in [str(x) for x in range(10)]]
if digits == []:
return False
else:
@bordy
bordy / Untitled.py
Created July 15, 2014 16:13
Untitled.py
import bs4
import requests
cath_resp = requests.get('http://www.reddit.com/r/Catholicism/top/')
soup = bs4.BeautifulSoup(cath_resp.text)
print(soup.prettify())
@bordy
bordy / Untitled 1.py
Created November 13, 2013 16:26
Untitled 1
def find_primes(num):
i = 2
while i * i < num:
while num % i == 0:
num = num/i
i = i + 1
print num

Deploying an app for the first time

Remotely:

sudo mkdir /var/www/dashboard.app
sudo chown -R deploy:deploy /var/www/dashboard.app/

Locally:

cap deploy:setup

sass_dir = ask("Where would you like to keep your sass files within your project? (default: 'app/stylesheets')")
sass_dir = "app/stylesheets" if sass_dir.blank?
css_dir = ask("Where would you like Compass to store your compiled css files? (default: 'public/stylesheets')")
css_dir = "public/stylesheets" if css_dir.blank?
compass_command = "compass --rails . --css-dir=#{css_dir} --sass-dir=#{sass_dir} "
file 'vendor/plugins/compass/init.rb', <<-CODE
# This is here to make sure that the right version of sass gets loaded (haml 2.2) by the compass requires.

Rails Dev Stack on Snow Leopard

(from a scratch install). Kinda, I imported my user home (~) from a Time Machine backup.

Homebrew

sudo mkdir /usr/local
sudo chown -R `whoami` /usr/local
curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C /usr/local
SSH_ENV=$HOME/.ssh/environment
function start_agent {
echo "Initializing new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > ${SSH_ENV}
echo succeeded
chmod 600 ${SSH_ENV}
. ${SSH_ENV} > /dev/null
/usr/bin/ssh-add;
}
require 'rubygems'
require 'money'
require 'yaml'
class Array
def total_hashes
self.inject({}) do |totals, hsh|
hsh.each { |key, value| (totals[key] = totals[key] ? value + totals[key] : value) unless %w(String Hash Array).include?(value.class.to_s) } if hsh.is_a?(Hash)
totals
#!/usr/bin/env ruby
v = RUBY_VERSION.match(/^1\.9/) ? "18" : "19"
%w{ruby irb gem erb ri rdoc}.each do |c|
system "sudo ln -fs /usr/local/bin/#{c+v} /usr/local/bin/#{c}"
end
system "ruby --version"
# Notes on Deploying Rails with Passenger on Ubuntu 9.04 and ruby 1.9
ssh root@0.0.0.0
adduser deploy
adduser deploy sudo
visudo
# uncomment or add the line: %sudo ALL=NOPASSWD: ALL