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
# The initial was for Varnish 2.1, this has been updated for Varnish 3. | |
# The upgrade changes were based on the docs here: | |
# https://www.varnish-cache.org/docs/3.0/installation/upgrade.html | |
# https://www.varnish-cache.org/docs/2.1/tutorial/vcl.html | |
# https://www.varnish-cache.org/trac/wiki/VCLExamples | |
# Summary | |
# 1. Varnish will poll the backend at /health_check to make sure it is | |
# healthy. If the backend goes down, varnish will server stale content | |
# from the cache for up to 1 hour. |
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
Varnish Admin: | |
varnishtop -i txurl | |
varnishadm -T 127.0.0.1:6082 url.purge // Purge all cache (requires authentication) | |
varnishadm "ban req.url ~ /" | |
Varnish Test: | |
sudo apt-get install libwww-perl && GET -Used http://localhost:6081/index.html |
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
dig www.domain.com +nostats +nocomments +nocmd |
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
1. Use on loop each_with_index | |
<% if index % 4 == 0 %> | |
# do stuff | |
<% 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
backend default { | |
.host = "127.0.0.1"; | |
.port = "8080"; | |
.connect_timeout = 600s; | |
.first_byte_timeout = 600s; | |
.between_bytes_timeout = 600s; | |
} | |
acl purge { | |
"localhost"; |
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
require "sinatra/base" | |
require "sinatra/namespace" | |
require "multi_json" | |
require "api/authentication" | |
require "api/error_handling" | |
require "api/pagination" | |
module Api | |
class Base < ::Sinatra::Base |
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
### /script/background_jobs | |
#!/usr/bin/env bash | |
cd $(dirname $0)/.. | |
app_root=$(pwd) | |
sidekiq_pidfile="$app_root/tmp/pids/sidekiq.pid" | |
sidekiq_logfile="$app_root/log/sidekiq.log" | |
app_user=$(ls -l config.ru | awk '{print $3}') | |
function stop { |
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
### lib/tasks/cache.rake | |
namespace :cache do | |
desc "Clear redis cache" | |
task :clear => :environment do | |
Rails.cache.clear | |
end | |
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
scp -r user@your.server.example.com:/path/to/foo /home/user/Desktop/ | |
scp -i mykey.pem somefile.txt root@ec2-184-73-72-150.compute-1.amazonaws.com:/ |
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
function getURLParameters(url) { | |
var result = {}; | |
var searchIndex = url.indexOf("?"); | |
if (searchIndex == -1 ) return result; | |
var sPageURL = url.substring(searchIndex +1); | |
var sURLVariables = sPageURL.split('&'); | |
for (var i = 0; i < sURLVariables.length; i++) | |
{ | |
var sParameterName = sURLVariables[i].split('='); |
OlderNewer