Skip to content

Instantly share code, notes, and snippets.

View yucao24hours's full-sized avatar
🎀
Learning DNS

Yuka Kato yucao24hours

🎀
Learning DNS
View GitHub Profile
@npj
npj / gist:2044147
Created March 15, 2012 13:16
Rack IP Filter + HTTP Basic Auth
class FilterAuth < ::Rack::Auth::Basic
def initialize(app, options = { }, realm=nil, &authenticator)
super(app, realm, &authenticator)
@ip_filter = ::Rack::Access.new(app, options)
end
def call(env)
# only need to do auth if the ip filter blocks the request
response = @ip_filter.call(env)
@metaskills
metaskills / wait_until.rb
Last active May 2, 2024 01:51
Never sleep() using Capybara!
# WAIT! Do consider that `wait` may not be needed. This article describes
# that reasoning. Please read it and make informed decisions.
# https://www.varvet.com/blog/why-wait_until-was-removed-from-capybara/
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations?
describe 'Modal' do
should 'display login errors' do
visit root_path
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active April 14, 2025 11:07
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh