Skip to content

Instantly share code, notes, and snippets.

@shiny
shiny / js
Created November 18, 2016 14:05
还我右键
javascript:(function() { function R(a){ona = "on"+a; if(window.addEventListener) window.addEventListener(a, function (e) { for(var n=e.originalTarget; n; n=n.parentNode) n[ona]=null; }, true); window[ona]=null; document[ona]=null; if(document.body) document.body[ona]=null; } R("contextmenu"); R("click"); R("mousedown"); R("mouseup"); R("selectstart");})()
@shiny
shiny / .htaccess
Created January 8, 2016 12:52
禁止阿里云云盾扫描
deny from 42.120.142.220/30
deny from 42.120.145.0/24
deny from 42.156.250.110/31
deny from 42.156.250.112/29
deny from 120.26.55.211/32
deny from 121.40.83.80/32
deny from 121.42.0.0/24
#https://help.aliyun.com/knowledge_detail/5975223.html
@shiny
shiny / example.php
Created March 26, 2015 11:48
example.php
<?php
function createStr($num = 700, $len = 6){
if($num===0){
return [];
}
$numbers = range(0, 9);
$letters = range('a', 'z');
$uppers = range('A', 'Z');
$elements = array_merge($numbers, $letters, $uppers);
$strings = [];
@shiny
shiny / upyun_form_upload.php
Last active August 29, 2015 14:10
upyun_form_upload
<?php
class upyun_form_upload {
private $policy = [];
private $secret_key;
function __construct($secret_key){
$this->secret_key = $secret_key;
}
function __call($function_name, $params){
$key = $this->underscore2hyphen($function_name);
if (!empty($params)) {
var proxy = "SOCKS5 127.0.0.1:1081; SOCKS 127.0.0.1:1081; DIRECT;";
var direct = 'DIRECT;';
var domains = [
'twitter.com',
'google.com',
'google.com.hk',
't.co',
'twimg.com',
'github.com',
@shiny
shiny / syncdb.sh
Last active January 2, 2016 06:48
一键从局域网的 mylvmbackup 备份恢复数据库 适用环境: 开发机:Mac,数据库通过 dmg 镜像安装。 备份:任意*nix、支持ssh 的主机。 否则需要稍作修改。
#一键从备份恢复数据
HOST=192.168.1.158 #主机地址,最好写好证书
BACKUP_DIR=/data/autobackup/mysql #远程备份文件夹地址
DB=jjdd #数据库名
MYSQL_DATA_DIR=/usr/local/mysql/data/ #本机数据库 datadir
MYSQL_USER=_mysql:_mysql #mysql 的用户
#start...
sudo echo '已获得 root 权限'
if [ $? -ne 0 ] ; then
@shiny
shiny / smtp.coffee
Created September 15, 2013 06:42
send email via smtp
nodemailer = require "nodemailer"
transportOptions =
service: "QQ"
auth:
user: "[email protected]"
pass: "password"
mailOptions =
from: "[email protected]",
to: "[email protected]",
@shiny
shiny / mailgun.coffee
Created September 15, 2013 04:58
send mail from mailgun. # how to use 1. npm install request 2. change: your mailgun api key; change your domain in request url
request = require 'request'
form =
from: 'shiguanglu <[email protected]>'
to: 'testuser <[email protected]>'
subject: 'this is a test mail'
text: 'test mail body'
auth =
user: 'api'
password: 'YOUR API KEY FROM MAILGUN'
@shiny
shiny / gist:6410663
Created September 2, 2013 08:45
Sign签名

test.php

<?php
$priKey = file_get_contents('./id_rsa');
$res = openssl_get_privatekey($priKey);
$orderString = 'some string';
openssl_sign($orderString, $sign, $res);
//$sign为引用
openssl_free_key($res);
$sign = base64_encode($sign);

echo $sign;

@shiny
shiny / 短网址互转.php
Created July 28, 2013 05:24
短网址代码和数字的互转
<?php
/**
* 将数字转为短网址代码
*
* @param int $number 数字
* @return string 短网址代码
*/
function generate_code($number) {
$out = "";
$codes = "abcdefghjkmnpqrstuvwxyz23456789ABCDEFGHJKMNPQRSTUVWXYZ";