Skip to content

Instantly share code, notes, and snippets.

View corerman's full-sized avatar
🚩

corerman

🚩
View GitHub Profile
@corerman
corerman / php_post.php
Created May 6, 2017 02:15
PHP post request (custom header and fast)
/*
* Use curl for http to send body for the form array, header for the head array
* Reference: http: //www.q3060.com/list3/list117/28490.html
*/
function sendPostRequest($url,$body,$header=null)
{
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Expect: ")); //Increase the sending speed :
curl_setopt($ch, CURLOPT_POST,true);
@corerman
corerman / iptables_forward
Last active May 9, 2017 06:11
iptables 中转流量 (端口范围)
vi /etc/sysctl.conf
将 net.ipv4.ip_forward=0
修改成 net.ipv4.ip_forward=1
sysctl -p
iptables -L -n -t nat 看规则列表
iptables -t nat -F 清空原有的nat规则
iptables -t nat -Z 清空原有的nat规则
iptables -F 清空所有的正常规则
iptables -X 清空所有的正常规则
iptables -Z 清空所有的正常规则
@corerman
corerman / gist:2983c51e13354840a4c5f6385bc4df54
Last active June 14, 2017 01:54 — forked from aeurielesn/gist:2511005
Retrying a jQuery.ajax() call
$.ajax({
url: '/echo/error/',
async: true,
// retryCount and retryLimit will let you retry a determined number of times
retryCount: 0,
retryLimit: 10,
// retryTimeout limits the total time retrying (in milliseconds)
retryTimeout: 10000,
// timeout for each request
timeout: 1000,
@corerman
corerman / leftjoin.sql
Created June 14, 2017 01:52
Sql left join
select a.oldman_name,b.org_id
From tbl_assess_oldman_ability a LEFT JOIN tbl_assess_user b
ON a.assess_user_id=b.admin_id
where b.org_id=15
You can upload data and files with one form using ajax.
PHP + HTML
<?
print_r($_POST);
print_r($_FILES);
?>
<form id="data" method="post" enctype="multipart/form-data">
@corerman
corerman / goBlowFish.go
Created January 5, 2018 03:49
golang blowfish 加密算法
package main
import (
"crypto/cipher"
// "github.com/labstack/gommon/log"
"golang.org/x/crypto/blowfish"
"fmt"
)
func main() {
// decrypt()
encrypt()
@corerman
corerman / shellService.sh
Created January 6, 2018 07:53
shell service
#!/bin/bash
case "$1" in
"start")
echo "$0 starting...";
privoxy /config;
echo "$0 started...";;
"stop")
echo "$0Stoping...";
killall privoxy;
echo "$0 Stoped...";;
@corerman
corerman / iptables.sh
Created January 10, 2018 14:02
iptables转发:根据ip进行转发
iptables -t nat -A PREROUTING -d 1.2.3.4 -p tcp --dport 3389 -j DNAT --to 192.168.1.1:3389
类似这个的。
1.2.3.4是你的外网IP  192.168.1.1是你想映射到外网的内网服务器。
如果vps有多个ip,可以实现ip之间端口转发
@corerman
corerman / goTcpListen.go
Created January 15, 2018 09:10
golang network listen
package main
import (
"fmt"
"net"
"time"
"bufio"
)
func handleConnection(conn net.Conn) {
package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"net/url"
)