Skip to content

Instantly share code, notes, and snippets.

View rberrelleza's full-sized avatar
👋
Hi friend!

Ramiro Berrelleza rberrelleza

👋
Hi friend!
View GitHub Profile
@rberrelleza
rberrelleza / key_on_commit.sh
Created December 9, 2014 21:49
Git hook to append issue name to a commit
#!/bin/sh
#
# git prepare-commit-msg hook for automatically prepending an issue key
# from the start of the current branch name to commit messages.
# check if commit is merge commit
if [ $2 = "merge" ]; then
exit
fi
ISSUE_KEY=`git branch | grep -o "\* \(.*/\)*[A-Z]\{2,\}-[0-9]\+" | grep -o "[A-Z]\{2,\}-[0-9]\+"`
cd submodule_directory
git checkout v1.0
cd ..
git add submodule_directory
git commit -m "moved submodule to v1.0"
git push
@rberrelleza
rberrelleza / scraper.py
Created April 11, 2015 02:56
Screen scrapper+pngcrusher exercise to
import shutil
import requests
from bs4 import BeautifulSoup
from tinypng import shrink_file
requests.packages.urllib3.disable_warnings()
response = requests.get("YOUR_URL")
soup = BeautifulSoup(response.text, 'html.parser')
images = soup.find_all('img')
@rberrelleza
rberrelleza / eml.pl
Created April 30, 2015 00:14
Display a eml file on the console
perl -MMIME::Base64 -ne 'print decode_base64($_)' < YOUR_FILE.eml
@rberrelleza
rberrelleza / WaitForProcess.cmd
Created March 27, 2012 22:24
Script that blocks the command line until process starts running
@echo off
set loops=0
set process=%1
:WaitForProcessToStart
if /i %loops% gtr 10 (
echo Process didn't started on time
exit /b 1
)
@rberrelleza
rberrelleza / QueryTableSize.sql
Created May 11, 2012 00:13
Query to see the size of all tables on a DB
select sysobj.name, sum(reserved_page_count) * 8.0 / 1024 as 'total size (MB)'
from sys.dm_db_partition_stats sysstats, sys.objects sysobj
where sysstats.object_id = sysobj.object_id and sysobj.schema_id = schema_id('dbo')
group by sysobj.name;
@rberrelleza
rberrelleza / UTCToLocal.sql
Created July 11, 2012 22:21
Transform UTC to LocalTime on SQL Server 2008
SELECT Convert(datetime, SWITCHOFFSET(CONVERT(datetimeoffset,[ColumnWithUTCTime]), DATENAME(TzOffset, SYSDATETIMEOFFSET()))) AS LocalTime
FROM TABLE
@rberrelleza
rberrelleza / packer-kill-orphans.sh
Created November 11, 2015 01:44 — forked from aaronzirbes/packer-kill-orphans.sh
Delete orphaned artifacts left by packer.io
#!/bin/bash
set -e
# Keypairs
echo "Finding Key Pairs..."
KEY_PAIRS_JSON=`aws ec2 describe-key-pairs --filters 'Name=key-name,Values=packer*'`
KEY_PAIRS=`echo "${KEY_PAIRS_JSON}" | grep 'KeyName' |sed -e 's/.*"KeyName": "//' -e 's/",* *$//'`
# Security Groups
@rberrelleza
rberrelleza / share_file.py
Last active November 25, 2015 23:23
Share a file with a hipchat room
#!/bin/python
import argparse
import json
import os.path
import re
import requests
import sys
from email.mime.multipart import MIMEMultipart
from email.mime.nonmultipart import MIMENonMultipart
@rberrelleza
rberrelleza / delete
Created December 19, 2012 23:29
Delete all files and folders recursevely on *nix
rm -Rf