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])):
@fnkr
fnkr / imagemagick-print-width-height.sh
Last active May 12, 2016 09:21
Print width and height with ImageMagick's identify tool.
identify -format '%wx%h' image.png
@fnkr
fnkr / kirby-subdir.nginxconf
Created May 12, 2016 09:05
Nginx configuration for Kirby A) in domain's root directory (e.g. example.com) B) in subdirectory named /kirbycms/ (e.g. example.com/kirbycms/).
# e.g. for example.com/kirbycms/
location /kirbycms/ {
if (!-e $request_filename) {
rewrite ^/kirbycms/(.*)$ /kirbycms/index.php last;
break;
}
}
@fnkr
fnkr / gist:51f0a92b9f0c658287ec
Last active May 12, 2016 09:23
This code allows you to configure phpPgAdmion to automatically login to a particular server and database with a particular default password.
<?php
/*
Automatic Login
(c) 2008 Tim Wood
contact via: tmwood (at) datawranglers (dot) com
You are free to use this code as long as this notice is retained
Description
@fnkr
fnkr / random-string.sh
Last active March 31, 2017 08:00
Generate random, alphanumeric strings in Bash.
#!/bin/bash
RANDSTR="$(cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | head -c 40)"
@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;
@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'
@pixelbrackets
pixelbrackets / Fluid.html
Last active May 15, 2019 17:24
TYPO3 Neos Backend Conditions
<f:if condition="{node.context.workspace.name} == 'live'">
Only visible in live frontend
</f:if>
<f:security.ifAccess privilegeTarget="TYPO3.Neos:Backend.GeneralAccess">
<f:if condition="{node.context.workspace.name} != 'live'">
Only visible in backend workspace
</f:if>
</f:security.ifAccess>
@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 }
@esfand
esfand / nginxvarcore.md
Last active May 17, 2021 16:39
Nginx Variables

Embedded Variables

The ngx_http_core_module module supports embedded variables with names matching the Apache Server variables. First of all, these are variables representing client request header fields, such as $http_user_agent, $http_cookie, and so on. Also there are other variables:

  • $arg_name
    argument name in the request line