Skip to content

Instantly share code, notes, and snippets.

View hvasconcelos's full-sized avatar

Hélder Vasconcelos hvasconcelos

View GitHub Profile
@hvasconcelos
hvasconcelos / grade_droid_gen
Created January 15, 2014 12:55
A script to generate a Gradle Android Project
#!/bin/bash
create_build_file() {
cat > $1/build.gradle << EOF
repositories {
mavenCentral()
}
@hvasconcelos
hvasconcelos / time_spent.c
Created November 19, 2013 12:27
Time spent doing something
#include <sys/time.h>
#include <stdio.h>
#include <string.h>
long timevaldiff(struct timeval *starttime, struct timeval *finishtime) {
long msec;
msec=(finishtime->tv_sec-starttime->tv_sec)*1000;
msec+=(finishtime->tv_usec-starttime->tv_usec)/1000;
return msec;
}
@hvasconcelos
hvasconcelos / redis
Last active December 25, 2015 13:29
Redis Init Script for CentOS 6
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid
@hvasconcelos
hvasconcelos / redis.conf
Created October 14, 2013 22:38
Redis Centos Configuration file
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
@hvasconcelos
hvasconcelos / vboxad
Created October 4, 2013 19:01
Vbox Additions on Centos 6.4
yum update kernel*
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
@hvasconcelos
hvasconcelos / gitistage
Last active December 20, 2015 05:49
Interactive Git Staging
#!/bin/bash
files=`git status --porcelain | grep -e "^\sM" | cut -d " " -f 3`
for file in $files; do
echo "Differences in file"
git diff --color=always $file
read -p "Do you want to stage this file [y/n]" to_stage
if [ "$to_stage" == "y" -o "$to_stage" == "Y" ]; then
echo "Staging file -> $file"
git add $file
fi
@hvasconcelos
hvasconcelos / twitter_rotator.rb
Last active December 20, 2015 01:39
Twitter Timeline Rotator
#!/usr/bin/env ruby
require "rubygems"
require "twitter"
require "colorize"
require "oauth"
require "yaml"
class TwitterRotator
attr_writer :tweet_func
@hvasconcelos
hvasconcelos / ifcfg-eth0
Created July 16, 2013 20:14
CentOS Configure Static IP Address
DEVICE=eth0
BOOTPROTO=static
HWADDR=XX:XX:XX:XX:XX:XX
IPADDR="<IP_ADDRESS>"
GATEWAY="<NETWORK_GATEWAY>"
NETMASK="<NETWORK_MASK>"
DNS1="<DNS_SERVER1>"
DNS2="<DNS_SERVER2>"
TYPE="Ethernet"
ONBOOT=yes
@hvasconcelos
hvasconcelos / go.bash
Created July 16, 2013 19:37
Go Tool aliases
#!/bin/bash
alias gob='go build'
alias goc='go clean'
alias gog='go get'
alias goi='go install'
alias gor='go run'
alias gotest='go test'
alias got='go tool'
alias govet='go vet'
@hvasconcelos
hvasconcelos / git.bash
Created July 16, 2013 19:35
Git aliases
#!/bin/bash
alias gita='git add'
alias gitb='git branch'
# To see which local branches you have that are merged into the
# branch you are currently on
alias gitbm='git branch --merged'
alias gitbnm='git branch --no-merged'
alias gitc='git commit'