View gist:2234066
To insert the new rule before others (i.e. allow's) in the list: | |
ufw insert 1 deny from a.b.c.d | |
To check the placement: | |
ufw status numbered |
View ipn.rb
class Ipn < ActiveRecord::Base | |
belongs_to :user | |
serialize :message_data, Hash | |
# | |
# Return true if this is a payment. | |
# | |
def payment? | |
return paypal_subscription_payment? || weblaws_payment? | |
end |
View gist:3936252
[7] pry(main)> include Magick | |
=> Object | |
[8] pry(main)> ls | |
self.methods: include private public to_s | |
locals: _ _dir_ _ex_ _file_ _in_ _out_ _pry_ | |
[9] pry(main)> ls -g | |
global variables: $! $" $$ $& $' $* $+ $, $-0 $-a $-d $-F $-i $-I $-K $-l $-p $-v $-W $-w $. $/ $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $: $; $< $= $> $? $@ $\ $_ $` $CODERAY_DEBUG $DEBUG $DEBUG_BEFORE $FILENAME $fileutils_rb_have_lchmod $fileutils_rb_have_lchown $KCODE $LOAD_PATH $LOADED_FEATURES $PROGRAM_NAME $SAFE $stderr $stdin $stdout $VERBOSE $~ | |
[10] pry(main)> Image | |
=> Magick::Image | |
[11] pry(main)> |
View .sh
# Heroku Convenience Aliases | |
alias precompile='rake assets:precompile; git add -f public/assets/manifest.yml; git commit -m manifest' | |
alias migrate='heroku run rake db:migrate' | |
alias clear_cache='heroku run rake cache:clear' | |
alias deploy='precompile; git push heroku master; migrate; clear_cache' |
View svn-to-git.rb
require 'Time' | |
require 'Nokogiri' | |
# | |
# svn-to-git | |
# | |
# Sync an svn repo to git. | |
# | |
# Checks for svn updates. If there are none, does | |
# nothing. Otherwise, commits & pushes the latest |
View capybara cheat sheet
=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') |
View slurp-text-file.rb
contents = File.open('file.txt') { |f| f.read } |
View slurp-text-file.py
with open('file.txt') as f: contents = f.read() |
View for-loop.rb
an_array.each { |item| puts item } | |
# or | |
an_array.each do |item| | |
puts item | |
end | |
# or |
View variable-length-argument-list.rb
func(1, 2, 3, 4, 5) | |
# The argument with the "splat operator" denotes | |
# a variable number of arguments which will be | |
# placed into an array. | |
def func(arg1, arg2, *other_args) | |
p arg1.inspect # => 1 | |
p arg2.inspect # => 2 | |
p other_args.inspect # => [3, 4, 5] | |
end |
OlderNewer