Skip to content

Instantly share code, notes, and snippets.

View elfacht's full-sized avatar
🥰
Love code, hate racism

Martin Szymanski elfacht

🥰
Love code, hate racism
View GitHub Profile
@elfacht
elfacht / cache-breaker-bookmarklet.js
Last active October 8, 2020 08:20
🤸🏽‍♀️ Cache Breaker Bookmarklet
javascript:(function()%7Bvar%20url%20%3D%20location.protocol%20%2B%20'%2F%2F'%20%2B%20location.host%20%2B%20location.pathname%3Bwindow.location.href%20%3D%20url%20%2B%20'%3F'%20%2B%20Math.floor((Math.random()%20*%20100000000000)%20%2B%201)%7D)()
@elfacht
elfacht / mixin-elements-last-row.scss
Last active October 21, 2021 04:59
Modify elements in last row
// Modify the items in the last row
// @param {Number} $range
// @param {String} $selector
@mixin u-last-row($range: 2, $selector: '.selector') {
&:nth-last-child(-n+#{$range}):nth-child(#{$range}n+1),
&:nth-last-child(-n+#{$range}):nth-child(#{$range}n+1) ~ #{$selector} {
@content;
}
}
@elfacht
elfacht / craft-updater.sh
Last active November 9, 2021 19:30
Update all local Craft CMS installations with one bash script. #craftcms
#!/bin/bash
#
# Update all local Craft CMS installations at once
# by adding the folder names and running:
#
# $ ./craft-updater.sh
#
ROOT_PATH="/path/to/local/htdocs/"
@elfacht
elfacht / imagemagick.sh
Created January 5, 2022 08:55
imagemagick CLI
# resize width only
convert input.jpg -resize 400 output.jpg
# resize height only
convert input.jpg -resize x400 output.jpg
# crop from center
convert input.jpg -gravity center -crop 200x200+0+0 +repage output.jpg
# convert all images to new name
@elfacht
elfacht / localhosts.sh
Created January 5, 2022 09:04
Restore localhosts
##
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
@elfacht
elfacht / npm.sh
Created January 5, 2022 09:05
Install npm without sudo on macOS
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@elfacht
elfacht / vscode-lagging.sh
Last active January 5, 2022 09:05
VSCode Lagging Fix on macOS
codesign --remove-signature /Applications/Visual\ Studio\ Code.app/Contents/Frameworks/Code\ Helper\ \(Renderer\).app
@elfacht
elfacht / macos.sh
Last active January 5, 2022 09:05
macOS Settings
# Show system info on startup
sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName
# Change screen shots file type
defaults write com.apple.screencapture type jpg && killall SystemUIServer
# Change screen shot default file name
defaults write com.apple.screencapture name "Screen shot" && killall SystemUIServer
# Change screen shots location
@elfacht
elfacht / composer-hetzner.sh
Created January 5, 2022 09:08
Install Composer on Hetzner Server
php -d allow_url_fopen=On ../../composer.phar install
@elfacht
elfacht / general.sh
Last active January 5, 2022 09:19
Asset Version Number with Nitro #craftcms
# /etc/nginx/craftcms/general.conf
location ~ "^/(.+)\.(\d+)\.(bmp|css|cur|gif|ico|jpe?g|js|png|svgz?|webp|webmanifest)$" {
try_files $uri /$1.$3$is_args$args;
}