Skip to content

Instantly share code, notes, and snippets.

View lastguest's full-sized avatar
❄️
I may be slow to respond.

Stefano Azzolini lastguest

❄️
I may be slow to respond.
View GitHub Profile
@lastguest
lastguest / is_fake_email.php
Created September 7, 2018 12:57
[PHP] is_fake_email
<?php
function is_fake_email($email){
return preg_match('~[^@]+@((\d+-m(ail)?|\d+c(huan|lickemail|n)|\d+d(-painting|ays-printing)|\d+(experts|hosting|mail|minutemail|ox|pad|paq|prong|tags|url|warding|wnd|zhuan)?|a(-bc|frobacon|g|gedmail|jaxapp|livance|milegit|miri|miriindustries|nappthat|no-mail|nonbox|nonymail|nonymbox|ntichef|ntispam|rmyspy|zmeil)|be(ddly|efmilk)|big(professor|string)|bi(nkmail|o-muesli)|bo(bmail|dhi\.lawlita|fthew|otybay|un|uncr|xformail)|bre(fmail|nnendesreich)|b(axomale\.ht|logmyway|roadbandninja|snow|u\.mintemail|uffemail|ugmenot|umpymail|und|urnthespam|uyusedlibrarybooks)|c(2|asualdx|ellurl|entermail|hammy|heatmail|hogmail|hoicemail1|hong-mail|lixser|mail|onsumerriot|ool|orreo\.blogos|osmorph|ourriel|ourrieltemporaire|rapmail|razymailing|ubiclink|urryworld|ust|uvox)|da(coolest|ndikmail|yrep)|d(bunker|cemail|eadaddress|eadspam|eagot|ealja|espam|espammed|evnullmail|fgh|igitalsanctuary|ingbone|iscardmail|isposableaddress|isposableemailaddresses|isposableinbox|ispose|isposeamail|isposem
@lastguest
lastguest / getFacebookSharesForURL.php
Created September 7, 2018 12:56
[PHP] getFacebookSharesForURL
<?php
function getFacebookSharesForURL($url){
return (int)substr(
$data = file_get_contents("http://graph.facebook.com/?id=" . urlencode($url)),
$p = strpos($data, $t = '"share_count":') + strlen($k),
(strpos($data,'}',$p) ?: strpos($data,',',$p)) - $p
);
}
@lastguest
lastguest / RESP.php
Created September 7, 2018 12:56
[WIP] REDIS Protocol Enc/Dec
<?php
/**
*
* REDIS Protocol Encoder/Decoder
* http://redis.io/topics/protocol
*
*/
class RESP {
@lastguest
lastguest / Query.php
Created September 7, 2018 12:54
[WIP] Query Builder (Core)
<?php
namespace SQL;
class Query {
public static function select(){
return new QuerySelect;
}
}
@lastguest
lastguest / lazy-image-tag-generator.html
Created September 7, 2018 12:54
[HTML] Lazy Image Tag generator
<style>
body { background-color:#111; color:#eee; text-align:center; font: normal 14px/1.1em Helvetica }
#output { width:100%;height:200px;padding:1em;border:1px #000 dashed; background: rgba(255, 255, 255, 0.08); color: #ccc;
font-size: 0.9em;
font-family: monospace;}
#image_url{ font-size: 1.6em; width: 100%; text-align:center; background: rgba(255,255,255,.2); color:#fff; border: 0; padding: 0.7em;}
.btn {
box-shadow:inset 0px 1px 0px 0px #ffffff;
background:linear-gradient(to bottom, #f9f9f9 5%, #e9e9e9 100%);
background-color:#f9f9f9;
@lastguest
lastguest / get_extended_post_data_by_id.php
Created September 7, 2018 12:53
[WP] Get Extended (with post meta) Post Data
<?php
function get_extended_post_data_by_id($ID, $hide_private=true){
global $wpdb;
$meta_where = $hide_private ? "and substr(meta_key,1,1) <> '_'" : '';
return (object) array_reduce($wpdb->get_results("
(select 'id' k, ID v from $wpdb->posts where ID = $ID) union
(select 'title' k, post_title v from $wpdb->posts where ID = $ID) union
(select 'content' k, post_content v from $wpdb->posts where ID = $ID) union
(select 'excerpt' k, post_title v from $wpdb->posts where ID = $ID) union
@lastguest
lastguest / local.typekit.js
Created September 7, 2018 12:53
[JS] TypeKit Local Caching
<!--
Questo codice si salva in localStorage le risorse interne di TypeKit
evitando il roundtrip di chiamata e il FOS.
Incollare lo snippet PRIMA del blocco :
<script src="https://use.typekit.net/gls5dvn.js"></script>
<script>try{Typekit.load({ async: true });}catch(e){}</script>
@lastguest
lastguest / array_mask.function.php
Created September 7, 2018 12:52
[PHP] array_mask
<?php
function array_mask(array $unsafe, array $mask){
return array_intersect_key(array_merge($mask, $unsafe), $mask);
}
$maschera_default = [
'name' => 'Senza Nome',
'surname' => 'Senza Cognome',
@lastguest
lastguest / CachedArray.php
Created September 7, 2018 12:52
[PHP] CachedArray class
<?php
class CachedArray implements ArrayAccess {
private $cache,
$read,
$exists,
$update,
$delete;
public function __construct($callbacks){
@lastguest
lastguest / unique_id.php
Created September 7, 2018 12:51
[PHP] Easy Unique ID Generator
<?php
function unique_id($len = 8) {
$base ='ABCDEFGHKLMNOPQRSTWXYZ0123456789';
$max = strlen($base)-1; $code='';
mt_srand((double)microtime()*1000000);
while (strlen($code)<($len+1)){
$code .= $base{ mt_rand(0,$max) };
} return $code;
}