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
# This is an example of how to use xtables / xt_geoip to block requests | |
# based on their source/destination country. | |
# | |
# It can be computationally expensive to have tons of iptables rules. | |
# According to the bottom of the following page, this xt_geoip is probably | |
# about as efficient as can be for doing this kind of thing: | |
# http://xtables-addons.sourceforge.net/geoip.php | |
# Install packages | |
apt-get install xtables-addons-common libtext-csv-xs-perl unzip |
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/env ruby | |
require 'yaml' | |
puts "How many sections?" | |
number_of_sections = Integer(gets) | |
data = YAML.load(DATA) | |
data['start'] = data['end'] + 1 | |
data['end'] += number_of_sections |
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
<div id="wufoo-p1nx3plw0skd0cb"> | |
Fill out my <a href="https://westarete.wufoo.com/forms/p1nx3plw0skd0cb">online form</a>. | |
</div> | |
<script type="text/javascript">var p1nx3plw0skd0cb;(function(d, t) { | |
var s = d.createElement(t), options = { | |
'userName':'westarete', | |
'formHash':'p1nx3plw0skd0cb', | |
'autoResize':true, | |
'height':'620', | |
'async':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
$ echo 'puts "hi"' > hello.rb | |
$ irb | |
irb(main):001:0> require 'hello' | |
LoadError: cannot load such file -- hello | |
from /Users/woods/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' | |
from /Users/woods/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' | |
from (irb):1 | |
from /Users/woods/.rbenv/versions/2.2.2/bin/irb:11:in `<main>' |
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
~/westarete/src/flip-learning | 30248d7 | master | |
[532] $ echo 'puts "hi"' > hello.rb | |
~/westarete/src/flip-learning | 30248d7 | master* | |
[533] $ irb | |
irb(main):001:0> require 'hello' | |
LoadError: cannot load such file -- hello | |
from /Users/woods/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' | |
from /Users/woods/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' | |
from (irb):1 |
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
class User | |
has_many :things | |
has_many :sub_things, through: :things | |
has_many :sub_sub_things, through: :sub_things | |
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
# This lives in config/initializers/current_partner.rb | |
# A global method to return the current partner | |
def current_partner | |
Partner.current | |
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
irb(main):006:0* class Dog | |
irb(main):007:1> def bark | |
irb(main):008:2> puts "Ruff!!" | |
irb(main):009:2> end | |
irb(main):010:1> def age | |
irb(main):011:2> 12 | |
irb(main):012:2> end | |
irb(main):013:1> end | |
=> :age | |
irb(main):014:0> |
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
# A helper for determining which partner site we're on. This can be | |
# used for setting a CSS class on the body tag in the layout, or | |
# for referencing namespaced assets or translations. | |
def parner(host=request.host) | |
if $ENV['PARTNER'] == 'graduate' || host =~ /graduate/i | |
'graduate' | |
elsif $ENV['PARTNER'] == 'schreyer' || host =~ /schreyer/i | |
'schreyer' | |
else | |
# decide whether to fail or default to one of the above |
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
# Include this module into your fake models to get some helpful default functionality. | |
# | |
# Example usage: | |
# | |
# class AuxiliaryOfficer | |
# include FakeModel | |
# | |
# attr_accessor :name, :started_on, :comments | |
# | |
# def self.fake_attributes |