Skip to content

Instantly share code, notes, and snippets.

@kimlindholm
kimlindholm / js_spec.watchr
Created Nov 16, 2014
watchr script for Teaspoon
View js_spec.watchr
# Usage:
# gem install watchr ruby-fsevent
# watchr spec/js_spec.watchr
# --------------------------------------------------
# Rules
# --------------------------------------------------
watch('spec/javascripts/.*_spec\.(coffee|js)') { |md| teaspoon md[0] }
# --------------------------------------------------
@kimlindholm
kimlindholm / gist:1819143
Created Feb 13, 2012
Code snippets from presentation "Varnish Configuration Step by Step"
View gist:1819143
------ Slide 8 ------
sudo su -
yum install -y gcc make pkgconfig pcre-devel ncurses-devel
cd /usr/src
wget http://repo.varnish-cache.org/source/varnish-3.0.2.tar.gz -O - | tar xz
cd varnish-3.0.2
./configure
make && make install
exit
@kimlindholm
kimlindholm / run
Created Feb 13, 2012
Daemontools run script for starting Varnish
View run
#!/bin/sh
# Daemontools run script for starting Varnish
exec 2>&1
exec echo | mail -s "Varnish in Tokyo restarting" admin@example.com
exec varnishd -F -s malloc,130M -u nobody -g nobody -p cli_timeout=30 \
-p thread_pool_add_delay=2 -p thread_pool_min=400 -p thread_pool_max=4000 \
-p session_linger=100 -f /etc/varnish/varnish.tokyo.vcl -T 127.0.0.1:2000 \
-a 0.0.0.0:80
@kimlindholm
kimlindholm / newrelic.h
Created Feb 13, 2012 — forked from jelder/newrelic.h
Add X-Request-Start header so we can track queue times in New Relic RPM
View newrelic.h
/*
* Add X-Request-Start header so we can track queue times in New Relic RPM
*/
#include <stdio.h>
#include <sys/time.h>
struct timeval detail_time;
gettimeofday(&detail_time, NULL);
char start[20];
@kimlindholm
kimlindholm / create_swapfile.sh
Created Feb 13, 2012
Create swapfile if not already present
View create_swapfile.sh
#!/bin/bash
# Create swapfile if not already present. Default size is 2 GB.
if [ ${SWAP_SIZE_MEGABYTES:=2048} -eq 0 ];then
echo No swap size given, skipping.
else
if [ -e /swapfile ];then
echo /swapfile already exists, skipping.
else
echo Creating /swapfile of $SWAP_SIZE_MEGABYTES MB
@kimlindholm
kimlindholm / email_varnish_reports.sh
Created Feb 13, 2012
Send Munin generated Varnish statistics by e-mail
View email_varnish_reports.sh
#!/bin/bash
# Send Munin generated Varnish statistics by e-mail
VARNISH_LOCATION="Tokyo"
REPORT_PATH=/var/www/html/munin/localhost/localhost
EMAIL_RECIPIENT="admin@example.com"
EMAIL_SUBJECT="Varnish Weekly Statistics"
EMAIL_BODY="Weekly statistics attached."
hash mutt 2>&- || { echo -e >&2 "\nMutt not installed, aborting.\n"; exit 1; }
@kimlindholm
kimlindholm / varnish.tokyo.vcl
Created Feb 6, 2012
Varnish configuration example
View varnish.tokyo.vcl
# VCL configuration file for Varnish
# Define which IP addresses or hosts have access to files that are
# blocked from the public internet
acl internal {
"localhost";
}
# Define origin servers
backend web { .host = "1.2.3.4"; .port = "80"; }
You can’t perform that action at this time.