Skip to content

Instantly share code, notes, and snippets.

View vibbow's full-sized avatar
🏠
Working from home

vibbow

🏠
Working from home
View GitHub Profile
@vibbow
vibbow / tplink-ip.php
Created January 22, 2014 22:40
从TP-Link管理页面抓取外网IP的脚本
@vibbow
vibbow / php-mssql-backup.php
Created January 22, 2014 22:46
PHP MSSQL 备份脚本
<?php
define('MSSQL_HOST', '127.0.0.1');
define('MSSQL_USER', '[USERNAME]');
define('MSSQL_PASS', '[PASSWORD]');
define('BACKUP_TEMP_DIR', 'd:\\mssql_backup\\tmp\\');
define('BACKUP_DIR', 'd:\\mssql_backup\\');
$start_time = time();
@vibbow
vibbow / php-mysql-backup.php
Created January 22, 2014 22:47
PHP MYSQL 备份脚本
#!/usr/bin/php
<?php
define('MYSQL_HOST', 'localhost');
define('MYSQL_USERNAME', '[USERNAME]');
define('MYSQL_PASSWORD', '[PASSWORD]');
define('BACKUP_TEMP_DIR', '/tmp/mysql_backup/');
define('BACKUP_DIR', '/var/backup/');
$start_time = time();
@vibbow
vibbow / search.php
Created January 22, 2014 23:50
PHP 全文搜索脚本
<?php
define ('DB_SOURCE', 'd:\\data');
define ('CACHE_LIMIT', 4194304);
define ('RESULT_LIMIT', 1000);
define ('TIME_LIMIT', 600);
$begin = microtime(true);
set_time_limit(TIME_LIMIT + 100);
ob_end_flush();
@vibbow
vibbow / ntp-client.php
Created January 22, 2014 23:55
PHP通过NTP服务器获取时间脚本
#!/usr/bin/php -q
<?php
echo "PHP Time Protocol Client\n";
echo "-----------------\n";
/* NTP服务器列表 */
$ntp_server_list = array(
'0.hk.pool.ntp.org',
'0.asia.pool.ntp.org',
'1.asia.pool.ntp.org',
@vibbow
vibbow / uptime.php
Created January 23, 2014 00:01
优雅 (蛋疼) 的获取Linux开机时长
<?php
$uptime = file_get_contents('/proc/uptime'); // 1164820.24 4655047.46;
$upsecond = (int)explode(' ', $uptime)[0];
$datediff = date_diff(date_create(), date_create("{$upsecond} second ago"), true);
echo $datediff->y . "\r\n";
echo $datediff->m . "\r\n";
echo $datediff->d . "\r\n";
echo $datediff->h . "\r\n";
echo $datediff->i . "\r\n";
@vibbow
vibbow / AutoRT.php
Last active August 29, 2015 13:56
自动RT指定Twitter用户的所有Tweet。
<?php
set_time_limit(300);
mb_internal_encoding("UTF-8");
header('Content-Type: text/html; charset=utf-8');
define('APP_DIR', __DIR__ . DIRECTORY_SEPARATOR);
define('TWIP_URL', 'TWIP O 模式地址'); // TWIP O 模式地址,实在懒得去处理OAuth的东西了
define('TWITTER_ID', 'Twitter User ID'); // Twitter 用户的 ID,防止用户改名
define('ADD_STR', '#土豪 的日常 RT @[USERNAME] '); // 要附加在原始推文前的内容
@vibbow
vibbow / fix_permission.php
Created April 21, 2014 00:12
Ubuntu /var/www 目录权限修复脚本
<?php
$path = '/var/www';
`chown -R www-data:www-data {$path}`;
`chown root:root {$path}`;
mod_dir($path);
function mod_dir($path) {
$files = scandir($path);
@vibbow
vibbow / 2-waysms.php
Created April 23, 2014 18:49
2-WaySMS 调用脚本
<?php
define('SMS_NUMBER', '');
define('SMS_TOKEN', '');
define('SMS_API', 'http://www.2-waysms.com/my/api/sms.php');
$to = '';
$message = '';
$senderid = '';
echo sendsms($to, $message, $senderid);
@vibbow
vibbow / route_bat_generator.php
Created May 23, 2014 21:44
Windows 路由表添加脚本生成工具
<?php
/**
* Windows 路由添加脚本生成工具
* 由路由列表文件,生成Windows适用的路由添加脚本
* vibbow @ 2014/5/23
*
* 参考路由列表文件:
* http://www.dnspod.cn/misc/iplist.txt
* 可从中截取出要生成的运营商路由表