This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
function decrypt($secret, $string) | |
{ | |
try { | |
Firebase\JWT\JWT::$leeway = 1; // $leeway in seconds is a clock skew times between the signing and verifying servers | |
$string = base64_decode($string); | |
return (array) Firebase\JWT\JWT::decode( | |
openssl_decrypt( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OptiPNG is a useful tool to compress png images without loss its quality, it really help reduce the bandwidth, diskspace and the loading/response time for website. I used it to re-compress all the png images on cdnjs and successfully made 206857 images smaller(see cdnjs/cdnjs@e936c87e9044fd2b123). | |
It’s easy to use, you can install it via apt-get, or download and build it from source : | |
$ sudo apt-get install optipng | |
Usage: | |
$ optipng example.png | |
The default compress level is 2, the range is 0~7 (may depends on the version you are using), I will always use the highest and slowest level: | |
$ optipng -o7 example.png |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Move image inside <p> tag above the <p> tag while preserving any link around image. | |
* Can be prevented by adding any attribute or whitespace to <p> tag, e.g. <p class="yolo"> or even <p > | |
*/ | |
function remove_p_around_img($content) | |
{ | |
$contentWithFixedPTags = preg_replace_callback('/<p>((?:.(?!p>))*?)(<a[^>]*>)?\s*(<img[^>]+>)(<\/a>)?(.*?)<\/p>/is', function($matches) { | |
$image = $matches[2] . $matches[3] . $matches[4]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
print '<pre>'; | |
class parserXPath extends DOMXPath { | |
private function getPage($url){ | |
$ch = curl_init(); | |
curl_setopt ($ch , CURLOPT_URL , $url); | |
curl_setopt ($ch , CURLOPT_USERAGENT , "Mozilla/5.0"); | |
curl_setopt ($ch , CURLOPT_RETURNTRANSFER , 1 ); | |
// можете добавить кучу других опций |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Youtube link embed conversion | |
* | |
* https://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg | |
* https://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg | |
* https://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg | |
* https://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg | |
* | |
* https://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// date | |
$date = '423523463463'; // time stamp | |
$date = date("F j, Y, g:i a", $date); | |
// satring to date | |
$str = strtotime('10/16/2016'); | |
$date = date('M d Y',$str); | |
echo $date; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* ---------------------------------------------------------- */ | |
/* minibots.class.php Ver.1.9g */ | |
/* ---------------------------------------------------------- */ | |
/* Mini Bots class is a small php class that allows you to */ | |
/* use some free web seriveces online to retrive usefull data */ | |
/* and infos. This version includes: */ | |
/* smtp validation, check spelling, meteo, exchange rates, */ | |
/* shorten urls, and geo referencing with IP address and more */ | |
/* Feel free to use in your applications, but link my blog: */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by PhpStorm. | |
* User: thiphariel | |
* Date: 15/08/17 | |
* Time: 19:40 | |
*/ | |
namespace App\Api; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* simple method to encrypt or decrypt a plain text string | |
* initialization vector(IV) has to be the same when encrypting and decrypting | |
* | |
* @param string $action: can be 'encrypt' or 'decrypt' | |
* @param string $string: string to encrypt or decrypt | |
* | |
* @return string | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Installing memcached on Mac with Homebrew and Lunchy | |
This is a quick guide for installing memcached on a Mac with Homebrew, and starting and stopping it with Lunchy. I hope this tutorial will get your memcached up and running in no time. | |
Step 1 — Install Homebrew | |
Installing Homebrew is super easy. Just paste this in your terminal — | |
$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" | |
You should also make sure your Homebrew is up-to-date. Use update and doctor commands to update and fix any issues it may have. |