Skip to content

Instantly share code, notes, and snippets.

@shilov
shilov / main.go
Created Mar 27, 2015
xdg-open chrome
View main.go
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()
View solarized.sh
#!/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 / gist:28ebee32bf0fb21a0160
Created Feb 17, 2015
Drop all databases in Postgres by removing the current data cluster and recreating it
View gist:28ebee32bf0fb21a0160
sudo pg_dropcluster --stop 9.4 main && sudo pg_createcluster 9.4 main && sudo pg_ctlcluster 9.4 main start
View gist:57118c86f4c6b507679f
"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 / honeybadger.cap
Created Dec 27, 2013
Honeybadger.io deploy task for Capistrano 3
View honeybadger.cap
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
View getting_started.md
View nginx-init.sh
# 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 / app.rb
Created Mar 26, 2012 — forked from cpatni/app.rb
unique calculation using redis
View app.rb
require 'sinatra'
require 'redis'
require 'json'
require 'date'
class String
def &(str)
result = ''
result.force_encoding("BINARY")
@shilov
shilov / redis_json_marshal_eval_benchmarks.rb
Created Jan 27, 2012
Ruby Redis benchmarks for JSON vs Marshal vs String
View redis_json_marshal_eval_benchmarks.rb
# http://forrst.com/posts/JSON_vs_Marshal_vs_eval_Which_is_the_fastest_fo-6Qy
require 'benchmark'
require 'json'
require 'redis'
# -----------------
puts "Initialize variables.."
@shilov
shilov / libmysqlclient16.sh
Created Nov 25, 2011
Removing libmysqlclient16 cauces dependency issues, but keeping it causes problems for Ruby's mysql2 gem
View libmysqlclient16.sh
[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: