Skip to content

Instantly share code, notes, and snippets.

View PavelJurasek's full-sized avatar

Pavel Jurásek PavelJurasek

View GitHub Profile
m(x) = x^8 + x^4 + x^3 + x + 1
a = 06 => x^2 + x
b = 2E => x^5 + x^3 + x^2 + x
a + b = x^5 + x^3 + 2x^2 + 2x
= x^5 + x^3
a * b = x^7 + x^6 + x^5 + 2x^4 + 2x^3 + x^2
= x^7 + x^6 + x^5 + x^2
#!/bin/bash
for f in `cat $1`; do
ping -c 1 -W 500 $f > /dev/null
rc=$?
if [[ rc -eq 2 ]]; then
echo $f;
fi;
done;
@PavelJurasek
PavelJurasek / timeMachine.sh
Last active July 25, 2017 12:54
Bash script for excluding development files from Time Machine backups
#!/bin/bash
# place this into your development directory (usually ~/Sites)
dir=$(cd `dirname $0` && pwd)
directories=(vendor node_modules temp log)
for dirname in "${directories[@]}"
do
@PavelJurasek
PavelJurasek / ckeditor.sh
Created September 1, 2017 10:29
Remove unused langs from ckeditor
for f in `find ckeditor/plugins/**/lang -type f`; do
grep -q "lang/[^(cs|en)].js" $f;
if [ $? -eq 1 ]; then
rm $f;
fi;
done
#!/bin/bash
for image in "$@"
do
NAME=`basename $image .webp`
echo $NAME
dwebp $image -o ~/Desktop/$NAME.png
done
@PavelJurasek
PavelJurasek / variants.js
Created May 7, 2019 16:59
Create variants of all attributes
const attrs = [
['r', 'g', 'b'],
['l', 'm', 's'],
['cyan', 'magenta'],
['ano', 'ne'],
];
let variants = [];
@PavelJurasek
PavelJurasek / sandbox.js
Created May 7, 2019 19:05
Build variant slug from pattern
const Product = {
"attributes": [
{
"name": "Color",
"value": "red", // whatever
},
{
"name": "Size",
"value": 'M',
@PavelJurasek
PavelJurasek / ecs.yaml
Created October 22, 2019 14:17
Co bychom udělali jinak? - Spaceflow & Rector talk at Péhápkaři 2019/10, LMC
# install: composer require symplify/easy-coding-standard --dev
# dry-run: vendor/bin/ecs check src
# run: vendor/bin/ecs check src --fix
# ----------------------------- Step 1 -----------------------------
services:
# use ::class
Symplify\CodingStandard\Fixer\Php\ClassStringToClassConstantFixer: ~
@PavelJurasek
PavelJurasek / ecs.yaml
Created October 22, 2019 14:17
Co bychom udělali jinak? - Spaceflow & Rector talk at Péhápkaři 2019/10, LMC
# install: composer require symplify/easy-coding-standard --dev
# dry-run: vendor/bin/ecs check src
# run: vendor/bin/ecs check src --fix
# ----------------------------- Step 1 -----------------------------
services:
# use ::class
Symplify\CodingStandard\Fixer\Php\ClassStringToClassConstantFixer: ~
@PavelJurasek
PavelJurasek / ecs.yaml
Created October 22, 2019 14:17
Co bychom udělali jinak? - Spaceflow & Rector talk at Péhápkaři 2019/10, LMC
# install: composer require symplify/easy-coding-standard --dev
# dry-run: vendor/bin/ecs check src
# run: vendor/bin/ecs check src --fix
# ----------------------------- Step 1 -----------------------------
services:
# use ::class
Symplify\CodingStandard\Fixer\Php\ClassStringToClassConstantFixer: ~