Skip to content

Instantly share code, notes, and snippets.

Avatar

Mladen Đurić macmladen

View GitHub Profile
@macmladen
macmladen / drupal_radiokarantin_check_media.sql
Last active Jul 7, 2021
Drupal, Radiokarantin.eu: Check which post reference which media
View drupal_radiokarantin_check_media.sql
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 Jun 22, 2021
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
View wp_users_extended.sql
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 Apr 23, 2021
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.
View youtube_list_time.js
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 Aug 19, 2019
JavaScriptp HTTP like redirect
View redirect.js
// 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 Jul 6, 2019 — forked from joeblau/OSX Secure Disk Wipe.md
Securely erase an external disk using dd on OSX
View OSX Secure Disk Wipe.md

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:
@macmladen
macmladen / remove-all-followers.js
Created Mar 11, 2016
Remove all Twitter followers.
View remove-all-followers.js
/**
* Removes all followers on Twitter, usually added by profile breach.
* Usage: just copy code bellow (triple click on line & CTRL+C ) to the
* Developer console in browser, press ENTER and watch them being deleted.
*/
setInterval(function(){t=$('.following').find('.follow-button');if(!t[0]){window.scrollTo(0,$(document).height());}else{console.log(t.attr('class')); t.trigger('click');}},100)
@macmladen
macmladen / dps.sh
Created Nov 23, 2015
Build local environment for development
View dps.sh
## Always, before performing any installation, make sure that system is up to date:
# Freshen information on versions of system software packages
sudo apt-get update
# Perform upgrade of packages
sudo apt-get upgrade
# Perform upgrade of system (kernel)
sudo apt-get dist-upgrade
## Getting to know system
@macmladen
macmladen / logging_in.md
Last active Sep 13, 2016
Linux and Mac interactive shell script loading
View logging_in.md

Order of script loading for interactive login shell

User can have multiple ways to login and different OSes, different shells have different approach. As I always search for same information, I decided to collect them here.

Ubuntu

To understand what's going on here, you need to understand a little background information about how shells (bash in this case) are run.

  • When you open a terminal emulator (gnome-terminal for example), you are executing what is known as an interactive, non-login shell.
  • When you log into your machine from the command line, via ssh, or run a command such as su username, you are running an interactive login shell.
View .gitconfig
[user]
name = MacMladen iMac
email = mladen@bluefish.rs
[color]
ui = on
[core]
excludesfile = /Users/mladen/.gitignore_global
whitespace= fix,-indent-with-non-tab,-indent-with-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore_global
[difftool "sourcetree"]
@macmladen
macmladen / .barracuda.cnf
Last active Dec 27, 2015
BOA full procedure for server upgrade
View .barracuda.cnf
###
### Configuration created on 151219-0247
###
_LOCAL_NETWORK_HN=""
_LOCAL_NETWORK_IP=""
_MY_FRONT="aegir.dx.rs"
_MY_HOSTN="dx.rs"
_MY_OWNIP="5.9.90.162"
_SMTP_RELAY_HOST=""
_SMTP_RELAY_TEST=YES