Skip to content

Instantly share code, notes, and snippets.

@sweded
sweded / countLetters.py
Created October 16, 2012 21:57
As an exercise, encapsulate this code in a function named countLetters, and generalize it so that it accepts the string and the letter as arguments.
def countLetters(str, ch):
fruit = str
count = 0
for char in fruit:
if char == ch:
count = count + 1
print count
@sweded
sweded / revFruit.py
Created October 16, 2012 21:24
As an exercise, write a function that takes a string as an argument and outputs the letters backward, one per line.
fruit = "banana"
def revFruit(fruit):
index = len(fruit)-1
while index >= 0:
letter = fruit[index]
print letter
index = index - 1
@sweded
sweded / capypow.rb
Created September 21, 2012 22:55
Use Pow to For Cucumber Tests -> features/support/env.rb
Capybara.default_driver = :selenium # Subdomain testing will only work with pow and selenium
pow_config = "#{Rails.root}/.powenv" # Dont change, this is the Config Files Location.
pow_config_stash = "#{Rails.root}/.powenv_original" # This is what the config will be stashed as during testing.
Before do
# Set the default host
Capybara.app_host = "http://assessory.dev"
# Stash the existing config
@sweded
sweded / twitbastard.rb
Created August 29, 2012 18:23
tweet fetchin', Bastard style
require "open-uri"
remote_base_url =
"http://api.twitter.com/1/statuses/user_timeline.xml?count=100&screen_name="
twitter_user = "USAGov"
remote_full_url = remote_base_url + twitter_user
first_page = 1
last_page = 5
(first_page..last_page).each do |page_num|
@sweded
sweded / hack.sh
Created April 9, 2012 16:31 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@sweded
sweded / .inputrc
Created April 9, 2012 16:30 — forked from gregorynicholas/.inputrc
OSX .inputrc to make terminal way better. and by better i mean i'm naked
"\e[1~": beginning-of-line
"\e[4~": end-of-line
“\e[5~”: history-search-backward
“\e[6~”: history-search-forward
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
@sweded
sweded / md_cheat.txt
Created November 1, 2011 17:48
Markdown cheatsheet
MARKDOWN
# Header 1 #
## Header 2 ##
### Header 3 ### (Hashes on right are optional)
#### Header 4 ####
##### Header 5 #####
## Markdown plus h2 with a custom ID ## {#id-goes-here}
[Link back to H2](#id-goes-here)
@sweded
sweded / bash_shortcuts.md
Created November 1, 2011 17:47
Bash Shortcuts For Maximum Productivity

Bash Shortcuts Bash Shortcuts For Maximum Productivity

Command Editing Shortcuts

Ctrl + a – go to the start of the command line
Ctrl + e – go to the end of the command line
Ctrl + k – delete from cursor to the end of the command line
Ctrl + u – delete from cursor to the start of the command line
Ctrl + w – delete from cursor to start of word (i.e. delete backwards one word)
Ctrl + y – paste word or text that was cut using one of the deletion shortcuts (such as the one above) after the cursor