Skip to content

Instantly share code, notes, and snippets.

Avatar

Michal Zuber mikaelz

View GitHub Profile
View hungarian-question-words-regex
(hol|hova|honnan|merre|mettol|meddig|mennyi|hany|hanyfele|mekkora|mifele|melyik|milyen|mikent|miert|hogyan|mikor|mikortol|mikent|mennyi|honnan|miota)
@mikaelz
mikaelz / slovak-question-words
Created Jul 18, 2021
Slovak question words regex for Google Search Console query filter. Based on https://twitter.com/DataChaz/status/1416330157749583872
View slovak-question-words
(?i)^(ako|aka|ake|kde|kam|kedy|co|naco|preco|koho|odkial|kto|ktory|ktora|ktore)[" "]
@mikaelz
mikaelz / librenms-alerts.service
Last active Oct 30, 2020
librenms systemd timers as crontab repalcement
View librenms-alerts.service
# /etc/systemd/system/librenms-alerts.service
[Unit]
Description=Run librenms poller
[Service]
Type=oneshot
ExecStart=/opt/librenms/alerts.php
User=librenms
@mikaelz
mikaelz / wc-delete-old-shop-orders.sql
Created Oct 14, 2020
Delete old (not current year) WooCommerce shop orders
View wc-delete-old-shop-orders.sql
DELETE
FROM wp_postmeta
WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'shop_order' AND YEAR(post_date) != YEAR(NOW()));
DELETE
FROM wp_commentmeta
WHERE comment_id IN (SELECT comment_ID
FROM wp_comments
WHERE comment_post_id IN
(SELECT ID FROM wp_posts WHERE post_type = 'shop_order' AND YEAR(post_date) != YEAR(NOW()))
@mikaelz
mikaelz / rc.lua
Created May 5, 2020
AwesomeWM spawn terminal on focused screen and tag
View rc.lua
awesome-client 'awful=require("awful");awful.spawn(terminal, {tag = mouse.screen.selected_tag})'
View mosaic-live-stream.sh
ffmpeg -rtsp_transport tcp \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/101 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/201 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/301 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/401 \
-filter_complex "
nullsrc=size=1920x1080 [base];
[0:v] setpts=PTS-STARTPTS, scale=960x540 [upperleft];
[1:v] setpts=PTS-STARTPTS, scale=960x540 [upperright];
[2:v] setpts=PTS-STARTPTS, scale=960x540 [lowerleft];
@mikaelz
mikaelz / ttm-dividend-yield.js
Created May 3, 2020
Google Spreadsheet script to fetch Dividend Yield from https://fmpcloud.io/plans
View ttm-dividend-yield.js
function DivYieldTtm(ticker) {
var ticker = ticker || "GOOG";
ticker = encodeURI(ticker);
var response = UrlFetchApp.fetch("https://fmpcloud.io/api/v3/ratios-ttm/" + ticker + "?apikey=YOUR_API_KEY");
var result = JSON.parse(response.getContentText());
return parseFloat(result[0].dividendYielTTM);
}
@mikaelz
mikaelz / YahooFinance.js
Created Apr 20, 2020
Google script to fetch stock quote data from Yahoo Finance
View YahooFinance.js
function YahooFinance(ticker) {
var ticker = ticker || "GOOG";
ticker = encodeURI(ticker);
var response = UrlFetchApp.fetch("https://query2.finance.yahoo.com/v7/finance/options/" + ticker);
var chain = JSON.parse(response.getContentText());
return parseFloat(chain.optionChain.result[0].quote.regularMarketPrice);
}
View ssh-login-notify.sh
$ cat /etc/profile.d/ssh-login-notify.sh
if [ -n "$SSH_CLIENT" ]; then
TEXT="$(date): ssh login to ${USER}@$(hostnamectl --static)"
TEXT="$TEXT from $(echo $SSH_CLIENT|awk '{print $1}')"
echo $TEXT|mail -s "ssh login" info@example.com
fi
@mikaelz
mikaelz / order-by-field.sql
Created Jul 20, 2019
Custom WP query ORDER BY with FIELD()
View order-by-field.sql
function pn_woocommerce_product_query( WP_Query $wp_query ) {
if ( $wp_query->get( 'orderby' ) == 'menu_order title' ) {
$wp_query->set( 'meta_query', [
'relation' => 'AND',
'internal_stock' => [
'key' => '_manage_stock',
'compare' => 'EXIST',
],
'stock_status' => [
'key' => '_stock_status',