Related Setup: https://gist.github.com/hofmannsven/6814278
Related Pro Tips: https://ochronus.com/git-tips-from-the-trenches/
<?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]; |
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 |
<?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( |
<?php | |
/* | |
* The MIT License | |
* | |
* Copyright 2016 Steve Guidetti. | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights |
<?php | |
function compose(callable $initial, callable ...$functions) | |
{ | |
if (count($functions) < 1) { | |
throw new \InvalidArgumentException('at least two functions are required'); | |
} | |
return array_reduce($functions, function ($f, $g) { | |
return function (...$args) use ($f, $g) { | |
return $f($g(...$args)); |
<?php | |
/** | |
* Command for losslessly compressing Amazon AWS images | |
*/ | |
use Illuminate\Console\Command; | |
use Symfony\Component\Console\Input\InputOption; | |
use Symfony\Component\Console\Input\InputArgument; | |
/** |
#include "FastLED.h" | |
// FastLED "100-lines-of-code" demo reel, showing just a few | |
// of the kinds of animation patterns you can quickly and easily | |
// compose using FastLED. | |
// | |
// This example also shows one easy way to define multiple | |
// animations patterns and have them automatically rotate. | |
// | |
// -Mark Kriegsman, December 2014 |
<?php | |
ini_set('max_execution_time', 0); | |
ini_set('memory_limit' , '500M'); | |
class convert2bloger { | |
private $database = NULL; | |
private $errors = array(); | |
private $curEntry = array(); // current entry of the parser |
Related Setup: https://gist.github.com/hofmannsven/6814278
Related Pro Tips: https://ochronus.com/git-tips-from-the-trenches/
FROM ubuntu:16.04 | |
MAINTAINER Ben Hardill <[email protected]> | |
ENV DEBIAN_FRONTEND noninteractive | |
USER root | |
RUN apt-get update && apt-get install -y \ | |
pkg-config \ |