Skip to content

Instantly share code, notes, and snippets.

@mindevolution
mindevolution / drop_db_multiple
Last active March 16, 2021 02:33
Mysql drop multiple database
#!/bin/bash
MUSER='root' # db username
MPASS='root' # db password
# db array to be deleted
declare -a DROP_DBS=(knowpath mydb xhprof )
# loop dbs and delete db
DBS=`(mysql -u$MUSER -p$MPASS -Bse 'SHOW DATABASES')`
@mindevolution
mindevolution / gist:5a0fedf661203f4831d8
Created April 23, 2015 08:05
Monitor http request
tcpdump -s 0 -A 'tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x47455420'
http://unix.stackexchange.com/questions/19485/how-to-monitor-incoming-http-requests
@mindevolution
mindevolution / update_discuz_index
Last active August 29, 2015 14:21
bash update discuz portal index
#!/bin/bash
# first back up the database
now=$(date +"%Y-%m-%d_%H:%M")
select_mode()
{
echo "Select the running mode:
1. Local Server
2. Production Server
@mindevolution
mindevolution / DatabaseDriver.php
Last active October 10, 2016 03:07
Solve symfony2.7 command php app/console doctrine:mapping:import --force AppBundle yaml Doctrine does not support reverse engineering from tables that don't have a primary key
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
@mindevolution
mindevolution / ssh-export-mysql.sh
Last active June 22, 2017 08:28
Ssh export database to local machine
#!/bin/sh
### System Setup ###
NOW=`date +%Y-%m-%d`
KEEPDAYS=5
#
### SSH Info ###
SHOST="" # XXXX is mt gs number
SUSER="" # mt_domain is primary mt domain
SDIR="/home/hezhl/data/tmp" # Remote temp save path
PORT=22
@mindevolution
mindevolution / mysql-no-strict.sql
Created June 22, 2017 09:29
Update mysql5.7 no strict mode
SET SESSION sql_mode= 'ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
@mindevolution
mindevolution / wp-user-op.php
Created September 18, 2017 03:54
wordpress reset admin password - wordpress重置admin账号
<?php
define('DB_HOST', 'localhost');
define('DB_USER', 'nshore_admin');
define('DB_PASS', 'w00d$ide');
define('DB_NAME', 'npclients_wp');
/**
* 数据库操作类
*/
@mindevolution
mindevolution / git-unchanged.sh
Created September 27, 2017 04:17
git set assume unchanged by directory
git ls-files -z | xargs -0 git update-index --assume-unchanged
@mindevolution
mindevolution / php-db-test.php
Last active June 6, 2018 06:38
Test php mysql db connection
<?php
$servername = '127.0.0.1';
$username = 'dbuser';
$password = 'dbpassword';
$dbname = 'dbname';
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
@mindevolution
mindevolution / gist:d4ccd893e0ea3e64911431fee597eedb
Created July 27, 2018 02:28 — forked from jordelver/gist:3073101
Set the Mac OS X SOCKS proxy on the command line

Set the Mac OS X SOCKS proxy on the command line

a.k.a. what to do when your ISP starts blocking sites :(

Set the SOCKS proxy to local SSH tunnel

networksetup -setsocksfirewallproxy "Ethernet" localhost 8080

To clear the domain and port