Skip to content

Instantly share code, notes, and snippets.

View macmladen's full-sized avatar

Mladen Đurić macmladen

View GitHub Profile
@macmladen
macmladen / magick.sh
Created May 16, 2024 15:42
ImageMagick useful oneliners
# Take each image, (900x1600)
# crop it to 900x900 by translating x=0 and Y=350
# repage - reset canvas
# resize then to 300x300
# delay between animated frames
# cyclic loop
# all *.jpg in the directory to resulting gif
magick *.jpg -crop 900x900+0+350 +repage -resize 300x300 -delay 6 -loop 0 *.jpg animated.gif
# Further savings: -layers 'optimize' -fuzz 7%
// International data based on browser preference
Intl.DateTimeFormat().resolvedOptions()
// Timezone offset to UTC
(new Date()).getTimezoneOffset()
// Array from browser
navigator.languages
// Language Attribute if page has it
#!/usr/bin/env bash
##
# Commands to get Next.js working with Drupal
#
# Author:
# - Mladen Djuric @MacMladen
#
# Requirements:
# - having DDEV installed https://ddev.readthedocs.io/en/stable/users/install/ddev-installation/
@macmladen
macmladen / smtp-terminal.sh
Created August 2, 2022 13:00
Connecting to SMTP SSL server in terminal to be sure that sending works.
### Connecting to SMTP over SSL on 465
openssl s_client -connect smtp.zoho.com:465
# CONNECTED(00000006)
# depth=1 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = Thawte TLS RSA CA G1
# verify error:num=20:unable to get local issuer certificate
# verify return:0
# ---
# Certificate chain
# 0 s:/CN=*.zoho.com
@macmladen
macmladen / ssh-key-gen.sh
Last active July 15, 2024 11:03
Use new ssh key encryption EdDSA (type ed25519). Everything on using SSH agent. Not a script to run but a reference list of useful sample commands.
# Generating new SSH key best practice
# RSA is most widely used, 4096 bits recommended!
# Ed25519 was introduced in OpenSSH 6.5 of January 2014
# Ref: https://goteleport.com/blog/comparing-ssh-keys/
# Ref: https://medium.com/risan/upgrade-your-ssh-key-to-ed25519-c6e8d60d3c54
# List all your keys
for key in ~/.ssh/id_*; do ssh-keygen -l -f "${key}"; done | uniq
@macmladen
macmladen / drupal_radiokarantin_check_media.sql
Last active July 7, 2021 08:34
Drupal, Radiokarantin.eu: Check which post reference which media
SELECT nid, node_field_data.status, type, FROM_UNIXTIME(node_field_data.created) AS Created, title, field_soundcloud_target_id AS mid, name, field_media_oembed_video_value AS Link
FROM `node_field_data`
LEFT JOIN `node__field_soundcloud` on node_field_data.nid=node__field_soundcloud.entity_id
LEFT JOIN `media__field_media_oembed_video` on field_soundcloud_target_id=media__field_media_oembed_video.entity_id
LEFT JOIN `media_field_data` on field_soundcloud_target_id=mid
WHERE type='article' OR type='episode'
ORDER BY nid DESC
@macmladen
macmladen / wp_users_extended.sql
Last active June 22, 2021 13:13
WordPress select users and extended profile data which is stored in same column. Lookup hint https://dba.stackexchange.com/questions/9011/proper-use-of-lookup-tables
SELECT ID, user_email email, user_registered registered, user_status status,
(SELECT meta_value FROM `pltfrm_usermeta` WHERE meta_key='last_activity' AND user_id=u.ID ) as active,
(SELECT meta_value FROM `pltfrm_usermeta` WHERE meta_key='first_name' AND user_id=u.ID ) as Name,
(SELECT meta_value FROM `pltfrm_usermeta` WHERE meta_key='last_name' AND user_id=u.ID ) as Surname
FROM `pltfrm_users` u
@macmladen
macmladen / youtube_list_time.js
Last active April 23, 2021 13:05
When you are on YouTube playlist page and want to know how long will the list play. You can paste it in console and run to get time in hh:mm:ss.
const all = [];
document
.querySelectorAll('ytd-playlist-video-renderer ytd-thumbnail-overlay-time-status-renderer')
.forEach(a => all.push(a.textContent.trim()));
let videosLength = 0;
all.forEach(a => {
const timeSplit = a.split(':');
videosLength += timeSplit[0]*60 + timeSplit[1]*1;
@macmladen
macmladen / redirect.js
Created August 19, 2019 17:55
JavaScriptp HTTP like redirect
// similar behavior as an HTTP redirect
// window. object can be omitted
window.location.replace("https://nisville.com/");
@macmladen
macmladen / OSX Secure Disk Wipe.md
Last active July 6, 2019 10:33 — forked from joeblau/OSX Secure Disk Wipe.md
Securely erase an external disk using dd on OSX

Securely erase an external disk using dd on OSX

  1. Plug in your SD card, HDD, or other block device and then use the following command to see which /dev/diskN node it's located on:
diskutil list
  1. Unmount the disk where N is the number of the disk taken from the above command: