Skip to content

Instantly share code, notes, and snippets.

View philss's full-sized avatar

Philip Sampaio philss

View GitHub Profile
@philss
philss / zshrc
Created June 30, 2015 20:41
Zsh git functions
# Put those functions on your ~/.zshrc or something similar.
# Cleans all merged branches (relative to the branch you are). Recommended to run from master.
function git_clean_branches()
{
# Fetch all merged branches that are not the master branch, and not the current branch
echo 'Deleting all merged branches...'
for branch in `git branch --merged | awk -F ' * ' '{print $2}' | grep -v -e 'master' | grep -v -e '*'`
do
echo "Removing .. $branch"
@philss
philss / zofe-audio-file-lengths.rb
Created February 21, 2015 04:24
This script fetches the audio file length in bytes for each audio file of ZOFE podcast
require 'yaml'
Dir.glob("./_posts/*.md").each do |post_file_path|
post = YAML.load_file(post_file_path)
audio_url = post.fetch("audio")
# NOTE: cURL may return multiple lines with length because
# it follows the redirects of the server.
#
lengths = `curl -I -L #{audio_url} | grep "Content-Length"`
@philss
philss / git_utils.sh
Last active August 29, 2015 14:14
A collection of shell script functions to work with git.
# Returns a list of files with a given term
function git_grep_files() {
git grep $1 | awk -F ':' '{print $1}' | sort | uniq
}
# Replace terms inside a git repository
#
# Example:
# git_replace "original_term" "new_term"
function git_replace() {
@philss
philss / math.ex
Last active August 29, 2015 13:56
A simple recursion example using pattern matching.
defmodule Math do
def sum_list([number]) do
number
end
def sum_list([head|tail]) do
head + sum_list(tail)
end
end
#include <stdio.h>
#define MAX_N 5000
int main() {
int size = 0;
int tmp = 0;
int i = 0;
int soma = 0;
scanf("%d",&size);
@philss
philss / rvm_ruby_install.sh
Created November 24, 2011 03:50
Rvm & Ruby 1.9.2 installation
#!/bin/bash
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
source $HOME/.bashrc
rvm install ruby-1.9.2