Skip to content

Instantly share code, notes, and snippets.

View onigetoc's full-sized avatar

Gino onigetoc

View GitHub Profile
@onigetoc
onigetoc / remote-image-cache.php
Created October 31, 2016 02:27 — forked from ScottPhillips/remote-image-cache.php
Cache remote image using PHP
<?php
function cache_image($image_url){
//replace with your cache directory
$image_path = 'path/to/cache/dir/';
//get the name of the file
$exploded_image_url = explode("/",$image_url);
$image_filename = end($exploded_image_url);
$exploded_image_filename = explode(".",$image_filename);
$extension = end($exploded_image_filename);
//make sure its an image
@onigetoc
onigetoc / get_favicon.php
Last active November 1, 2016 21:00
Get favicon V1
<?php
// REGEX LIST
// $success = preg_match('/\<link.*href=\"(.*)\" \/\>/is', $str, $matches);
// $success = preg_match('/\<link.*href=\"(.*)\" \/\>/is', $text, $matches);
echo "<h2>Find RSS Feed URLs</h2>";
//$url = "https://mrmondialisation.org";
$url = "http://stackoverflow.com/";
@onigetoc
onigetoc / get_favicon_v2.php
Last active February 23, 2018 15:36
Get Favicon V2
<?php
echo "<h2>Get Favicons URLs</h2>";
//$url = "https://mrmondialisation.org";
//$url = "http://stackoverflow.com/";
//$url = "http://changera.blogspot.ca/";
//$url = "http://veteranstoday.com";
$url = "http://www.2012un-nouveau-paradigme.com/";
//$url = "http://www.stopmensonges.com/";
//$url = "http://reseauinternational.net";
@onigetoc
onigetoc / php-regex-favicon.php
Created November 1, 2016 16:09
How to PHP regex match an HTML document's declared favicon
<?php
function parseFavicon($html) {
// Get the 'href' attribute value in a <link rel="icon" ... />
// Also works for IE style: <link rel="shortcut icon" href="http://www.example.com/myicon.ico" />
// And for iOS style: <link rel="apple-touch-icon" href="somepath/image.ico">
$matches = array();
// Search for <link rel="icon" type="image/png" href="http://example.com/icon.png" />
preg_match('/<link.*?rel=("|\').*icon("|\').*?href=("|\')(.*?)("|\')/i', $html, $matches);
if (count($matches) > 4) {
@onigetoc
onigetoc / get_favicon_V3.php
Last active October 11, 2018 15:23
Get Favicon V3
<?php
/********* LIVE DEMO: https://goo.gl/shr5Cv *********/
echo "<h1>Get Favicon</h1>";
//$url = "https://mrmondialisation.org";
//$url = "http://stackoverflow.com/";
//$url = "http://changera.blogspot.ca/";
//$url = "http://veteranstoday.com";
//$url = "http://2012un-nouveau-paradigme.com/"; // No favicon
//$url = "http://www.stopmensonges.com/";
@onigetoc
onigetoc / Split_charactere_and_word.php
Last active November 15, 2016 05:18
Google Translate php class
// split at 3000 characters
$string = "<div>Ceci est un test et on ajoute encore plus de texte</div> Ceci est un test et on ajoute encore plus de texte. Lorem ipsum dolor sit amet";
$string = wordwrap($string, 15, ";;", true);
var_dump(explode(";;", $string));
@onigetoc
onigetoc / get_hot_tag.html
Created December 1, 2016 08:34 — forked from hideokamoto/get_hot_tag.html
Get Plugin-Data fromWordPress.org API
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<div class="wp_org_api"></div>
<script>
//setUp Post Data
var actionType = 'hot_tags';
var number = 10;
var timeout = 15;
//Parse Post Data
var postData = {
@onigetoc
onigetoc / scroll_to.js
Last active December 6, 2016 01:12
Scroll to href atribute link like href="#targetID"
// DEMO: https://jsfiddle.net/onigetoc/5kh0e5f4/
function ScrollTo(target, speed, timeout, margin) {
if (!timeout) timeout = 0;
if (!speed) speed = 1000;
if (!margin) margin = 0;
if (typeof target !== "undefined") {
setTimeout(function() {
$('html,body').animate({
@onigetoc
onigetoc / replace_empty_html_tags.php
Last active December 6, 2016 17:06
Replace empty html tags with PHP
<?php
/* Write your PHP code here */
//$re = '/<(\w+)\b(?:\s+[\w\-.:]+(?:\s*=\s*(?:"[^"]*"|"[^"]*"|[\w\-.:]+))?)*\s*\/?>\s*<\/\1\s*>/';
$re = '/<([^>\s]+)[^>]*>(?:\s*(?:<br \/>|&nbsp;|&thinsp;|&ensp;|&emsp;|&#8201;|&#8194;|&#8195;)\s*)*<\/\1>/';
$str = '<h2></h2> Nous sommes en train d’assister a un évènement historique, et la semaine prochaine je serai sur les lieux à Standing Rock pour couvrir cet évènement HISTORIQUE !
<p></p>
Une énorme victoire a été faite aujourd’hui, le permis de forage a été refusé a la compagnie qui construit l’oléoduc. C’est une victoire, mais ce n’est pas fini.
La société de construction DAPL a annoncé qu’elle poursuivrai le forage malgré l’interdiction et qu’elle paierai les amendes !
Ce qui se passe à Standing Rock est EXTRAORDINAIRE, une poignée d’Indiens a tenu en échec une multinationale et met en échec un projet de 3,8 milliards de dollars !
@onigetoc
onigetoc / wp_text_widget_and_shortcode_tools.php
Last active December 21, 2016 16:57
Wordpress Filter text widget and shortcode | Allow Shortcode in text widget | Search replace in Text Widget
<?php
// ENQUEUE IF SHORTCODE IN TEXT WIDGET
function check_shortcode($text) {
$pattern = get_shortcode_regex();
if ( preg_match_all( '/'. $pattern .'/s', $text, $matches )
&& array_key_exists( 2, $matches )
&& in_array( 'myshortcode', $matches[2] ) )
{