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 / 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;
@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 / 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 / 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();
}
View fuzzysearch.js
'use strict';
function fuzzySearch (subject, pattern) {
var i = 0, n = -1, l;
subject = subject.toLowerCase();
pattern = pattern.toLowerCase();
for (; l = pattern[i++];)
if (!~(n = subject.indexOf(l, n + 1)))
@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 / colorContrast.js
Created Sep 15, 2015
Get best contrast to a given color
View colorContrast.js
// rgb is a array [r, g, b]
function colorContrast (rgb) {
var r = rgb.r * 255,
g = rgb.g * 255,
b = rgb.b * 255;
var factor = (r * 299 + g * 587 + b * 114) / 1000;
return (factor >= 128) ? 'dark' : 'light';
}
@rodrigoalviani
rodrigoalviani / tor_curl.php
Created Nov 17, 2015 — forked from zachflower/tor_curl.php
How To Anonymize PHP cURL Requests Using Tor
View tor_curl.php
<?php
$ip = '127.0.0.1';
$port = '9051';
$auth = 'PASSWORD';
$command = 'signal NEWNYM';
$fp = fsockopen($ip,$port,$error_number,$err_string,10);
if(!$fp) { echo "ERROR: $error_number : $err_string";
return false;
View accent_replace.php
<?
preg_replace("/&([a-z])[a-z]+;/i", "$1", htmlentities($valor));
View crawler haskell
-- | URL Doc : http://hackage.haskell.org/package/url-2.1.3/docs/Network-URL.html
module Page where
import Network.URL
import Network.Curl
import Text.XML.HXT.Core
import Text.HandsomeSoup
data Page = Page {
title :: String,
You can’t perform that action at this time.