Skip to content

Instantly share code, notes, and snippets.

View blaxter's full-sized avatar

Jesús García Sáez blaxter

  • Zaragoza, Spain
View GitHub Profile
@blaxter
blaxter / pr.md
Created March 26, 2013 00:35 — forked from piscisaureus/pr.md
Pull request locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@blaxter
blaxter / standup
Last active December 15, 2015 22:49
standup
function yesterworkday()
{
if [[ "Mon" == "$(date +%a)" ]]
then
echo "last friday"
else
echo "yesterday"
fi
}
@blaxter
blaxter / singleapp.py
Created April 18, 2013 15:13
PySide QSingleApplication
class QSingleApplication(QApplication):
def single_start(self, widget):
self.widget = widget
self.local_socket = QLocalSocket()
self.local_socket.connected.connect(self.another_instance_started)
self.local_socket.error.connect(self.first_instance)
self.local_socket.connectToServer("foobar", QIODevice.WriteOnly)
def another_instance_started(self):
self.local_socket.write("foobar")
@blaxter
blaxter / Vagrantfile
Created March 27, 2014 16:45
openchange cloud vagrant
Vagrant.configure("2") do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "puppet/manifests"
puppet.module_path = "puppet/modules"
puppet.manifest_file = "site.pp"
puppet.options = "--verbose --debug"
end
@blaxter
blaxter / punch
Last active August 29, 2015 14:01
puncher for internal Zentyal timetracker
#!/usr/bin/env python
import keyring
import re
import os
import sys
import requests
import configobj
import getpass
@blaxter
blaxter / rsync nonstop
Last active August 29, 2015 14:02
sync files one way
# sudo aptitude install inotify-tools
[email protected]
SOURCE=source_dir
TARGET=target_dir
while inotifywait -r $SOURCE ; do
rsync -avz $SOURCE $DEST:$TARGET
done
@blaxter
blaxter / snif_unix_socket.sh
Created June 13, 2014 10:48
Snif unix socket
socat -v UNIX-LISTEN:/tmp/socat-listen UNIX-CONNECT:/path/to/real.socket
@blaxter
blaxter / reprovision_openchangedb
Last active August 29, 2015 14:07
Reprovision openchangedb
mysqladmin --defaults-file=/etc/mysql/debian.cnf --force drop openchange create openchange && \
openchange_provision --openchangedb --openchangedb-uri=`cat /etc/samba/openchange.conf | grep mysql:// | head -n 1 | awk '{ print $3 }'` --firstorg="`/usr/share/zentyal/grep-redis openchange/state | cut -c 19- | ruby -rjson -e 'puts JSON.parse(ARGF.read)["Provision"]["organizationname"]'`"
@blaxter
blaxter / send_emails.py
Created October 17, 2014 10:49
send mails
#!/usr/bin/env python
import smtplib
import argparse
parser = argparse.ArgumentParser(description='Send massive emails')
parser.add_argument('to_addr_list', metavar='TO', type=str, nargs='+',
help='List of addresses to send the emails')
parser.add_argument('--number', '-n', type=int, default=100,
help='Number of emails to send)')
parser.add_argument('--username', '-u', help='SMTP login')
@blaxter
blaxter / foo.sh
Created October 17, 2014 11:00
script with lock
lockfile=/var/tmp/mylock
if ( set -o noclobber; echo "$$" > "$lockfile") 2> /dev/null; then
trap 'rm -f "$lockfile"; exit $?' INT TERM EXIT
# do stuff here
# clean up after yourself, and release your trap
rm -f "$lockfile"