Skip to content

Instantly share code, notes, and snippets.

View bajzarpa's full-sized avatar

Arpad Bajzath bajzarpa

View GitHub Profile
@bajzarpa
bajzarpa / convert.sh
Last active March 25, 2024 07:46
Convert png or jpg images to WebP using ffmpeg from cli
#!/bin/bash
convert_to_webp() {
for file in "$@"; do
if [[ $file == *.png ]]; then
filename=$(basename -- "$file")
filename="${filename%.*}"
ffmpeg -i "$file" -compression_level 6 "${filename}.webp"
elif [[ $file == *.jpg ]]; then
filename=$(basename -- "$file")
@bajzarpa
bajzarpa / legacy-vuex-option-adapter.js
Created April 25, 2022 12:43
Vue.js plugin to use VueX 3 with old VueX
const LegacyVuexOptionAdapter = {
install(Vue) {
Vue.mixin({
beforeCreate() {
vuexAdapterInit.call(this, Vue);
},
});
// option merging
const merge = Vue.config.optionMergeStrategies.computed;
@bajzarpa
bajzarpa / angular.gravatar.directive.js
Last active February 8, 2017 13:37
Angular.js directive to get user gravatar from user email
// npm install md5 --save
import md5 from 'md5';
let gravatarModule = angular.module('gravatar', [])
.directive('gravatar', () => {
const DEFAULT_AVATAR = "http://www.gravatar.com/avatar/000?s=200";
const EMAIL_REGEX = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
let isEmail = (email) => EMAIL_REGEX.test(email);
@bajzarpa
bajzarpa / symlink.js
Created June 13, 2016 13:24
Create symlinks with filepatterns
@bajzarpa
bajzarpa / what-forces-layout.md
Last active September 21, 2015 21:00 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()