Skip to content

Instantly share code, notes, and snippets.

View yonzin's full-sized avatar

Frédérick Perrin yonzin

View GitHub Profile
@yonzin
yonzin / gist:f9a9a26dc096dfd77ab925c3f63ace9e
Created May 13, 2016 15:26 — forked from PerpetualBeta/gist:6653157
Bash script header to elevate a script that needs to run as "root" if it is run without sudo. Background here: http://darkblue.sdf.org/weblog/post/got-root
# /bin/sh
if [ "$(whoami)" != 'root' ]; then
echo 'This script must be run as "root".'
echo 'Enter password to elevate privileges:'
SCRIPTPATH=$( cd $(dirname $0) ; pwd -P )
SELF=`basename $0`
sudo $SCRIPTPATH'/'$SELF
exit 1
fi
@yonzin
yonzin / app.module.ts
Last active August 30, 2019 13:54
auth0/angular2-jwt ionic and capacitor storage configuration
import { JwtModule, JWT_OPTIONS } from '@auth0/angular-jwt';
import { Plugins } from '@capacitor/core';
// ...
export function jwtOptionsFactory() {
return {
tokenGetter: () => {
return Plugins.Storage.get({ key: 'jwt_token' }).then(storedData => storedData.value);
},
@yonzin
yonzin / docker_mysql.md
Last active September 29, 2020 14:56
docker mysql dump / restore

Mysql import

docker exec -i [container_name] mysql -u[mysql_user] -p[mysql_password] < [dump_name].sql

Mysql dump

docker exec -i [container_name] mysqldump -u[mysql_user] -p[mysql_password] [DB_name] > [dump_name].sql
## useful git aliases
git config --global alias.st 'status -sb'
git config --global alias.ll 'log --oneline'
git config --global alias.last 'log -1 HEAD --stat'
git config --global alias.cm 'commit -m'
git config --global alias.rv 'remote -v'
git config --global alias.d 'diff'
git config --global alias.gl 'config --global -l'
git config --global alias.br 'branch'

useful git aliases

git config --global alias.st 'status -sb'
git config --global alias.ll 'log --oneline'
git config --global alias.last 'log -1 HEAD --stat'
git config --global alias.cm 'commit -m'
git config --global alias.rv 'remote -v'
git config --global alias.d 'diff'
git config --global alias.gl 'config --global -l'
git config --global alias.br 'branch'
SET @oldsite='http://oldsite.com';
SET @newsite='http://newsite.com';
UPDATE wp_options SET option_value = replace(option_value, @oldsite, @newsite) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, @oldsite, @newsite);
UPDATE wp_links SET link_url = replace(link_url, @oldsite, @newsite);
UPDATE wp_postmeta SET meta_value = replace(meta_value, @oldsite, @newsite);
/* only uncomment next line if you want all your current posts to post to RSS again as new */
#UPDATE wp_posts SET guid = replace(guid, @oldsite, @newsite);
@yonzin
yonzin / git-rebase-onto.sh
Last active June 27, 2024 13:06
git rebase onto
git rebase $1~ --onto $2;
$1 = first commit branch
$2 = rebased branch
ex: git rebase 118689f~ --onto origin/main