Install chef gem (for knife command):
gem install chef
knife cookbook create my_cookbook
| # NB: `req` is a Rack::Request object (basically an env hash with friendly accessor methods) | |
| # Throttle 10 requests/ip/second | |
| # NB: return value of block is key name for counter | |
| # falsy values bypass throttling | |
| Rack::Attack.throttle("req/ip", :limit => 10, :period => 1.second) { |req| req.ip } | |
| # Block cloud IPs from accessing PATH regexp | |
| Rack::Attack.block "bad_ips from logging in" do |req| |
| # -*- encoding: utf-8 -*- | |
| $:.unshift '.' | |
| require 'bsearch' | |
| Gem::Specification.new do |s| | |
| s.name = 'bsearch-ruby' | |
| s.version = BSearch::VERSION | |
| s.authors = ["Aaron Suggs"] | |
| s.description = "A binary search implementation in ruby" |
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require 'bundler/setup' | |
| require 'octokit' | |
| require 'yaml' | |
| commit = ARGV.first || 'HEAD' | |
| full_sha = `git rev-parse --verify #{commit}`.strip |
| source 'https://rubygems.org' | |
| gem 'rack-attack', :ref => '1c01e6097ce18f486d887ebbeb9f0c4b434cd8f5', :git => 'https://github.com/kickstarter/rack-attack.git' | |
| gem 'redis-activesupport' |
| require 'thor' | |
| module Thor | |
| class CommandFailedError < Error; end | |
| module Actions | |
| # runs command, raises CommandFailedError unless exit status is 0. | |
| def run_or_die(command, config={}) | |
| result = run(command, config) | |
| if behavior == :invoke && $?.exitstatus != 0 | |
| message = "#{command} failed with %s" % ($?.exitstatus ? "exit status #{$?.exitstatus}" : "no exit status (likely force killed)") |
| # First blacklist checks for /etc/password, and counts hits in cache | |
| blacklist 'etc/password' do | |
| if req.query_string =~ %r{/etc/passwd} | |
| Fail2Ban.fail('etc_password', req.ip, limit: 3, period: 24.hours, ban_for: 24.hours) | |
| end | |
| end | |
| # 2nd blacklist checks for banned IPs in cache | |
| blacklist 'banned_ips' do | |
| Fail2Ban.banned?(req.ip) |
| #!/usr/bin/env ruby | |
| ## | |
| # Restore simplenote backup | |
| # | |
| # If you want to restore your Simplenote for Mac database, you can use this script. | |
| # I created it for this issue: | |
| # http://help.simplenote.com/customer/en/portal/questions/2773965-most-of-my-notes-were-deleted?new=2773965 | |
| # | |
| # First, find a good backup of your simplenote database stored in |
The asset pipeline changed a bit in Rails4, and I've never been super happy w/ the egads approach to tar'ing assets.
So here's my idea for a better approach.
Features:
| FROM ubuntu:14.04 | |
| MAINTAINER aaron@ktheory.com | |
| RUN apt-get update | |
| RUN apt-get install -y build-essential libssl-dev curl | |
| # Install ruby-build | |
| RUN export ruby_build_release=20140420 && \ |