Skip to content

Instantly share code, notes, and snippets.

View fnkr's full-sized avatar
🐧
cat /dev/urandom | aplay -c 2 -r 24000

Florian Kaiser fnkr

🐧
cat /dev/urandom | aplay -c 2 -r 24000
View GitHub Profile
@fnkr
fnkr / ascii_table.py
Created May 12, 2016 09:08
ASCII Tables with Python 3
# Python 3
def pprinttable(rows):
if len(rows) > 1:
headers = rows[0]._fields
lens = []
for i in range(len(rows[0])):
lens.append(len(max([x[i] for x in rows] + [headers[i]],key=lambda x:len(str(x)))))
formats = []
hformats = []
for i in range(len(rows[0])):
@alces
alces / ansible_local_playbooks.md
Last active May 20, 2024 14:57
How to run an Ansible playbook locally
  • using Ansible command line:
ansible-playbook --connection=local 127.0.0.1 playbook.yml
  • using inventory:
127.0.0.1 ansible_connection=local
@alok-mishra
alok-mishra / trakt-remove-all-from-collection.js
Last active May 6, 2024 04:51
Remove all items from Trakt collection
// Removes all items from a page of the Trakt collection
// Run script from console of user's collection page
// Must be run on each page
$(".posters .grid-item").each(function() {
actionWatch($(this).closest('.grid-item'), 'collect', true)
})
@mapmeld
mapmeld / OverEncrypt.md
Last active July 25, 2023 18:55
OverEncrypt - paranoid HTTPS

OverEncrypt

This is a guide that I wrote to improve the default security of my website https://fortran.io , which has a certificate from LetsEncrypt. I'm choosing to improve HTTPS security and transparency without consideration for legacy browser support.

WARNING: if you mess up settings, lose your certificates, or decide to no longer maintain HTTPS certs, these steps can and will make your domain inaccessible.

I would recommend these steps only if you have a specific need for information security, privacy, and trust with your users, and/or maintain a separate secure.example.com domain which won't mess up your main site. If you've been thinking about hosting a site on Tor, then this might be a good option, too.

The best resources that I've found for explaining these steps are https://https.cio.gov , https://certificate-transparency.org , and https://twitter.com/konklone

@halberom
halberom / 00_play.yml
Last active September 6, 2022 08:03
ansible - example of parsing a url
---
- hosts: localhost
gather_facts: False
connection: local
vars:
myvar: 'http://www.example.domain.com:9090'
tasks:
- name: not as good as a custom filter
debug:
@valeriomazzeo
valeriomazzeo / github_release.rb
Created July 5, 2017 21:24
Creates or update a GitHub release for the given tag name
#!/usr/bin/env ruby
require 'optparse'
require 'octokit'
options = {}
OptionParser.new do |opt|
opt.on('-s', '--secret SECRET', 'GitHub access token') { |o| options[:secret] = o }
opt.on('-r', '--repo-slug REPO_SLUG', 'Repo slug. i.e.: apple/swift') { |o| options[:repo_slug] = o }
opt.on('-c', '--changelog-file CHANGELOG_FILE', 'Changelog path') { |o| options[:changelog_file] = o }
@fnkr
fnkr / simple_mysql_backup.sh
Last active May 30, 2018 06:45
MySQL/MariaDB server backup in 147 chars
echo 'show databases;' | sudo mysql | tail -n+2 | grep -v _schema$ | grep -v ^mysql$ | xargs -n 1 -I _ bash -c 'sudo mysqldump _ | gzip > _.sql.gz'
@fnkr
fnkr / mysql-db-stats.sql
Created February 20, 2018 09:44
Human readable overview of MySQL/MariaDB database size
SELECT table_schema "Database",
Round(Sum(data_length) / 1024 / 1024, 0) "Data size (in MB)",
Round(Sum(data_length) / 1024 / 1024 / 1024, 3) "Data size (in GB)",
Round(Sum(index_length) / 1024 / 1024, 0) "Index size (in MB)",
Round(Sum(index_length) / 1024 / 1024 / 1024, 3) "Index size (in GB)",
Round(Sum(data_length + index_length) / 1024 / 1024, 0) "Total size (in MB)",
Round(Sum(data_length + index_length) / 1024 / 1024 / 1024, 3) "Total size (in GB)"
FROM information_schema.tables
GROUP BY table_schema;
@Ryanb58
Ryanb58 / install.md
Last active May 17, 2024 13:42
How to install telnet into a alpine docker container. This is useful when using the celery remote debugger in a dev environment.
>>> docker exec -it CONTAINERID /bin/sh
/app # telnet
/bin/sh: telnet: not found

/app # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
v3.7.0-243-gf26e75a186 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]
v3.7.0-229-g087f28e29d [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]
@zealot128
zealot128 / README.md
Last active January 6, 2023 20:08
Gitlab Autoscaling Infrastructure on Hcloud with internal caching

Order and provision a Hetzner Cloud based Gitlab-Runner Docker-machine autoscaling infrastructure

See my blog for more information.

  • Adjust settings in vars.auto.tfvars.
  • Run with terraform init && terraform apply

Content: