Skip to content

Instantly share code, notes, and snippets.

View sandys's full-sized avatar

Sandeep Srinivasa sandys

View GitHub Profile
@sandys
sandys / gist:8300759
Created January 7, 2014 15:15
CDN header hacker news
As people mentioned this site is an exception to how to do things, in that PG actively does not care about search engine results. However, for the people who are interested, here's a few ways you can handle a situation like this.
1. If you add the "max-stale" header to your content you can tell your CDN to hold on to things longer in the event of an outage. What happens is that the CDN will look at the cache time you set and check in as normal when that expires, but if it gets back no response or a 503 code (server maintenance status code- if you work with CDNs this is your friend!) it will continue serving the stale content for as long as you tell it.
2. Lets say you're beyond that, or your site is too dynamic. Instead of setting up an error page that responds to everything, setup a redirect with the 302 status code (so crawlers and browsers know it's a temporary thing). Point that redirect at an error page and you're golden. The best part is these types of requests use minimal resources.
What I do is kee
@sandys
sandys / ec2-py.json
Last active December 28, 2015 20:39
ansible teardown problem
#This is the output of running ec2.py
{
"ec2": [
"54.201.98.213"
],
"i-8bcae5bf": [
"54.201.98.213"
],
"key_ansible-1": [
"54.201.98.213"
@sandys
sandys / build.scala
Created October 26, 2013 12:44
build.scala
import sbt._
import Keys._
import sbtassembly.Plugin._
//import AssemblyKeys._ // put this at the top of the file
import sbtassembly.Plugin.AssemblyKeys
import sbtassembly.Plugin.AssemblyKeys._
import sbtassembly.Plugin.assemblySettings
import sbtassembly.Plugin.MergeStrategy
@sandys
sandys / build.sbt
Created October 26, 2013 04:59 — forked from sam/build.sbt
name := "foo"
version := "1.0-SNAPSHOT"
scalaVersion := "2.10.3"
scalacOptions in ThisBuild ++= Seq(
"-language:_",
"-feature",
"-unchecked",
@sandys
sandys / README.md
Created October 12, 2013 13:04 — forked from nikcub/README.md
@sandys
sandys / AziLink.ovpn
Created September 23, 2013 04:42
Azilink with openvpn on ubuntu
@sandys
sandys / threads.scala
Created August 19, 2013 07:10
using Threads and runnables in Scala
package multi
import java.util.concurrent.Callable
object Threads {
def main(args: Array[String]) : Unit = {
implicit def funcToCallable[A](func : () => A): Callable[A] = new Callable[A] { println("creating callable");def call() :A = func() }
implicit def funcToRunnable( func : () => Unit ) = new Runnable(){ println("creating runnable");def run() = func()}
//bad. cannot be tested properly. plus completely screws up the idea of runnable (viz to have the choice of not using threads with minimum code changes)
@sandys
sandys / T430S configuration
Last active December 21, 2017 00:25
super lean and fast Ubuntu 12.04 install. It doesnt hang and with firefox open, it consumes 500 mb of RAM ! - Now works with Ubuntu 14.04/Trusty Tahr!
# http://nodebox.metaforix.net/articles/debian-on-lenovo-thinkpad-t420
#create new file /usr/share/X11/xorg.conf.d/99-my.conf
Section "InputDevice"
Identifier "Synaptics Touchpad"
Driver "synaptics"
Option "SendCoreEvents" "true"
Option "Device" "/dev/psaux"
Option "Protocol" "auto-dev"
@sandys
sandys / damn-fast-ruby-setup.sh
Last active August 15, 2018 12:39
Set up a development environment for ruby in 30 minutes on ubuntu. This will use rbenv to take care of paths and will mimic how you would set up your production environment. A very clean separated setup conducive to integration with Puppet/chef (for installation of ruby versions) and Capistrano (for contained deployment). Allows for per-user own…
#pre-requisites
sudo apt-get install build-essential libreadline-dev libssl-dev zlib1g-dev libxml2-dev libxslt-dev git libpq-dev libmysqlclient-dev libpq-dev nodejs libcurl4-openssl-dev libffi-dev imagemagick libjpeg-progs pngcrush
############optional
sudo apt-get install sudo vim zsh
######### optional for jruby
sudo apt-get install openjdk-7-jdk