Skip to content

Instantly share code, notes, and snippets.

View CristalT's full-sized avatar

Marcelo Forclaz CristalT

View GitHub Profile
/**
* With axios agent
*/
axios({
url: 'url',
method: 'POST',
responseType: 'blob'
}).then(res => {
const fileURL = URL.createObjectURL(res.data);
window.open(fileURL);
@CristalT
CristalT / cropimg.php
Last active December 30, 2019 20:41
Recorta los espacios vacíos de una imagen PNG y la guarda como JPG.
$png = 'image/path/filename.png';
$img = imagecreatefrompng($png);
//find the size of the borders
$b_top = 0;
$b_btm = 0;
$b_lft = 0;
$b_rt = 0;
//top
$ch = curl_init();
$options = [
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_ENCODING => "", // handle compressed
CURLOPT_USERAGENT => "test", // name of client
CURLOPT_AUTOREFERER => true, // set referrer on redirect
@CristalT
CristalT / env-parser
Last active December 28, 2021 16:01
Converts string values into native types for .env values
const env = (key, defaultValue = null) => {
const value = process.env[key] ?? defaultValue;
switch (String(value).toLowerCase()) {
case 'true' || '(true)':
return true;
case 'false' || '(false)':
return false;
case 'empty' || '(empty)':
return '';
case 'null' || '(null)':