Skip to content

Instantly share code, notes, and snippets.

View luckyshot's full-sized avatar
🌍
xaviesteve.com

Xavi Esteve luckyshot

🌍
xaviesteve.com
View GitHub Profile
@luckyshot
luckyshot / url.php
Last active October 14, 2017 13:23
Tiny PHP Helper Class to parse and work with URLs and its GET parameters
<?php
/*
Tiny PHP Helper Class to parse and work with URLs and its GET parameters
by Xavi Esteve (c) 2017 (MIT License)
Example:
$u = new Url;
$u->param('utm_source', 'xaviesteve.com');
$u->param('id', false);
*/
@luckyshot
luckyshot / ob.php
Last active January 12, 2017 16:06
PHP Buffer OB Cache flush
<?php
ob_start();
// Do whatever
$buffer = ob_get_clean();
@luckyshot
luckyshot / first_name.php
Created April 25, 2016 12:38
Extract first name from person's name
<?php
if ( isset( $info['first_name'] ) ){
$first_name = $info['first_name'];
}else{
$first_name = substr( $info['full_name'], 0, strrpos($info['full_name'], ' ') );
}
$first_name = ucwords( strtolower( $first_name ) );
@luckyshot
luckyshot / first_name.php
Created April 25, 2016 12:34
Extract first name from person's name
<?php
if ( isset( $info['first_name'] ) ){
$first_name = $info['first_name'];
}else{
$first_name = substr( $info['full_name'], 0, strrpos($info['full_name'], ' ') );
}
$first_name = ucwords( strtolower( $first_name ) );
@luckyshot
luckyshot / tvshows.js
Created September 3, 2015 13:51
TV Shows - Full list (JSON)
var shows = {"shows":["12 Monkeys","19-2 (2014)","2 Broke Girls","24","60 Minutes Australia","60 Minutes US","8 Out of 10 Cats","A D The Bible Continues","A to Z","A Young Doctor's Notebook","About a Boy","Adventure Time","Air Crash Investigation - Mayday","Alaska: The Last Frontier","Alaskan Bush People","Ali G: Rezurection","Allegiance","Almost Human","Almost Royal","Alpha House","Ambassadors","America Declassified","America Unearthed","America's Got Talent","America's Next Top Model","American Crime","American Dad!","American Horror Story","American Idol","American Ninja Warrior","American Odyssey","American Pickers","American Restoration","Ancient Aliens","Anger Management","Another Period","Anthony Bourdain: Parts Unknown","Antiques Roadshow UK","Aqua TV Show Show","Aquarius (US)","Archer (2009)","Arctic Air","Arrow","At Midnight","Atlantis","Attack on Titan","Avengers Assemble (2013)","Awkward.","Axe Cop","Baby Daddy","Babylon","Bachelor in Paradise","Back in the Game","Backstrom","Bad Education","Bad I
@luckyshot
luckyshot / compresshtml.php
Created June 2, 2015 09:22
Compress HTML output
<?php
function compressHtml($html) {
return preg_replace( ['/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s'], ['>', '<', '\\1'], $html );
}
@luckyshot
luckyshot / multilanguage.php
Created June 1, 2015 20:57
Simple Multilanguage functionality
<?php
define('LANGUAGES_PATH', 'languages/');
define('DEFAULT_LANGUAGE', 'en');
define('LANGUAGE_COOKIE_TIME', 1314000 ); // 3600 * 365 = 1314000; (1 year)
define('COOKIE_DOMAIN', '.xaviesteve.com');
/*
Usage:
@luckyshot
luckyshot / style.css
Created May 28, 2015 21:02
Readability CSS
html {
color: #444;
background: #FDFDFF;
font-family: 'Helvetica Neue', HelveticaNeue, sans-serif;
font-size: 16px;
line-height: 1.618em;
margin: 0 auto;
max-width: 50em;
text-rendering: optimizeLegibility;
}
@luckyshot
luckyshot / responsive.css
Created January 30, 2015 12:14
CSS Responsive code example
@media all and (max-width: 300px) {
}
@luckyshot
luckyshot / gender.php
Created January 28, 2015 14:40
Detects the gender (male or female) of a name
<?php
/**
* returns positive if male, negative if female
*/
function gender( $s )
{
$gender = 0; // female - , + male
$letters = array(