This file contains 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
/** | |
* This code snippet calculates the discount % on eKupi.hr and injects the info for each listing. | |
* | |
* Usage: Paste the code int Snippets in Chrome DevTools, open ekupi.hr page of interest, | |
* right-click the Snipper and choose Run. | |
*/ | |
$('.price-block').each(function () { | |
const $this = $(this); | |
const oldPrice = parseInt($this.find('.item-old-price').text().replace(',00 kn', '').replace('.', '')); | |
const newPrice = parseInt($this.find('.price').text().replace(',00 kn', '').replace('.', '')); |
This file contains 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
/** | |
* Helper to filter out the empty properties(null, undefined, [], or '') from the given object | |
* | |
* @param {{}} obj | |
* @returns {{}} | |
*/ | |
const removeEmptyProps = (obj) => { | |
return Object.keys(obj) | |
// remove params that are empty | |
.filter(key => { |
This file contains 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
/** | |
* Get all filters w/ regexp, because UrlSearchParams sux | |
* | |
* @param string url | |
* @return Object | |
*/ | |
function extractFilters(url) { | |
return url.matchAll( | |
/[&?]filter\[([^\]]+)\]=([^&]+)/g | |
) |
This file contains 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 | |
/** | |
* New versions of Chrome will not render html responses inside of ajax requests that requested json, which | |
* breaks Laravel's dd() helper method as well as eloquents' ->dd() methods, making it far more complicated | |
* to see what the generated SQL looks like. This is a simple workaround: | |
*/ | |
// instead of `dd($foo);` | |
return response()->json($foo, 500); |
This file contains 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 | |
$img = new Imagick($img); | |
// code by Max Eremin http://php.net/manual/en/imagick.stripimage.php#120380 | |
// we need to keep the ICC profiles | |
$profiles = $img->getImageProfiles('icc', true); | |
// but remove everything else |
This file contains 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
Show hidden characters
{ | |
"parser": "babel-eslint", | |
"extends": [ | |
"eslint:recommended", | |
"plugin:react/recommended", | |
"eslint-config-prettier" | |
], | |
"parserOptions": { | |
"ecmaVersion": 2018, | |
"sourceType": "module", |
This file contains 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
document | |
// can be any element that knows how to recieve the paste event | |
.getElementById('someElement') | |
// add event listener | |
.addEventListener('paste', e => { | |
if (! e.clipboardData.types.includes('text/html')) { | |
// if there's no html on the clipboard ignore it | |
return; | |
} |
This file contains 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
// Lists of countries with ISO 3166 codes, presented in various formats. | |
// Last Updated: July 30, 2020 | |
// If you're using PHP, I suggest checking out: | |
// https://github.com/thephpleague/iso3166 | |
// or Laravel: https://github.com/squirephp/squire | |
// | |
// JS developers can check out: | |
// https://www.npmjs.com/package/iso3166-2-db | |
// |
This file contains 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 | |
/** | |
* Convert | |
* http://stackoverflow.com/questions/12516842/convert-psd-and-ai-to-png-jpg-with-imagick | |
* @param string $dir Directory to save to. | |
* @param string $tmpName The name to name the file excluding the extension. | |
* @param string $fileType | |
* @param string $size Large or small. | |
*/ |
This file contains 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
tail -f nohup.out | grep -i error | while read line; do say 'Error!'; done |
NewerOlder