Skip to content

Instantly share code, notes, and snippets.

View rafeca's full-sized avatar
🐙
.

Rafael Oleza rafeca

🐙
.
View GitHub Profile
@rafeca
rafeca / Multilog.php
Created August 28, 2011 08:32 — forked from pepe84/Multilog.php
PHP Zend: Multilog resource
<?php
require_once 'Zend/Application/Resource/ResourceAbstract.php';
require_once 'Zend/Log.php';
/**
* Multilog Resource
*
* @category Zend
* @package Zend_Application
@rafeca
rafeca / phono.js
Created November 14, 2011 13:57
Phono initialization with Java applet
$(document).ready(function(){
phono = $.phono({
apiKey: 'xxx',
onReady: function(event, phone) {
// (...)
},
audio: {
type: 'java',
jar: 'http://hudson.voxeolabs.com/hudson/job/PhonoSDK/lastBuild/artifact/artifacts/sdk/plugins/audio/phono.audio.jar'
}
@rafeca
rafeca / trace.log
Created November 15, 2011 13:50
libevent for PHP installation error
rafeca->roa ~/Documents/Curro/TID/10fridays/connfurence git:(telephony) ✗ sudo pecl install libevent
Password:
downloading libevent-0.0.4.tgz ...
Starting to download libevent-0.0.4.tgz (9,003 bytes)
.....done: 9,003 bytes
3 source files, building
running: phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
@rafeca
rafeca / main_re.py
Created February 8, 2012 09:42 — forked from ggarber/main_re.py
Cast CamelCase to "underscore_case"
import re
def _camel_to_underscore_case(name):
"""
Translate 'CamelCaseNames' to 'camel_case_names'.
"""
camelcase_boundry = '((?<=[a-z])[A-Z])'
return re.sub(camelcase_boundry, '_\\1', name).lower()
def camel_to_underscore_case(obj, deep=True):
@rafeca
rafeca / .zshrc
Created March 12, 2012 09:42
Change Python virtualenv based on finding a .venv file in the current directory
function chpwd() {
if [ -e .venv ]; then
echo "$fg[green]Switching to virtualenv \"`cat .venv`\"$reset_color"
workon `cat .venv`
fi
}
@rafeca
rafeca / vpn_connect.rb
Created April 3, 2012 10:05
Script to connect to several VPNs that use different racoon config files from the command line
#!/usr/bin/env ruby
CONFIGURED_INTERFACES = ["O2", "TID"]
VPN_INTERFACE_NAMES = "%s VPN"
RACOON_CONFIG_FILES = "/etc/racoon/racoon.conf.%s"
unless (ARGV.length > 0 && CONFIGURED_INTERFACES.include?(ARGV[0].upcase))
puts "usage: vpn_connect [#{CONFIGURED_INTERFACES.join('|')}]"
exit 1
end
<?php
function _buildParams(array $data = array(), $preffix = '')
{
$query = array();
foreach ($data as $k=>$v){
if (is_array($v)){
$query[] = _buildParams($v, $preffix ? $preffix .'[' . (is_int($k) ? '' : $k) . ']' : $k);
} else if ($preffix) {
@rafeca
rafeca / build-pipeline.js.diff
Created September 5, 2012 22:26
Dirty fix for the following bug in jenkins build pipeline plugin: https://issues.jenkins-ci.org/browse/JENKINS-14656
diff -r 4a634fdf26e2 src/main/webapp/js/build-pipeline.js
--- a/src/main/webapp/js/build-pipeline.js Sat Aug 25 16:04:30 2012 -0700
+++ b/src/main/webapp/js/build-pipeline.js Wed Sep 05 23:24:46 2012 +0100
@@ -69,6 +69,18 @@
},
triggerBuild : function(id, upstreamProjectName, upstreamBuildNumber, triggerProjectName, dependencyIds) {
var buildPipeline = this;
+
+ // Ugly patch by rafeca to fix this bug: https://issues.jenkins-ci.org/browse/JENKINS-14656
+ var currentBox = $('#build-' + id);
@rafeca
rafeca / tag-cleaner.sh
Created October 30, 2012 11:26
Remove the tags that finish with -a1, -a2, -b1, -b2, ...
# First, remove the tags from the origin repository
$ git tag -l | grep -e '-[a-zA-Z][0-9]*$' | awk '{ print ":" $1}' | xargs git push origin
# Then, remove the tags locally
$ git tag -l | grep -e '-[a-zA-Z][0-9]*$' | xargs git tag -d
@rafeca
rafeca / pre-commit.sh
Created November 30, 2012 12:39
Pre-commit hook to alert the committer before committing changes dangerous files. Save it in .git/hooks/pre-commit
#!/bin/sh
FILES="app/config/config.production.yaml\|app/config/application.production.yaml"
if [ "`git diff-index --cached HEAD | grep \"$FILES\"`" ]; then
exec < /dev/tty
echo "You are commiting changes to a live config file. Are you sure? [y/n] "
read -s -n 1 sure