Skip to content

Instantly share code, notes, and snippets.

View te-online's full-sized avatar

Thomas Ebert te-online

View GitHub Profile
@te-online
te-online / useSWRReactNavigation.ts
Last active November 25, 2020 15:33
Forces SWR to revalidate in react-native environment
/**
* Author: @nandorojo, adapted from https://github.com/vercel/swr/issues/417#issuecomment-721438386
* Forces SWR to revalidate when one of the following events occurs
* - React-Navigation event (focus)
* - Focus of the app through AppState is propagated
* - Networks access is restored
*/
import { responseInterface, ConfigInterface } from 'swr';
import { useRef, useEffect } from 'react';
import { AppState } from 'react-native';
@te-online
te-online / mailmove-simple.sh
Last active February 25, 2020 19:01
Massive Mail Move
#!/bin/bash
echo -n "Enter FROM hostname: "
read HOST1
echo -n "Enter FROM user: "
read USER1
echo -n "Enter FROM password: "
read -s PASS1
@te-online
te-online / DeleteButtonWithConfirmation.js
Last active December 17, 2020 17:15 — forked from adylevy/DeleteButtonWithConfirmation.js
react-admin delete button with confirmation
/*
Copyright (c) 2018 Ady Levy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
@te-online
te-online / node_perf.js
Created October 1, 2018 14:48
Node Performance measurement for laymen
const start = now();
// some task goes here
const end = now();
const time = (end-start).toFixed(4);
const currentList = process.env.PERFLIST;
const list = (currentList) ? JSON.parse(currentList) : [];
list.push(time);
process.env.PERFLIST = JSON.stringify(list);
@te-online
te-online / mongo.sh
Created April 13, 2018 06:48
Login to Mongo Shell on Uberspace
mongo admin --host localhost --port GENERATED_PORT --username GENERATED_USERNAME -p
@te-online
te-online / find-ami-id.sh
Created January 10, 2018 11:34
Find the AMI id of an old AMI with aws-cli
AMI_NAME="2017.09.c"
aws ec2 describe-images --filters "Name=name,Values=*$AMI_NAME*"
@te-online
te-online / wordpress-multisite-internal-redirect-loop.md
Created January 8, 2018 20:11 — forked from JustThomas/wordpress-multisite-internal-redirect-loop.md
WordPress Multisite: How to fix error "too many redirects"

WordPress Multisite: How to fix error "Request exceeded the limit of 10 internal redirects"

I am running a WordPress multisite network with sub-directory setup. When I check my error.log file, it is full of entries like this one:

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'Limit InternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

The problem was, in my case, one specific rewrite rule in the .htaccess file.

Problem description

@te-online
te-online / browser.eslintrc
Last active December 22, 2017 10:51
EsLint Config for Browser script.
{
"globals": {
// Free globals from errors here
"$": true
},
"env": {
"es6": false,
"node": false,
"browser": true
},
@te-online
te-online / JsPrettier.sublime-settings
Created December 22, 2017 10:50
SublimeText Prettier Config
{
"prettier_options": {
// If true, will use single instead of double quotes
"singleQuote": true,
"tabs": true
}
}
@te-online
te-online / checkCertificateValidity.py
Last active December 22, 2017 14:40
An AWS Lambda function to check if a given hostname (in the start event) still hold as valid tls certificate.
"""
Copyright 2016 Ryan Scott Brown <sb@ryansb.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and