Skip to content

Instantly share code, notes, and snippets.

"Hi, I’d like to hear a TCP joke."
"Hello, would you like to hear a TCP joke?"
"Yes, I’d like to hear a TCP joke."
"OK, I’ll tell you a TCP joke."
"Ok, I will hear a TCP joke."
"Are you ready to hear a TCP joke?"
"Yes, I am ready to hear a TCP joke."
"Ok, I am about to send the TCP joke. It will last 10 seconds, it has two characters, it does not have a setting, it ends with a punchline."
"Ok, I am ready to get your TCP joke that will last 10 seconds, has two characters, does not have an explicit setting, and ends with a punchline."
"I’m sorry, your connection has timed out. Hello, would you like to hear a TCP joke?"
@shilov
shilov / gist:28ebee32bf0fb21a0160
Created February 17, 2015 08:03
Drop all databases in Postgres by removing the current data cluster and recreating it
sudo pg_dropcluster --stop 9.4 main && sudo pg_createcluster 9.4 main && sudo pg_ctlcluster 9.4 main start
#!/bin/bash
#
# Author: benley@gmail.com (Benjamin Staffin)
# Set your terminal's color palette to match the Solarized color scheme by
# using escape sequences. Uses OSC 4 to set colors.
#
# This will work with many terminal emulators, but not all.
set -o nounset
@shilov
shilov / main.go
Created March 27, 2015 18:20
xdg-open chrome
package main
import (
"os/exec"
)
func main() {
try := []string{"xdg-open", "google-chrome", "open"}
for _, bin := range try {
err := exec.Command(bin, "http://golang.org").Run()
@shilov
shilov / libmysqlclient16.sh
Created November 25, 2011 22:32
Removing libmysqlclient16 cauces dependency issues, but keeping it causes problems for Ruby's mysql2 gem
[user@debian:~] 02:29:30 PM: aptitude purge libmysqlclient16
The following packages will be REMOVED:
libmysqlclient16{p}
0 packages upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 4481 kB will be freed.
The following packages have unmet dependencies:
libdbd-mysql-perl: Depends: libmysqlclient16 (>= 5.1.21-1) but it is not going to be installed.
The following actions will resolve these dependencies:
Remove the following packages:
@shilov
shilov / app.rb
Created March 26, 2012 03:24 — forked from cpatni/app.rb
unique calculation using redis
require 'sinatra'
require 'redis'
require 'json'
require 'date'
class String
def &(str)
result = ''
result.force_encoding("BINARY")
@shilov
shilov / nginx-init.sh
Created August 25, 2012 22:10
nginx upstart
# nginx
description "nginx http daemon"
start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]
env DAEMON=/usr/bin/nginx
env PID=/usr/local/nginx/logs/nginx.pid
@shilov
shilov / honeybadger.cap
Created December 27, 2013 00:07
Honeybadger.io deploy task for Capistrano 3
namespace :deploy do
desc "Notifies Honeybadger locally using curl"
task :notify_honeybadger do
on roles(:app) do
require 'json'
require 'honeybadger'
begin
require './config/initializers/honeybadger'
rescue LoadError
@shilov
shilov / redis_json_marshal_eval_benchmarks.rb
Created January 27, 2012 23:01
Ruby Redis benchmarks for JSON vs Marshal vs String
# http://forrst.com/posts/JSON_vs_Marshal_vs_eval_Which_is_the_fastest_fo-6Qy
require 'benchmark'
require 'json'
require 'redis'
# -----------------
puts "Initialize variables.."