Skip to content

Instantly share code, notes, and snippets.

Rodrigo Alviani rodrigoalviani

Block or report user

Report or block rodrigoalviani

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rodrigoalviani
rodrigoalviani / matchPairs2.js
Created Mar 4, 2015
Match pairs - array based (with typed groups)
View matchPairs2.js
'use strict';
var i = 0
, defender = []
, attacker = []
, len = Math.max(defender.length, attacker.length);
function mathPair () {
return selectName(defender) + ' & ' + selectName(attacker);
}
@rodrigoalviani
rodrigoalviani / matchPairs.js
Last active Aug 29, 2015
Match pairs - array based
View matchPairs.js
'use strict';
var i = 0
, names = [] // add names here
, len = (names.length / 2);
function matchPair () {
return selectName() + ' & ' + selectName();
}
@rodrigoalviani
rodrigoalviani / the80.js
Last active Aug 29, 2015
Let the pages as if they were made in the 80s
View the80.js
$('*').each(function () {
var colors = ['aqua', 'blue', 'fuchsia', 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'orange', 'purple', 'red', 'silver', 'teal', 'yellow'];
$(this).css('background-color', colors[Math.floor(Math.random()*colors.length)]);
$(this).css('font-family', 'Comic Sans MS');
});
$('img').each(function () {
var imgs = [
'http://www.animatedgif.net/devilish/coolskul.gif',
'http://www.animatedgif.net/devilish/devildance_e0.gif',
@rodrigoalviani
rodrigoalviani / ip.php
Created Dec 26, 2014
Get real user IP (PHP)
View ip.php
function ip() {
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',') !== FALSE) {
$ip = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
return trim(end($ip));
} else {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
} else {
return $_SERVER['REMOTE_ADDR'];
@rodrigoalviani
rodrigoalviani / multicurl.php
Created Dec 23, 2014
Multi Curl Request (PHP)
View multicurl.php
function multiRequest($data, $connecttimeout = 10, $timeout = 10) {
$curly = array();
$result = array();
$mh = curl_multi_init();
foreach ($data as $id => $d) {
$curly[$id] = curl_init();
$url = (is_array($d) && !empty($d['url'])) ? $d['url'] : $d;
You can’t perform that action at this time.