Skip to content

Instantly share code, notes, and snippets.

View brunogama's full-sized avatar
🏠
Working from home

Bruno Gama brunogama

🏠
Working from home
  • Banco Inter
  • Brazil
  • 18:51 (UTC -03:00)
  • X @brunogama
View GitHub Profile
@brunogama
brunogama / gist:1051218
Created June 28, 2011 14:14
Spotlight search by name in the current directory (pwd)
slnamepwd() {
mdfind -onlyin $PWD -name $*
SLNAMETOTAL=$(mdfind -count -onlyin $PWD -name $*)
printf "\nTotal files found ${SLNAMETOTAL}\n"
}
@brunogama
brunogama / NSTimer+Additions.h
Created July 5, 2011 16:45
NSTimer blocks implementation //NOT WORKING.
#import <Foundation/Foundation.h>
typedef void (^VoidBlock)();
@interface NSTimer (NSTimer_Additions)
+ (NSTimer *)scheduleTimerWithTimeInterval:(NSTimeInterval)theSeconds repeats:(BOOL)repeats actions:(VoidBlock)actions;
@end
@brunogama
brunogama / gist:1098261
Created July 21, 2011 21:29
Change the hostname (mac)
sudo scutil --set HostName computer-name.local
@brunogama
brunogama / gist:1251469
Created September 29, 2011 18:10
kill stuff like a boss
# Kill it Like a Boss
function vaporize {
QSTRING=$*
PROC=`ps aux | grep ${QSTRING} | grep -v grep | awk '{print $2}'`
if [ ! -n "$PROC" ]; then
echo "0 PID found with the matching String: \"${QSTRING}\"."
else
NUMPROC=`echo $PROC | awk '{print NF}'`
echo "Found $NUMPROC PIDs with the matching String: \"${QSTRING}\"."
sudo kill -9 $PROC
@brunogama
brunogama / gist:1251473
Created September 29, 2011 18:12
Force Malware Update Definitions (Mac OS Only)
updateMalwareDefinitions() {
sudo /usr/libexec/XProtectUpdater
echo "Last Malware Definitions $(defaults read /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/XProtect.meta LastModification)"
}
@brunogama
brunogama / random_image_generator.py
Created February 3, 2012 21:18
My random size image generator script (only for UNIX systems).
import random
import string
from os import system as s
for i in range(14):
new = '%s.jpg' % (''.join(random.choice(string.ascii_lowercase + string.digits) for x in range(15)))
cmd = 'cp terra.jpg %s' % (new)
s(cmd)
s('dd if=/dev/urandom of=dummy_bytes bs=1m count=80')
cmd = 'cat dummy_bytes >> %s' % (new)
@brunogama
brunogama / gist:2771443
Created May 22, 2012 20:33
Runserver with the interface IP (for Parallels VM testing) OSX Only
runservervm() {
interface=$1
if [ -n "$interface" ]; then
interface=$1
else
interface='en1'
fi
internalIP=$(ipconfig getifaddr ${interface})
echo "http://${internalIP}:8000" | pbcopy
python manage.py runserver ${internalIP}:8000
@brunogama
brunogama / Preferences.sublime-settings
Created June 8, 2012 13:05
Preferences.sublime-settings
{
"auto_complete": true,
"auto_complete_commit_on_tab": false,
"auto_complete_delay": 50,
"auto_complete_selector": "source - comment",
"auto_complete_size_limit": 4194304,
"auto_complete_triggers":
[
{
"characters": "<",
@brunogama
brunogama / main.m
Created June 14, 2012 21:03
Literals
//
// main.m
// Literals
//
// Created by Bruno Gama on 14/06/12.
// Copyright (c) 2012 Bruno Gama. All rights reserved.
//
#import <Foundation/Foundation.h>
@brunogama
brunogama / gist:3030898
Created July 2, 2012 03:44
Delete pdf file if epub exist
for i in *pdf; do x=$(echo $i | sed 's/pdf/epub/g'); [ -f $x ] && rm $i; done