Skip to content

Instantly share code, notes, and snippets.

View perfectfoolish's full-sized avatar
🎯
Focusing

Fulei Li perfectfoolish

🎯
Focusing
View GitHub Profile
@perfectfoolish
perfectfoolish / command.txt
Created July 28, 2021 08:57
solve forget the root password of mysql installed by homebrew on macOS
$ 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
# 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 September 22, 2017 06:19
Use the env.JAVA_HOME environment variable to specify the JDK to use as shown in the Pipeline snippet below:
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 September 6, 2017 10:41
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.
def gitURL = "[email protected]: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 September 23, 2016 08:49 — forked from matthewlehner/autopgsqlbackup
Auto PostgreSQL backup script.
#!/bin/bash
#
# PostgreSQL Backup Script Ver 1.0
# http://autopgsqlbackup.frozenpc.net
# Copyright (c) 2005 Aaron Axelsen <[email protected]>
#
# 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
@perfectfoolish
perfectfoolish / nginx.conf
Created May 17, 2016 07:10
For react SPA
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
#!/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
#!/bin/bash
isExistApp = `pgrep httpd`
if [[ -n $isExistApp ]]; then
service httpd stop
fi
@perfectfoolish
perfectfoolish / gist:39c9fd8c15b41f787e82
Last active August 29, 2015 14:27 — forked from lucifr/gist:1208100
Sublime Text 2 - 实用快捷键 (Mac OS X)
@perfectfoolish
perfectfoolish / gist:c28f04a973343b91fd50
Last active August 29, 2015 14:27 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

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