Skip to content

Instantly share code, notes, and snippets.

@pklaus
pklaus / enumerate_interfaces.py
Last active March 15, 2024 15:32
Python: List all Network Interfaces On Computer
"""
Determine IPv4 addresses on a Linux machine via the socket interface.
Thanks @bubthegreat the changes to make it Py2/3 compatible and the helpful
code comments: https://gist.github.com/pklaus/289646#gistcomment-2396272
This version has all comments removed for brevity.
"""
import socket
import array
import struct
@dongilbert
dongilbert / wp-shell-install.sh
Created May 2, 2011 15:27
Auto Install Latest WordPress from Shell
#!/bin/bash
# Install script for Latest WordPress by Johnathan Williamson - extended by Don Gilbert
# Disclaimer: It might not bloody work
# Disclaimer 2: I'm not responsible for any screwups ... :)
# DB Variables
echo "MySQL Host:"
read mysqlhost
export mysqlhost
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active June 11, 2024 15:54
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@lucianosousa
lucianosousa / gist:3825283
Created October 3, 2012 05:51
5 livros que mudaram minha cabeça, em ordem de leitura
1) O Ócio Criativo - Domenico De Masi
http://www.livrariasaraiva.com.br/produto/443457/o-ocio-criativo/
2) Você está Louco - Ricardo Semler
http://www.livrariasaraiva.com.br/produto/1461877/voce-esta-louco-!-uma-vida-administrada-de-outra-forma/
3) Virando a própria mesa - Ricardo Semler
http://www.livrariasaraiva.com.br/produto/100702/virando-a-propria-mesa-uma-historia-de-sucesso-empresarial-made-in-brazil/
4) The 4-Hour Workweek - Tim Ferriss
@clintongormley
clintongormley / gist:3888120
Created October 14, 2012 09:44
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.

BOX_NAME=vagrant-build
BASE_DIR="`pwd`/machines"
BOX_DIR="${BASE_DIR}/${BOX_NAME}"
mkdir -p ${BASE_DIR}
VBoxManage createvm --name "${BOX_NAME}" --ostype RedHat_64 --basefolder ${BASE_DIR}
VBoxManage registervm "${BOX_DIR}/${BOX_NAME}.vbox"
mkdir -p tmp
@tarruda
tarruda / .README.md
Last active September 27, 2021 13:21
Tmux/Vim integration

Some scripts/configurations that greatly improve tmux/vim workflows. The shell scripts target zsh but should be adaptable without much effort for other unix shells.

Features:

  • Transparently move between tmux panes and vim windows
  • Using the shell, open files in one vim instance per project or directory
  • Fully integrated copy/paste between tmux, vim and x11 using simple keybinds(need to install the xclip program)
  • Easily send text to any tmux pane without breaking your edit workflow(needs slimux

'vim-tmux-move.zsh', '.vimrc' and '.tmux.conf' cooperate so you can move transparently between tmux panes and vim windows using ALT + (arrow keys or jkhl). It was based on this gist

#!/bin/bash
# Autor: Nilton OS -- www.linuxpro.com.br
echo 'setup-web2py-nginx-uwsgi-centos64.sh'
echo 'Support CentOS 6.4'
echo 'Installs Nginx 1.4.1 + uWSGI + Web2py'
# Get Web2py Admin Password
echo -e "Web2py Admin Password: \c "
read PW
@sh1n0b1
sh1n0b1 / ssltest.py
Created April 8, 2014 07:53
Python Heartbleed (CVE-2014-0160) Proof of Concept
#!/usr/bin/python
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford (jspenguin@jspenguin.org)
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select
@peczenyj
peczenyj / coligacoes.sh
Last active August 29, 2015 14:05
Script que mostra quantas vezes um partido coliga com outro por estado
#!/bin/bash
#
# Este script vai consultar o json da globo.com e vai mostrar em
# quantos estados o partido X coliga com os outros partidos
#
PARTIDO=${1:?favor informar o partido}
URL=http://estaticog1.globo.com/2014/07/Coligacoes/eleicao.json
echo "Coligações do partido $PARTIDO"