Create droplet of your liking (ubuntu 12.10 x32)
ssh to root in terminal with your server ip
ssh root@123.123.123.123
Add ssh fingerprint and enter password provided in email
[ -f /etc/hosts ] && echo "Found" || echo "Not found" |
$ iptables -I INPUT -p tcp --dport 80 -m state --state NEW -m recent --set | |
$ iptables -I INPUT -p tcp --dport 80 -m state --state NEW -m recent --update --seconds 30 --hitcount 10 -j DROP | |
#Source: http://codingfreak.blogspot.ca/2010/01/iptables-rate-limit-incoming.html |
source: http://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/ | |
`openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]` | |
What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file. This is the password that you used to protect your keypair when you created your .pfx file. If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!. Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file. | |
Now let’s extract the certificate: | |
`openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]` |
<?php | |
//Bad Email... | |
$badEmail = "bad@email"; | |
//Run the email through an email validation filter. | |
if( !filter_var($badEmail, FILTER_VALIDATE_EMAIL) ){ | |
echo "Email is no good."; | |
}else{ | |
echo "Nice email."; | |
} |
Upload multiple files with php | |
<?php | |
fixFilesArray($_FILES['array_of_files']); | |
foreach ($_FILES['array_of_files'] as $position => $file) { | |
// should output array with indices name, type, tmp_name, error, size | |
var_dump($file); | |
} | |
?> |
<?php | |
/** | |
* Retorna todos os status do Correios para ID enviado | |
* | |
* @param string $id_correios ID do Correios | |
* @return array $array_retorno | |
*/ | |
function status_correios( $id_correios ) { | |
$conteudo = file_get_contents('http://websro.correios.com.br/sro_bin/txect01$.QueryList?P_LINGUA=001&P_TIPO=001&P_COD_UNI='.$id_correios); |
<?php | |
$num=103; | |
if($num & 1) { | |
#impar | |
return true; | |
} else { | |
#par | |
return false; |
<?php | |
/* | |
* usage: echo tweetCount('http://google.com'); | |
* ref: http://www.phpsnippets.info/get-how-many-times-a-page-have-been-retweeted-using-php | |
*/ | |
function tweetCount($url) { | |
$content = file_get_contents("http://api.tweetmeme.com/url_info?url=".$url); | |
$element = new SimpleXmlElement($content); | |
$retweets = $element->story->url_count; | |
if($retweets){ |
/* | |
* Calcula distancias | |
*/ | |
function distance($lat1, $lon1, $lat2, $lon2, $unit) { | |
$theta = $lon1 - $lon2; | |
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta)); | |
$dist = acos($dist); | |
$dist = rad2deg($dist); | |
$miles = $dist * 60 * 1.1515; |