Skip to content

Instantly share code, notes, and snippets.

alganet /
Last active January 29, 2022 03:49
Capturing keyboard events on any shell
#!/usr/bin/env sh
# This script captures keyboard events on popular POSIX Shells.
# Run it by executing ./ and press the arrow keys
# to see the capture exemple. Press Return to exit.
# It has been tested on:
# - Windows (Git Bash and MSYS+Mintty)
# - OS X (native terminal, Yosemite)
ricardo-rossi /
Last active December 1, 2023 04:55
Installing ElasticSearch on Ubuntu 14.04
### ./ 1.7 will install Elasticsearch 1.7
### ./ will fail because no version was specified (exit code 1)
### CLI options Contributed by @janpieper
### Check for latest version of ElasticSearch
clayton /
Created August 9, 2013 18:55
Install FFMPEG on OS X with HomeBrew to convert Mp4 to WebM
# Installation
brew install ffmpeg --with-vpx --with-vorbis --with-libvorbis --with-vpx --with-vorbis --with-theora --with-libogg --with-libvorbis --with-gpl --with-version3 --with-nonfree --with-postproc --with-libaacplus --with-libass --with-libcelt --with-libfaac --with-libfdk-aac --with-libfreetype --with-libmp3lame --with-libopencore-amrnb --with-libopencore-amrwb --with-libopenjpeg --with-openssl --with-libopus --with-libschroedinger --with-libspeex --with-libtheora --with-libvo-aacenc --with-libvorbis --with-libvpx --with-libx264 --with-libxvid
# Easy Peasy
ffmpeg -i video.mp4 video.webm
nelsonsar / .vimrc
Created July 11, 2013 14:52
This is my .vimrc file. It will get update since UpdateCTags function for some reason breaks in some cases...
"mark trailing whitespaces
hi link localWhitespaceError Error
au Syntax * syn match localWhitespaceError /\(\zs\%#\|\s\)\+$/ display
au Syntax * syn match localWhitespaceError / \+\ze\t/ display
highlight WhitespaceEOL ctermbg=red guibg=red
match WhitespaceEOL /\s\+$/
"change tabs for 4 spaces
set tabstop=4
nelsonsar /
Last active December 19, 2015 15:28
This is a script for update ctags and put a tags.{git_base_dir} on the folder that you specify. It will also search for a .srclist in your home folder, for PHP developers is nice to put your include_path for PEAR.Thanks to @henriquemoody for bash support!
ctags -R --exclude=".git" \
-h '.php' \
--languages=-javascript,sql \
--totals=yes \
--tag-relative=yes \
--PHP-kinds=+cfiv \
--regex-PHP="/(abstract)?\s+class\s+([^ ]+)/\2/c/" \
--regex-PHP="/(static|abstract|public |protected|private)\s+(final\s+)?function\s+(\&\s+)?([^ (]+)/\4/f/" \
nikic /
Last active April 12, 2024 17:05
Post explaining why objects often use less memory than arrays (in PHP)

Why objects (usually) use less memory than arrays in PHP

This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)

The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array part of it away. So how does that work?

The key here is that objects usually have a predefined set of keys, whereas arrays don't:

henriquemoody / phpunit.bash
Last active May 10, 2023 02:52
PHPUnit Bash Completion. sudo curl -L -o /etc/bash_completion.d/phpunit && source /etc/bash_completion.d/phpunit
# Bash-Completion script for PHPUnit
# Created by Henrique Moody <>
local cur="${COMP_WORDS[COMP_CWORD]}"
local prev="${COMP_WORDS[COMP_CWORD-1]}"
piscisaureus /
Created August 13, 2012 16:12
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 =

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:

henriquemoody / content-finder.bash
Last active October 6, 2015 18:18
[content-finder] Find content into files.
#!/usr/bin/env bash
# Usage: {script} OPTIONS
# Find content into files.
# -h, --help Displays this help
# -a, --action Action to perform: "search", "files" or a sed pattern to
# apply to files (default "search")
# -d, --directory Directory to search (default ".")
# -e, --extension Extensions to search on (default "*")
# -x, --exclude Pattern to exclude
henriquemoody /
Created May 8, 2012 21:41
Record the terminal session and replay later
# Uses script and scriptreplay to record and playback virtual terminal.
# Copyright (C) 2007 Hean Kuan Ong <>
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,