Skip to content

Instantly share code, notes, and snippets.

View serweb-labs's full-sized avatar

Luciano Rodríguez serweb-labs

View GitHub Profile
@jbarber
jbarber / 10-install_binaries.sh
Created July 20, 2011 10:18
Quick Oracle 11g install on RHEL5
#!/bin/bash
set -e
. CONFIG
# Satisfy the prerequisites for Oracle 11g and install the binaries
for i in oinstall dba oper asmadmin asmdba asmoper; do groupadd $i; done
useradd -g oinstall -G dba,oper,asmdba oracle
useradd -g oinstall -G asmadmin,asmdba,asmoper grid
@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);
}
@alobato
alobato / start-stop-example.sh
Created March 3, 2012 23:09
start-stop-example
#!/bin/sh
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
# Must be a valid filename
NAME=foo
PIDFILE=/var/run/$NAME.pid
#This is the command to be run, give the full pathname
DAEMON=/usr/local/bin/bar
@edwerner
edwerner / Vector2.js
Last active March 26, 2019 16:34
Base Vector2 JavaScript math helper class serves methods to perform operations on object values within Cartesian coordinate systems.
var Vector2 = function () {
this._x = 0;
this._y = 0;
this.DEGRAD = 0;
};
Vector2.prototype.initialize = function (x, y) {
_x = x;
_y = y;
};
@pwenzel
pwenzel / perpetual-rsync.sh
Created December 1, 2012 15:15
Automatically resume rsync over SSH after broken connection
#!/bin/bash
while [ 1 ]
do
rsync -avz --partial source dest
if [ "$?" = "0" ] ; then
echo "rsync completed normally"
exit
else
echo "Rsync failure. Backing off and retrying..."
@KartikTalwar
KartikTalwar / Documentation.md
Last active October 12, 2025 04:53
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@scribu
scribu / test.php
Created February 8, 2013 03:12
Simulate threads in PHP using only proc_open() and co.
<?php
include __DIR__ . '/threads.php';
$commands = array();
for ( $i=0; $i<10; $i++ ) {
$commands[] = "bash -c 'sleep `shuf -i 1-5 -n 1`; echo $i'";
}
@xeoncross
xeoncross / ajax.js
Last active August 3, 2023 06:06
Simple, cross-browser Javascript POST/GET xhr request object. Supports request data and proper AJAX headers.
/**
* IE 5.5+, Firefox, Opera, Chrome, Safari XHR object
*
* @param string url
* @param object callback
* @param mixed data
* @param null x
*/
function ajax(url, callback, data, x) {
try {
@amatiasq
amatiasq / new.js
Created December 10, 2013 15:45
A simple .new() method to create instances without constructors. This allow us to rewrite the "new" in order to do other things but create objects.
function $new() {
var obj = Object.create(this);
obj.init.apply(obj, arguments);
return obj;
}
@danburzo
danburzo / README.md
Last active July 29, 2021 08:41
Get all event listeners on the page in Google Chrome