This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT table_name AS "Table", | |
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)" | |
FROM information_schema.TABLES | |
ORDER BY (data_length + index_length) DESC; | |
SELECT table_schema AS "Database", | |
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)" | |
FROM information_schema.TABLES | |
GROUP BY table_schema; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is to get a list of IP's, banned by fail2ban on a remote machine. | |
# | |
# It connects via SSH, so sqlite3 won't need to be exposed. | |
# | |
# Authentication is handled by the local machine, so in this case a keyfile is used. | |
# | |
# In addition the user has been granted NOPASSWD in the /etc/sudoers file. Below is an example | |
# username ALL=(ALL:ALL) NOPASSWD:ALL | |
# This allows the user to use sudo, without having to submit a password. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the paho-mqtt library using pip: "pip3 install paho-mqtt" | |
import paho.mqtt.publish as publish | |
def mqttpublish(topic="paho/test/multiple", payload="multiple 2"): | |
msgs = [(topic, payload, 0, False)] | |
publish.multiple(msgs, hostname="broker.hivemq.com") | |
mqttpublish("paho/test/multiple", "TEST01") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# "is" vs "==" | |
a = [1, 2, 3] | |
b = a | |
a is b | |
# True | |
a == b | |
# True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
# Timing according to http://www.nu-ware.com/NuCode%20Help/index.html?morse_code_structure_and_timing_.htm | |
# Also, use python3 for this... and in general... please, for fuck's sake! | |
import numpy | |
import pyaudio | |
import math | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const readline = require('readline'); | |
const {google} = require('googleapis'); | |
const SCOPES = ['https://www.googleapis.com/auth/calendar.readonly']; | |
const TOKEN_PATH = 'token.json'; | |
fs.readFile('credentials.json', (err, content) => { | |
if (err) return console.log('Error loading client secret file:', err); | |
authorize(JSON.parse(content), listEvents); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request | |
import urllib.parse | |
import ast | |
import codecs | |
url = "http://www.swissgrid.ch/mvc.do/applicationFrequencyTimeAjax?tooltipText=+Live+data+(updated+every+30+seconds%2c+capacity+data+delayed+by+20+minutes)&deviationText=Current+grid+time+deviation&frequencyText=Current+frequency&_charset_=UTF-8" | |
enc = codecs.encode(str.encode(url), "hex") | |
print(enc) | |
dec = str(codecs.decode(enc, "hex"))[2:-1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This is almost a copy of "About Dis Mac" by mjk. I just made minor changes to make it work with the current beta 3 of OS X 10.14.1. | |
# Unfortunately i cannot find the original source of this wonderfull collection of functions. But it deserves to be preserved. | |
function write_header () { | |
local h="$@" | |
printf "%s\n" "####################" | |
printf "%s\n" "${h}" | |
printf "%s\n" "####################" |
NewerOlder