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 / 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 / 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 / ClassAdd.js
Last active January 5, 2022 10:53
JavaScript Helper Functions
/**
* Add classes to an element
*
* @param object $element – DOM element | required
* @param string className – CSS class to be added | required
* @return function|string
*/
export default function($element, className) {
if ($element.classList) {
$element.classList.add(className);
@elfacht
elfacht / random.php
Last active January 19, 2022 19:33
Generate random key in PHP
<?php
$activation_key = mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand();
?>
@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 / 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 / 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 / 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