Skip to content

Instantly share code, notes, and snippets.

@teawithfruit
teawithfruit / fritzbox_port.md
Last active January 10, 2022 14:15
Synology Task / AVM Fritzbox port mapping / Let's Encrypt renew

Put the fritzbox_port.sh file somewhere to your Synology system. Create a custom task entry in your Synology system options with the following code. Update the PATH_TO_SCRIPT part and run the task as root.

bash /volume1/PATH_TO_SCRIPT/fritzbox_port.sh 1
/usr/syno/sbin/syno-letsencrypt renew-all -v
bash /volume1/PATH_TO_SCRIPT/fritzbox_port.sh 0
@teawithfruit
teawithfruit / migrate.js
Created December 15, 2021 13:58
Migrate accounts with pbkdf2 passwords from MySQL to Keycloak
const mysql = require('mysql')
const { curly } = require('node-libcurl');
const querystring = require('querystring');
const host = 'URL_TO_KEYCLOAK'
const realm = 'REALM_NAME'
async function migrate() {
var connection = mysql.createConnection({
host: 'HOST', // Insert your database host.
@teawithfruit
teawithfruit / console.js
Created January 28, 2020 14:12
A function for hijacking the console
captureConsole() {
let console = window.console
if(!console) return
function intercept(method) {
let original = console[method]
console[method] = function() {
if(original.apply) {
// do something with arguments
@teawithfruit
teawithfruit / README.md
Last active October 11, 2019 11:08
MySQL backup script with deletion of old files

To backup all databases in one file.

./mysql_backup.sh

To back up a particular database to a directory named the database.

./mysql_backup.sh DB_NAME
@teawithfruit
teawithfruit / MKMapView+FitAnnotaion.swift
Last active May 10, 2019 10:01
Extension to fit annotaion with a given location
extension MKMapView {
func fitMapViewToAnnotaion(withEdgePadding edgePadding:UIEdgeInsets = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20), andLocation givenLocation:CLLocationCoordinate2D?) -> Void {
var zoomRect:MKMapRect = MKMapRect.null
for annotation in annotations {
let aPoint:MKMapPoint = MKMapPoint(annotation.coordinate)
let rect:MKMapRect = MKMapRect(x: aPoint.x, y: aPoint.y, width: 0.1, height: 0.1)
if zoomRect.isNull {
zoomRect = rect
@teawithfruit
teawithfruit / ViewController.swift
Created April 17, 2017 11:19
if available – UIRefreshControl
import Foundation
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: #selector(refresh), for: .valueChanged)
@teawithfruit
teawithfruit / README.md
Created March 10, 2016 12:02
Nginx redirect

#Nginx Redirect Template This config will redirect a given request from "http://IP:PORT/THE/PATH/" to a choosen webservice. To get it work, you only have to edit "/THE/PATH/" and "IP:PORT".

@teawithfruit
teawithfruit / backup.sh
Last active November 16, 2015 12:36
Create a backup from your MySQL database and a given directory.
#!/bin/bash
### This directory will be zipped and pushed to the ftp server.
LOCAL_BACKUP="/srv/www"
### MySQL credentials
MYSQL_USER="root"
MYSQL_PASS="password"
### FTP credentials
@teawithfruit
teawithfruit / tidy5-install-ubuntu.sh
Last active February 22, 2016 20:40
Install tidy5 on Ubuntu.
#!/bin/bash
# Check if user is root
if [ $(id -u) != "0" ]; then
echo "Error: You must be root to run this script, please use root to install the software."
exit 1
fi
apt-get remove libtidy-0.99-0 tidy -y
wget -O /tmp/tidy-5.0.0-64bit.deb http://www.htacg.org/binaries/binaries/tidy-5.0.0.RC1/tidy-5.0.0-64bit.deb
@teawithfruit
teawithfruit / tidy5.rb
Last active August 29, 2015 14:24
Tidy5 script for Homebrew
class TidyHtml5 < Formula
desc ""
homepage ""
url "https://github.com/htacg/tidy-html5/archive/5.0.0.RC1.tar.gz"
version "1"
sha256 "3b1f51ec0d445af99f9c36c46a621b6374a3ea22866d29375e3af5d8d0e960b2"
depends_on "cmake" => :build
def install