Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Fulei Li perfectfoolish

🎯
Focusing
View GitHub Profile
@perfectfoolish
perfectfoolish / command.txt
Created Jul 28, 2021
solve forget the root password of mysql installed by homebrew on macOS
View command.txt
$ brew services stop mysql
$ pkill mysqld
$ rm -rf /usr/local/var/mysql/ # NOTE: this will delete your existing database!!!
$ brew postinstall mysql
$ brew services restart mysql
$ mysql -uroot
View export-restore-kubernetes-mysql-database.txt
# Export dump particular database.
$ kubectl exec {{podName}} -n {{namespace}} -- mysqldump -u {{dbUser}} -p{{password}} {{DatabaseName}} > <scriptName>.sql
# Export dump all databases.
$ kubectl exec {{podName}} -n {{namespace}} -- mysqldump -u {{dbUser}} -p{{password}} --all-databases > <scriptName>.sql
# Restore a database from a dump.
$ kubectl exec -it {{podName}} -n {{namespace}} -- mysql -u {{dbUser}} -p{{password}} {{DatabaseName}} < <scriptName>.sql
@perfectfoolish
perfectfoolish / JdkSpecificVersion.groovy
Last active Sep 22, 2017
Use the env.JAVA_HOME environment variable to specify the JDK to use as shown in the Pipeline snippet below:
View JdkSpecificVersion.groovy
node {
// https://support.cloudbees.com/hc/en-us/articles/115001595227-How-To-Specify-A-Specific-JDK-In-Pipeline-
// configure the JDK in Manage Jenkins > Global Tool Configuration > JDK
jdk = tool name: 'JDK17'
env.JAVA_HOME = "${jdk}"
echo "jdk installation path is: ${jdk}"
// next 2 are equivalents
sh "${jdk}/bin/java -version"
@perfectfoolish
perfectfoolish / find-all-branches.groovy
Last active Sep 6, 2017
Install 'Extended Choice Parameter Plug-In', then selected 'Basic Parameter Types', input 'Number of Visible Items' with 100 and 'Delimiter' with ',', selected Groovy Script and input this script.
View find-all-branches.groovy
def gitURL = "git@github.com:xxxxx.git"
def command = "git ls-remote -h $gitURL"
def proc = command.execute()
proc.waitFor()
if ( proc.exitValue() != 0 ) {
return ["develop", "master"]
}
@perfectfoolish
perfectfoolish / autopgsqlbackup
Created Sep 23, 2016 — forked from matthewlehner/autopgsqlbackup
Auto PostgreSQL backup script.
View autopgsqlbackup
#!/bin/bash
#
# PostgreSQL Backup Script Ver 1.0
# http://autopgsqlbackup.frozenpc.net
# Copyright (c) 2005 Aaron Axelsen <axelseaa@amadmax.com>
#
# This script is based of the AutoMySQLBackup Script Ver 2.2
# It can be found at http://sourceforge.net/projects/automysqlbackup/
#
# The PostgreSQL changes are based on a patch agaisnt AutoMySQLBackup 1.9
View nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
View stop_server.sh
#!/bin/bash
isExistApp=`ps -ef|grep data-jar-with-dependencies.jar|grep -v grep|awk '{print $2}'`
if [[ -n $isExistApp ]]; then
kill -9 $isExistApp
echo 'app stopped'
fi
View stop_server.sh
#!/bin/bash
isExistApp = `pgrep httpd`
if [[ -n $isExistApp ]]; then
service httpd stop
fi
@perfectfoolish
perfectfoolish / gist:39c9fd8c15b41f787e82
Last active Aug 29, 2015 — forked from lucifr/gist:1208100
Sublime Text 2 - 实用快捷键 (Mac OS X)
View gist:39c9fd8c15b41f787e82
@perfectfoolish
perfectfoolish / gist:c28f04a973343b91fd50
Last active Aug 29, 2015 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts
View gist:c28f04a973343b91fd50

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt