Skip to content

Instantly share code, notes, and snippets.

View diasjorge's full-sized avatar
🤖

Jorge Dias diasjorge

🤖
View GitHub Profile
require 'pp'
class Array
def average
inject(0.0) { |sum, e| sum + e } / length
end
end
res = {}
@diasjorge
diasjorge / add_path
Created September 2, 2014 10:45
Interact with riak attach
#!/usr/bin/expect
# Debug info
# exp_internal 1
set timeout 10
log_user 0
set path [lindex $argv 0]
if {[llength $argv] == 0} {
@diasjorge
diasjorge / security.rb
Last active January 3, 2016 03:39
Small interface to osx keychain using the command security
class Security
attr_reader :app, :service
def initialize(app, service = app)
@app = app
@service = service
end
def get_password
@diasjorge
diasjorge / composer.rb
Created November 2, 2013 12:10
modified composer.rb
# >---------------------------------------------------------------------------<
#
# _____ _ _
# | __ \ (_) | /\
# | |__) |__ _ _| |___ / \ _ __ _ __ ___
# | _ // _` | | / __| / /\ \ | '_ \| '_ \/ __|
# | | \ \ (_| | | \__ \/ ____ \| |_) | |_) \__ \
# |_| \_\__,_|_|_|___/_/ \_\ .__/| .__/|___/
# | | | |
# |_| |_|
;;; real-auto-save.el --- enable real auto save
;; Copyright (C) 2008, Chaoji Li
;; Author: Chaoji Li <lichaoji AT gmail DOT com>
;; Version: 0.3
;; Date: May 17, 2008
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@diasjorge
diasjorge / git-clean-branches
Last active December 24, 2015 00:09
Clean your old git branches
#/bin/sh
# -*- mode: shell-script; -*-
current_branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
if [ "$current_branch" != "master" ]; then
echo "WARNING: You are on branch $current_branch, NOT master."
fi
echo "Fetching merged branches..."
@diasjorge
diasjorge / gist:6296042
Last active December 21, 2015 10:59
coffee script hide show emacs support
(add-to-list 'hs-special-modes-alist
`(coffee-mode "\\s-*\\(?:class\\|.+[-=]>$\\)" nil "#"
,(lambda (arg)
(coffee-nav-end-of-block)) nil))
(defun coffee-chomp (str)
"Chomp leading and tailing whitespace from STR."
(while (string-match "\\`\n+\\|^\\s-+\\|\\s-+$\\|\n+\\'"
str)
(setq str (replace-match "" t t str)))
@diasjorge
diasjorge / clean_completion.sh
Created January 14, 2013 10:31
Clean Unused bash completions
cd /usr/local/etc/bash_completion.d
for f in *
do
if [[ $f =~ git|helpers ]]; then
echo "MATCH"
fi
exists=$(which $f)
if [[ -z $exists ]]; then
@diasjorge
diasjorge / playlist-gen.sh
Created November 26, 2012 19:53
Create playlist for all directories
IFS=$'\n'
# Find all leaf directories
for dir in $(find . -type d -exec sh -c '(ls -p "{}"|grep />/dev/null)||echo "{}"' \;);
do
cd $dir
find . -type f -iname '*mp3' | sed s/\.\\/// > "$(echo $dir | sed s/.*\\///)"-playlist.m3u
cd -
done
@diasjorge
diasjorge / xing.sh
Created July 18, 2012 07:26
xing.sh
complete -C `which xing_autocompletion` -o default xing
xing_dir="/Users/jorge.dias/development/xing"
function cx () {
if [ -n $1 ]; then
cd "$xing_dir/$1"
else
cd $xing_dir
fi