Skip to content

Instantly share code, notes, and snippets.

@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

@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 / .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 / 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 / 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 / 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 / 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 / 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 / gist:3920278
Created October 19, 2012 19:43
Everything you can override in a refinerycms project with refinerycms-blog
When starting a project that includes refinerycms-blog:
$ rake refinery:override view=refinery/pages/*
$ rake refinery:override view=layouts/*
$ rake refinery:override view=refinery/blog/shared/*
$ rake refinery:override view=refinery/blog/posts/*
$ rake refinery:override view=refinery/*
$ rake refinery:override controller=refinery/blog/*
$ rake refinery:override controller=refinery/*
@sweded
sweded / auth.md
Created November 9, 2012 19:29
The definitive guide to forms based website authentication

PART I: How To Log In

  1. As a rule, [CAPTCHAs][1] should be a last resort. They tend to be annoying, often aren't human-solvable, most of them are ineffective against bots, all of them are ineffective against cheap third-world labor (according to [OWASP][2], the current sweatshop rate is $12 per 500 tests), and some implementations are technically illegal in some countries (see link number 1 from the MUST-READ list). If you must use a CAPTCHA, use [reCAPTCHA][3], since it is OCR-hard by definition (since it uses already OCR-misclassified book scans).

  2. It is possible to prevent browsers from storing/retrieving a password with the autocomplete tag for forms/input fields. However in the real world, your customers will have many accounts on different systems; it compromises their security if they use the same password for every site. Can you expect them to remember different passwords for every site? There are some good password managers out there, however there are also bad ones - which will become a