Skip to content

Instantly share code, notes, and snippets.

View iamrobert's full-sized avatar

Robert Stark iamrobert

View GitHub Profile
@zethzeth
zethzeth / php-json-helper.php
Last active March 1, 2022 06:16
Decontaminate text in PHP, preparing for json_decode
/**
* Text cleaner
*
* Primary sources:
* - https://stackoverflow.com/questions/17219916/json-decode-returns-json-error-syntax-but-online-formatter-says-the-json-is-ok
* - https://stackoverflow.com/questions/2348152/detect-bad-json-data-in-php-json-decode
*/
function decontaminate_text(
$text,
$remove_tags = true,
@pierrehenri220
pierrehenri220 / barba-settings.js
Created December 6, 2016 01:25
Update html head tags with Barba.js
Barba.Dispatcher.on('newPageReady', function(currentStatus, oldStatus, container, newPageRawHTML) {
// html head parser borrowed from jquery pjax
var $newPageHead = $( '<head />' ).html(
$.parseHTML(
newPageRawHTML.match(/<head[^>]*>([\s\S.]*)<\/head>/i)[0]
, document
, true
)
);
var headTags = [
@PyramisDev
PyramisDev / Country name and flag in php.php
Created September 25, 2013 05:44
Country name and flag in php
Get Country
-----------
<?php
$country = file_get_contents('http://api.hostip.info/country.php?ip='.$_SERVER['REMOTE_ADDR']);
echo $country; //Remove this line
?>