Skip to content

Instantly share code, notes, and snippets.

View suconghou's full-sized avatar

suconghou suconghou

View GitHub Profile
@suconghou
suconghou / main.rs
Created November 6, 2021 14:53
actix-web
use actix_web::client::{Client, ClientRequest};
use actix_web::{get, web, App, Error, HttpRequest, HttpResponse, HttpServer, Responder};
use core::time::Duration;
use std::error;
use std::io;
const EXPOSE_HEADERS: [&str; 7] = [
"accept-ranges",
"content-range",
"content-length",
@suconghou
suconghou / patch_strings_in_file.sh
Created March 9, 2018 07:05
patch_strings_in_file
function patch_strings_in_file() {
local FILE="$1"
local PATTERN="$2"
local REPLACEMENT="$3"
# Find all unique strings in FILE that contain the pattern
HASSTRING=$(grep ${PATTERN} ${FILE})
if [ "${HASSTRING}" != "" ] ; then
echo "File '${FILE}' contain strings with '${PATTERN}' in them:"
@suconghou
suconghou / nc.go
Last active October 12, 2023 14:30
nc golang
package main
import (
"fmt"
"io"
"net"
"os"
"sync"
)
@suconghou
suconghou / test.go
Created February 6, 2018 03:12
golang http2 invalid Connection request header
package main
import (
"fmt"
"io"
"net/http"
"os"
"time"
)
@suconghou
suconghou / stream.php
Created September 21, 2017 06:06
php stream proxy
<?php
class stream
{
private static $ignore=['Host'];
public static function init($url)
{
$headers = [];
foreach(getallheaders() as $k => $v)
@suconghou
suconghou / fetch.php
Created July 11, 2017 05:30
fetch domain resource use given host
<?php
$opts = stream_context_create(array(
'http'=> array(
'method' => 'GET',
'header'=> "Host: www.oschina.net\r\nUser-Agent: my file_get_contents use host\r\n",
)
));
$url = "http://125.39.6.163/news/86646/lftp-4-8-0";
echo file_get_contents($url, null, $opts);
@suconghou
suconghou / tree.php
Last active April 23, 2017 09:37
2个无限级分类
<?php
public static function data($items)
{
$items=array_column($items,null,'id');
$tree = [];
foreach($items as $item)
{
if(isset($items[$item['pid']]))
{
$items[$item['pid']]['child'][] = &$items[$item['id']];
@suconghou
suconghou / report.sh
Last active April 23, 2017 10:57
get server status
#!/bin/bash
# config
apiUrl="http://127.0.0.1:9090"
# 内网IP
if hash ip 2>/dev/null; then
@suconghou
suconghou / generate_docker_cert.sh
Last active June 17, 2022 07:26
some shell script
#!/bin/bash
#
# Generates client and server certificates used to enable HTTPS
# remote authentication to a Docker daemon.
#
set -e
set -x
@suconghou
suconghou / http.go
Created September 29, 2016 15:44
go http file server
package main
import (
"flag"
"fmt"
"net/http"
"os"
"path"
"strconv"
)