Skip to content

Instantly share code, notes, and snippets.

View aeurielesn's full-sized avatar

Alexander Urieles aeurielesn

View GitHub Profile
@aeurielesn
aeurielesn / gist:2511005
Created April 27, 2012 17:23
Retrying a jQuery.ajax() call
$.ajax({
url: '/echo/error/',
async: true,
// retryCount and retryLimit will let you retry a determined number of times
retryCount: 0,
retryLimit: 10,
// retryTimeout limits the total time retrying (in milliseconds)
retryTimeout: 10000,
// timeout for each request
timeout: 1000,
@aeurielesn
aeurielesn / gist:2376289
Created April 13, 2012 11:51
Find features referencing a plugin
osgi> provlquery /eclipse/p2/org.eclipse.equinox.p2.engine/profileRegistry/SDKProfile.profile "select(parent | parent.properties['org.eclipse.equinox.p2.type.group'] == true && parent.requirements.exists(rc | everything.exists(iu | iu.id == 'org.eclipse.core.filesystem' && iu ~= rc)))" true
@aeurielesn
aeurielesn / backup.sh
Created April 5, 2012 21:03
Backup through FTP
#!/bin/bash -e
#
#Define dumpfile name
MYSQLBACKUP= /tmp/dbackup
#Perform MySQL dump
#Replace appropriate USER, PASSWORD and paths to mysqldump, socket, etc.
#Drop in you preferred method - tar versus gzip, etc.
/usr/bin/mysqldump --all-databases -S /tmp/mysql.sock -uUSER -pPASSWORD | gzip -c > $MYSQLBACKUP
@aeurielesn
aeurielesn / jquery.tabs.js
Created February 22, 2012 21:13
Modified jquery tab plugin to allow subtabs
$(".tabs").tabs();
@aeurielesn
aeurielesn / gist:1502169
Created December 20, 2011 16:27
Installing Oracle Java Plugin in Ubuntu 11.04
sudo apt-get install sun-java6-plugin
sudo update-alternatives --install /usr/lib/mozilla/plugins/mozilla-javaplugin.so mozilla-javaplugin.so /usr/lib/jvm/java-6-sun/jre/lib/i386/libnpjp2.so 1
@aeurielesn
aeurielesn / dice-portrait.py
Last active September 28, 2015 03:38
spmacdonald's dice portrait
# http://web.archive.org/web/20091015013516/http://www.elusivesnark.com/2008/11/carolines-dice-portrait.html
PImage img;
PImage cropped_img;
PImage patch;
int _width = 640;
int _height = 1024;
int patch_w = 16;
int patch_h = 16;
@aeurielesn
aeurielesn / gist:1278767
Created October 11, 2011 17:32
Change files encoding from ANSI to UTF-8
for file in $(find . -name *.java -type f)
do
iconv -f cp1252 -t utf-8 -o "$file.new" "$file" && mv -f "$file.new" "$file"
done
@aeurielesn
aeurielesn / mysql-drop-all-tables.sh
Created August 18, 2011 21:03
Drop all tables from a MySQL database
$ mysqldump -u[USERNAME] -p[PASSWORD] --add-drop-table --no-data [DATABASE] | grep ^DROP | mysql -u[USERNAME] -p[PASSWORD] [DATABASE]
#Source: Thingy Ma Jig Blog (http://www.thingy-ma-jig.co.uk/blog/10-10-2006/mysql-drop-all-tables)
@aeurielesn
aeurielesn / build.xml
Created August 4, 2011 05:24
ant script to get local revision number from the subversion's .svn/entries file
<?xml version="1.0" encoding="UTF-8"?>
<project name="svn" default="revision-number" basedir=".">
<target name="check-svn-entries">
<available file=".svn/entries" property="svn.entries.present"/>
</target>
<target name="revision-number" depends="check-svn-entries" if="svn.entries.present">
<loadfile srcfile=".svn/entries" property="revision">
<filterchain>
@aeurielesn
aeurielesn / util.php
Created July 31, 2011 03:47
Decode Unicode strings in PHP
<?php
#source: http://stackoverflow.com/questions/2934563/how-to-decode-unicode-escape-sequences-like-u00ed-to-proper-utf-8-encoded-char
function replace_unicode_escape_sequence($match) {
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
}
function unicode_decode($str) {
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $str);
}