Skip to content

Instantly share code, notes, and snippets.

View test-mysql-connection.php
<?php
$link = mysql_connect('localhost', 'user', 'password');
if (!$link) {
echo "Fail!<br>" . mysql_error();
} else {
echo "Succ!<br>";
}
mysql_close();
@srxr
srxr / straceall.sh
Created Aug 31, 2017
using strace on multiple processes in Linux
View straceall.sh
function straceall {
strace $(pidof "${1}" | sed 's/\([0-9]*\)/-p \1/g')
}
View get-the-size-of-table-in-mysql.sh
# all database
SELECT
TABLE_SCHEMA AS `Database`,
TABLE_NAME AS `Table`,
ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Size (MB)`
FROM
information_schema.TABLES
ORDER BY
(DATA_LENGTH + INDEX_LENGTH)
DESC;
View function_reload.js
function addMethod(object, name, f) {  
var old = object[name];  
object[name] = function() {
// f.length为函数定义时的参数个数
// arguments.length为函数调用时的参数个数    
if (f.length === arguments.length) {  
return f.apply(this, arguments);    
} else if (typeof old === "function") {
return old.apply(this, arguments);    
}  
View lede-pppoe-config
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config interface 'lan'
option ifname 'eth0.1'
option type 'bridge'
option proto 'static'
View javascript-timer.js
var timers = {
timerID: 0,
timers: [],
add: function(fn) {
this.timers.push(fn);
},
start: function() {
if (this.timerID) return;
(function runNext() {
if (timers.timers.length > 0) {
@srxr
srxr / update-git-committed.md
Last active Sep 20, 2017
batch update git committed log
View update-git-committed.md
git filter-branch --env-filter '
WRONG_EMAIL="wrong@example.com"
NEW_NAME="New Name Value"
NEW_EMAIL="correct@example.com"

if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
    export GIT_COMMITTER_NAME="$NEW_NAME"
    export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
View date_loop.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import datetime
date = datetime.date(2016, 1, 1)
dateend = datetime.date(2017, 1, 4)
dateend_int = dateend.strftime('%Y%m%d')
while date:
@srxr
srxr / hover.css
Created Jun 16, 2016
CSS-When-Mouse-Hover-Show-St
View hover.css
<style type="text/css">
table tr td span { opacity:0; float:right }
table tr:hover span { opacity:1 }
</style>
@srxr
srxr / MySQL PRIVILEGES.md
Last active May 20, 2017
MySQL PRIVILEGES
View MySQL PRIVILEGES.md
select distinct concat('user:',user,'@',host,':') as query from mysql.user;
You can’t perform that action at this time.