Skip to content

Instantly share code, notes, and snippets.

View Neoglyph's full-sized avatar
🧙
wizard in training since 1989

Adam Stradovnik Neoglyph

🧙
wizard in training since 1989
View GitHub Profile
@Neoglyph
Neoglyph / laravel-last-login.php
Last active August 2, 2018 12:08
Laravel last login event
<?php
// thanks to: https://stevenwestmoreland.com/2017/03/recording-last-login-information-using-laravel-events.html
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
@Neoglyph
Neoglyph / resolve.scss
Created September 5, 2018 11:03
Mix - resolve loop import issue
@import url("~fullcalendar/dist/fullcalendar.min.css");
@Neoglyph
Neoglyph / rgb2cmyk.php
Last active November 17, 2023 21:57
Convert RGB to CMYK in PHP with Imagick
<?php
$iccProfile = '../path_to_icc/Profile.icc';
$image = new Imagick();
$image->clear();
$image->readImage($imagePath);
if ($image->getImageColorspace() == Imagick::COLORSPACE_CMYK) {
return;
}
$iccCmyk = file_get_contents($iccProfile);
@Neoglyph
Neoglyph / remove-remote-tag
Created October 22, 2018 11:19
GIT - Remove remote tag
git tag -d tag-name
git push origin :refs/tags/tag-name
@Neoglyph
Neoglyph / lazyloadbg.js
Created November 27, 2018 09:48
Lazyload background images
const loadBackgroundImage = (element) => {
if (typeof element.dataset.src === 'undefined') { return }
const src = element.dataset.src
element.style.backgroundImage = `url(${src})`
element.removeAttribute('data-src')
}
const handleIntersection = (entries, observer) => {
for(let i = 0; i < entries.length; ++i) {
loadBackgroundImage(entries[i].target)
@Neoglyph
Neoglyph / resize-images-shell.sh
Created December 17, 2018 08:33
Simple shell script to resize images to specific sizes with imagemagick
shopt -s nullglob
for i in *.png; do
echo "Resizing $i"
FILE=$i
FILENAME="${FILE%%.*}"
EXT="${FILE##*.}"
convert $FILE -resize 270x "./resized/${FILENAME}-270.${EXT}"
convert $FILE -resize 320x "./resized/${FILENAME}-320.${EXT}"
convert $FILE -resize 560x "./resized/${FILENAME}-560.${EXT}"
convert $FILE -resize 800x "./resized/${FILENAME}-800.${EXT}"
@Neoglyph
Neoglyph / Model.php
Created February 25, 2019 13:07
Laravel Model Events
class User extends Model
{
public static function boot()
{
parent::boot();
self::creating(function($model){
// ... code here
});
@Neoglyph
Neoglyph / limit-file-upload.js
Created March 26, 2019 16:05
Limit file size on file input (basic javascript)
var imageStatus = document.getElementById('my-file-input');
// imageStatus = input[type="file"]
if (files[0].size > fileMaxSize) {
imageStatus.innerText = 'Datoteka ne sme biti večja od 5MB!';
imageUpload.value = '';
var imageUploadClone = imageUpload.cloneNode(true);
imageUpload.parentNode.replaceChild(imageUploadClone, imageUpload);
}
@Neoglyph
Neoglyph / redis-cli-delete
Created August 21, 2019 08:07
REDIS delete keys by pattern
Lets say your keys start with `sync:`
Removes the whole key store
redis-cli --scan --pattern sync:* | xargs redis-cli del
Removes the key store for a specific parameter
redis-cli --scan --pattern sync:PARAMETER | xargs redis-cli del
@Neoglyph
Neoglyph / prevent-scroll.scss
Created August 22, 2019 13:57
Prevent ios mobile scroll on mobile
body.on-scroll {
overflow-y: hidden !important;
}
.modal-overlay {
-webkit-overflow-scrolling: touch;
}