Skip to content

Instantly share code, notes, and snippets.

@hitxiang
hitxiang / memcached_
Created August 14, 2012 05:51
Munin plugin which monitors several instances of Memcached
#!/usr/bin/perl
# -*- cperl -*-
#
# Plugin to monitor memcache statistics
#
# This module has 3 seperate graph datasets:
# rates
# bytes
# counters
#

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
d-i partman-auto/disk string /dev/sda
# Use LVM for partitioning
d-i partman-auto/method string lvm
# If one of the disks that are going to be automatically partitioned
# contains an old LVM configuration, the user will normally receive a
# warning. Preseed this away
d-i partman-lvm/device_remove_lvm boolean true
@hitxiang
hitxiang / rc.d
Created August 15, 2013 08:38 — forked from jippi/rc.d
update-rc.d logstash-shipper defaults
update-rc.d logstash-reader defaults
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods
@hitxiang
hitxiang / build.sbt
Created December 6, 2013 01:49 — forked from seratch/build.sbt
organization := "net.seratch"
name := "sandbox"
version := "0.1"
scalaVersion := "2.9.1"
libraryDependencies ++= Seq(
"junit" % "junit" % "4.9" withSources(),

How to purge ('ban') an entire domain in Varnish Cache 3

I thought I'd share this because it's taken me a couple of hours to work out and the documentation is not entirely clear.

Jump to answer

ban wtf?*

First of all, the purge method used to be called purge in Varnish 2.x but they renamed it to ban in 3.0. Confusingly there is also a new command called purge too! The new purge command is much less sophisticated than ban, as (AFAIK) it only purges exactly matched items, so basically one at a time.

If you do wish to use the new purge you need to have some specific VCL in place. See here

import std;
probe default {
.url = "/index.html";
.timeout = 30ms;
.interval = 2s;
.window = 5;
.threshold = 3;
}
# based on http://uberblo.gs/2011/06/high-performance-url-shortening-with-redis-backed-nginx
# using code from http://stackoverflow.com/questions/3554315/lua-base-converter
# "database scheme"
# database 0: id ~> url
# database 1: id ~> hits
# database 2: id ~> [{referer|user_agent}]
# database 3: id ~> hits (when id is not found)
# database 4: id ~> [{referer|user_agent}] (when id is not found)
# database 5: key "count" storing the number of shortened urls; the id is generated by (this number + 1) converted to base 62