Skip to content

Instantly share code, notes, and snippets.

View qianlongzt's full-sized avatar

Fei Yang qianlongzt

  • 07:21 (UTC +08:00)
View GitHub Profile
@qianlongzt
qianlongzt / limitRquestRate.php
Created November 13, 2016 06:40
php 通过redis限制速度
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$time = $_SERVER['REQUEST_TIME'];
$maxPerSecond = 10;
try {
$redis = new Redis();
$redis -> connect('127.0.0.1', 6379, 20);
$redis -> lpush($ip, $time);
if(
($redis -> llen ($ip) >= $maxPerSecond) && ($redis -> lrange($ip, $maxPerSecond - 1, $maxPerSecond - 1))[0] + 1 >= $time
@qianlongzt
qianlongzt / client.go
Created June 26, 2017 08:13
socket 编程
package main
import (
"io"
"log"
"net"
"time"
)
func reader(r io.Reader) {
@qianlongzt
qianlongzt / wechat_oauth.php
Created August 19, 2017 14:39
微信 Oauth 回调域名和使用域名不一样的使用。
<?php
$appid = APPID;
$appkey = APPKEY;
$redirect_url = urlencode(REDIRECT_URL);//可以为跳板url,然后跳板url跳到这里来。域名可以不一样。
$scope = "snsapi_userinfo";//snsapi_userinfo //这个可以不用关注;
$state = "";
if(isset($_GET['code'])) {
$code = $_GET['code'];
$api_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$appid}&secret={$appkey}&code={$code}&grant_type=authorization_code";
$data_str = get($api_url);
@qianlongzt
qianlongzt / HDUportalLogin.py
Last active October 18, 2017 12:35
杭电 WiFI Portal登录
### curl 'http://2.2.2.2/ac_portal/login.php' --data 'opr=logout'
### curl 'http://2.2.2.2/ac_portal/login.php' --data 'opr=pwdLogin&userName={stuid}&pwd={stupwd}&rememberPwd=0'
import urllib.request
import urllib.parse
import json
import sys
@qianlongzt
qianlongzt / getTota.js
Created October 13, 2017 01:34
get the number of your country ip addrs from http://www.nirsoft.net/countryip/cn.html
doc = document.getElementsByTagName("table")[6].children[0];
total = 0
for(i = 1;i< doc.children.length; i++) {
total += parseInt(doc.children[i].children[2].innerText)
}
alert(total)
2018/01/14 20:09:41 [D] Session ID: <hidden>
2018/01/14 20:09:41 [D] CSRF Token: <hidden>
2018/01/14 20:09:42 [D] Template: user/dashboard/dashboard
==> xorm.log <==
2018/01/14 20:09:41 [I] [SQL] SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `keep_email_private`, `passwd`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `created_unix`, `updated_unix`, `last_login_unix`, `last_repo_visibility`, `max_repo_creation`, `is_active`, `is_admin`, `allow_git_hook`, `allow_import_local`, `allow_create_organization`, `prohibit_login`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_following`, `num_stars`, `num_repos`, `description`, `num_teams`, `num_members`, `diff_view_style` FROM `user` WHERE `id`=? LIMIT 1 []interface {}{2}
2018/01/14 20:09:41 [I] [SQL] SELECT count(*) FROM `notification` WHERE user_id = ? AND status = ? []interface {}{2, 0x1}
2018/01/14 20:09:41 [I] [SQL] SELECT * FROM `org_user` LEFT JOIN `user` ON `org_user`.org_id=`use