Skip to content

Instantly share code, notes, and snippets.

View beanyoung's full-sized avatar

BeanYoung beanyoung

  • ByteDance
  • Beijing, China
View GitHub Profile
server {
listen *:80 backlog=4096;
server_name *.stdcdn.com stdcdn.com;
client_max_body_size 1024m;
location / {
proxy_pass http://10.3.96.3:80;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
@beanyoung
beanyoung / login
Last active December 29, 2017 02:24
#!/usr/bin/expect -f
set host [lindex $argv 0]
spawn ssh demo.com
send "su ubuntu\r"
expect "?assword"
send "password\r"
interact
@beanyoung
beanyoung / ssh_port_forward.conf
Created November 4, 2017 04:12
ssh_port_forward.conf
[program:ssh]
command=ssh -vvv -o ServerAliveInterval=30 -o TCPKeepAlive=yes -o ServerAliveCountMax=2 -N -R 0.0.0.0:2222:127.0.0.1:22 YOUR_SERVER_IP
user=chenbingyu
numprocs=1
stopsignal=TERM
autostart=true
startsecs=1
startretries=10
autorestart=true
serverurl=AUTO

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
<?php
$app_key = 'demo_key';
$app_secret = 'demo_secret';
$rfc_1123_date = gmdate('D, d M Y H:i:s T', time());
file_put_contents('./log.txt',json_encode($_POST),FILE_APPEND);
// $_POST['job_id'] ='577c460f-140a-4112-8898-a943ea020ccc';
if(isset($_POST['job_id'])){
import sys
template = """
def test_%s():
pass
"""
def main():
#!/usr/bin/python
# -*- coding: utf-8 -*-
import requests
# api = 'https://api.xmpush.xiaomi.com/v2/message/regid'
api = 'https://sandbox.xmpush.xiaomi.com/v2/message/regid'
secret = 'demo_secret'
@beanyoung
beanyoung / flask_thrift_server.py
Last active October 8, 2020 15:12
thrift server based on flask
from flask import Flask, request, make_response
from thrift.protocol import TBinaryProtocol
from thrift.server import TServer
from thrift.transport import TTransport
from FooService import FooService
from foo_service_handler import FooServiceHandler
@beanyoung
beanyoung / diffbot_demo.py
Created January 2, 2014 16:26
diffbot demo
from diffbot import Client
c = Client('demo_token')
url = 'http://www.diffbot.com/products/automatic/article/'
json_object = c.get('/v2/article', url)
data = 'Now is the time for all good robots to come to the aid of their-- oh never mind, run!'
json_object = c.post('/v2/article', url, content_type='text-plain', data=data)
int_arr = [97, 98, 99, 100, 101]
char_arr = ''.join([unichr(i) for i in int_arr])