Skip to content

Instantly share code, notes, and snippets.

View appleshan's full-sized avatar
🏠
Working from home

Programmer Alan appleshan

🏠
Working from home
View GitHub Profile
@appleshan
appleshan / here-emacs
Created April 16, 2022 09:29 — forked from twlz0ne/here-emacs
Launch emacs from emacs.d folder you placed anywhere.
#!/usr/bin/env bash
##
# Launch emacs from emacs.d folder you placed anywhere.
#
# @author gongqijian@gmail.com
# @date 2016-07-21
#
function usage {
cat<<EOF
@appleshan
appleshan / fix_database_to_utf8.py
Created April 6, 2022 11:51 — forked from miratcan/fix_database_to_utf8.py
Small python script that converts character sets to utf8 in all databases and tables. My solution for "Illegal mix of collations" errors. (http://stackoverflow.com/questions/3029321/how-to-solve-illegal-mix-of-collations-in-mysql)
from MySQLdb import connect
conn = connect(user="[USER]", passwd= "[PASSWORD]")
cur = conn.cursor()
cur.execute("show databases;")
dbs_to_update = filter(
lambda db: db not in ('information_schema', 'mysql', 'performance_schema'),
[dbname[0] for dbname in cur.fetchall()])
@appleshan
appleshan / my.cnf
Created October 13, 2021 05:24 — forked from Jamesits/my.cnf
A good /etc/mysql/my.cnf replacement which solves mysql/percona fail to start problem. Worked for me.
# https://www.digitalocean.com/community/questions/mysql-server-keeps-stopping-unexpectedly
# http://pastie.org/8665237
# Generated by Percona Configuration Wizard (http://tools.percona.com/) version REL5-20120208
[mysql]
# CLIENT #
port = 3306
socket = /var/run/mysqld/mysqld.sock
@appleshan
appleshan / docker-wrapper.sh
Created October 13, 2021 03:53 — forked from Jamesits/docker-wrapper.sh
Run Docker in 2021 - supports Docker & Podman in root or rootless mode.
#!/bin/bash
set -Eeuo pipefail
DOCKER_IMAGE="${DOCKER_IMAGE:-hello-world}"
DOCKER_FLAGS="${DOCKER_FLAGS:-}"
function __docker() {
if command -v docker >/dev/null; then
docker "$@"
elif command -v podman >/dev/null; then
podman "$@"
@appleshan
appleshan / docker_cleanup.sh
Created October 13, 2021 03:46 — forked from Jamesits/docker_cleanup.sh
Docker cleanup unused things
#!/usr/bin/env bash
# USE WITH CAUTION
# remove all exited containers
docker rm $(docker ps -a -f status=exited -f status=created -q)
# remove dangling volumes
docker volume rm $(docker volume ls -f dangling=true -q)
@appleshan
appleshan / ubuntu_enable_bbr.sh
Created October 13, 2021 03:46 — forked from Jamesits/ubuntu_enable_bbr.sh
Ubuntu enable BBR
#!/bin/bash
set -eu
SYSCTL_FILE=/etc/sysctl.d/90-tcp-bbr.conf
# check root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
function addEvent(element, event, callback) {
if (element.addEventListener) {
element.addEventListener(event, callback, false)
} else if (element.attachEvent) {
element.attachEvent('on' + event, callback);
} else {
element['on' + event] = callback;
}
}
@appleshan
appleshan / gist:4a113af51185a7c5000673ecd9964bfe
Created August 24, 2021 13:43 — forked from zhasm/gist:4038348
Emacs Command Summary

Emacs Command Summary

Emacs command summary, Thu Jul 25. link

Key
Key Cmd
@appleshan
appleshan / invalid_or_corrupted_package.md
Created June 14, 2021 13:00 — forked from joseluisq/invalid_or_corrupted_package.md
How To Fix “invalid or corrupted package (PGP signature)” Error In Arch Linux
@appleshan
appleshan / conda-env-autodetect.plugin.zsh
Created June 2, 2018 02:05 — forked from floringogianu/conda-env-autodetect.plugin.zsh
zsh plugin for autodetecting conda environments based on a .venv file in your project
# conda-env-autodetect.plugin.zsh
# Copy this file to ~/.oh-my-zsh/plugins/conda-env-autodetect/
# And make sure you have a .venv file with your env's name in your
# preject's root folder.
_conda_env_auto_activate() {
if [ -f ".venv" ]; then
# check conda is active