Skip to content

Instantly share code, notes, and snippets.

View tomasperezv's full-sized avatar
🤖
Focusing

Tomás Pérez tomasperezv

🤖
Focusing
View GitHub Profile
@tomasperezv
tomasperezv / gist:2731645
Created May 19, 2012 17:36
Example of an AJAX request using the XMLHttpRequest object
var xhr = new XMLHttpRequest();
xhr.open('get', url, true);
xhr.onreadystatechange = function() {
// Here we check the status of the readyState property
switch(this.readyState) {
case 200:
case 202:
onSuccess(this.responseText);
break;
@tomasperezv
tomasperezv / gist:2731665
Created May 19, 2012 17:43
Access-Control-Allow-Origin example
Access-Control-Allow-Origin: http://www.example.com
@tomasperezv
tomasperezv / gist:2731727
Created May 19, 2012 18:02
Fallback to XDomainRequest object to perform a crossdomain AJAX request
try {
xhr.open(method, url, true);
} catch (e) {
if (window.XDomainRequest) {
// Fallback to XDomainRequest
var xdr = new XDomainRequest();
xdr.open("get", url);
xdr.onload = function() {
// Completed request, here we can access to the body of the response
@tomasperezv
tomasperezv / gist:3217857
Created July 31, 2012 15:33
tmux synchronize-panes
ctrl+w :setw synchronize-panes
@tomasperezv
tomasperezv / gist:3225093
Created August 1, 2012 08:44
pip commands
# @see http://guide.python-distribute.org/pip.html
# Install package from remote repository
pip install -e svn+http://svn.colorstudy.com/INITools/trunk#egg=initools-dev
# Install package from local checkout
pip install -e path/to/repo
@tomasperezv
tomasperezv / gist:3225204
Created August 1, 2012 09:01
HTTP benchmarking with siege
cut -d ' ' -f7 /var/log/apache2/access.log > urls.txt
siege -c<concurreny rate> -b -f urls.txt
@tomasperezv
tomasperezv / gist:3247854
Created August 3, 2012 13:48
Testing UDP connectivity with netcat
# client machine
nc -uv servname 7000
# server
nc -ulvp 7000
@tomasperezv
tomasperezv / gist:3730388
Created September 15, 2012 23:45
Git: Create branch from other
git checkout -b feature-branch source-branch
@tomasperezv
tomasperezv / cache.js
Created September 16, 2012 18:59
Cache wrapper
/**
* @var Array _cache
*/
this._cache = [];
/**
* @param String category
* @param String key
* @param Mixed value
*/
@tomasperezv
tomasperezv / gist:3748470
Created September 19, 2012 08:40
Rate limiting in scp
scp -l kbits