Skip to content

Instantly share code, notes, and snippets.

View seyhunak's full-sized avatar
🏆
Winning The Life

Seyhun Akyürek seyhunak

🏆
Winning The Life
View GitHub Profile
@seyhunak
seyhunak / default.vcl
Last active August 29, 2015 13:55 — forked from ethier/default.vcl.pl
Varnish 3 - VCL
# 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.
@seyhunak
seyhunak / varnish_commands.sh
Last active August 29, 2015 13:55
Varnish Commands
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
@seyhunak
seyhunak / unix.sh
Created February 6, 2014 08:42
Collection of useful Unix scripts
dig www.domain.com +nostats +nocomments +nocmd
@seyhunak
seyhunak / erb.html.erb
Created February 6, 2014 15:43
Erb Tricks
1. Use on loop each_with_index
<% if index % 4 == 0 %>
# do stuff
<% end %>
@seyhunak
seyhunak / default.vcl
Created February 10, 2014 17:46 — forked from benclark/default.vcl
Varnish - Mobile Dedection
backend default {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 600s;
.first_byte_timeout = 600s;
.between_bytes_timeout = 600s;
}
acl purge {
"localhost";
@seyhunak
seyhunak / base.rb
Created February 15, 2014 13:49 — forked from bensie/base.rb
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
@seyhunak
seyhunak / background_jobs
Created February 19, 2014 08:49
Sidekiq - Background jobs - Rake - Inıt Script
### /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 {
@seyhunak
seyhunak / cache.rake
Created February 19, 2014 08:50
Cache Clear - Rake - Task
### lib/tasks/cache.rake
namespace :cache do
desc "Clear redis cache"
task :clear => :environment do
Rails.cache.clear
end
end
@seyhunak
seyhunak / scp_copy.sh
Created March 12, 2014 09:47
Copying files between local and remote
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:/
@seyhunak
seyhunak / get_url_parameters.js
Created March 18, 2014 15:58
Get url parameters with Javascript
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('=');