Skip to content

Instantly share code, notes, and snippets.

View BenderV's full-sized avatar
🎯
Focusing

Benjamin BenderV

🎯
Focusing
View GitHub Profile
@zed
zed / override_instance_method.py
Created November 23, 2010 22:20
Example on how how to override instance method in Python.
#!/usr/bin/env python
"""Example on how how to override instance method in Python.
See http://stackoverflow.com/q/4243586
"""
import types
from operator import methodcaller
class Spam:
@spicycode
spicycode / tmux.conf
Created September 20, 2011 16:43
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@textarcana
textarcana / git-log2json.sh
Last active March 1, 2024 05:26
Convert Git logs to JSON. The first script (git-log2json.sh) is all you need, the other two files contain only optional bonus features 😀THIS GIST NOW HAS A FULL GIT REPO: https://github.com/context-driven-testing-toolkit/git-log2json
#!/usr/bin/env bash
# Use this one-liner to produce a JSON literal from the Git log:
git log \
--pretty=format:'{%n "commit": "%H",%n "author": "%aN <%aE>",%n "date": "%ad",%n "message": "%f"%n},' \
$@ | \
perl -pe 'BEGIN{print "["}; END{print "]\n"}' | \
perl -pe 's/},]/}]/'
@stefanv
stefanv / sparks.py
Created November 17, 2011 00:25
Command line sparks in Python
#!/usr/bin/python
# coding=utf-8
# Python version of Zach Holman's "spark"
# https://github.com/holman/spark
# by Stefan van der Walt <stefan@sun.ac.za>
"""
USAGE:
@tsabat
tsabat / zsh.md
Last active December 25, 2023 19:16
Getting oh-my-zsh to work in Ubuntu
@saetia
saetia / gist:1623487
Last active May 1, 2024 19:55
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@bracki
bracki / reindex.py
Created January 30, 2012 21:34
Simple reindex for elasticsearch using pyes
>>> import pyes
>>> conn = pyes.es.ES("localhost:9200")
>>> all = conn.scan(pyes.query.MatchAllQuery(), 'index', 'type')
>>> for a in all:
... hits = a['hits']['hits']
... for hit in hits:
... conn.index(hit['_source'], 'new_index', 'type', hit['_id'], bulk=True)
@Visgean
Visgean / backup.py
Created July 16, 2012 22:27
Backup all messages on facebook
#! /usr/bin/python
# -*- coding: UTF-8 -*-
import facebook
import urllib2
import codecs
print "You need API token: get one here: https://developers.facebook.com/tools/explorer"
USER_ACCESS_TOKEN= raw_input("Your API key: ")
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active June 8, 2024 22:26
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active June 5, 2024 13:48
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'