Skip to content

Instantly share code, notes, and snippets.

View cute-angelia's full-sized avatar
🎯
最近在开发游戏服务端,网络基础框架还是比一般的服务复杂

Angelia cute-angelia

🎯
最近在开发游戏服务端,网络基础框架还是比一般的服务复杂
View GitHub Profile
@cute-angelia
cute-angelia / PHP中奖概率算法
Created June 28, 2022 08:41 — forked from wolf432/PHP中奖概率算法
PHP中奖概率算法
<?php
/*
* 经典的概率算法,
* $proArr是一个预先设置的数组,
* 假设数组为:array(100,200,300,400),
* 开始是从1,1000 这个概率范围内筛选第一个数是否在他的出现概率范围之内,
* 如果不在,则将概率空间,也就是k的值减去刚刚的那个数字的概率空间,
* 在本例当中就是减去100,也就是说第二个数是在1,900这个范围内筛选的。
* 这样 筛选到最终,总会有一个数满足要求。
* 就相当于去一个箱子里摸东西,
@cute-angelia
cute-angelia / notion2blog.js
Created November 16, 2021 07:23 — forked from mayneyao/notion2blog.js
Notion.so > Personal Blog | custom domain + disqus comment
const MY_DOMAIN = "agodrich.com"
const START_PAGE = "https://www.notion.so/gatsby-starter-notion-2c5e3d685aa341088d4cd8daca52fcc2"
const DISQUS_SHORTNAME = "agodrich"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
@cute-angelia
cute-angelia / socks5_proxy.go
Created September 8, 2021 08:31 — forked from ometa/socks5_proxy.go
Golang HTTP Client using SOCKS5 proxy and DialContext
// Golang example that creates an http client that leverages a SOCKS5 proxy and a DialContext
func NewClientFromEnv() (*http.Client, error) {
proxyHost := os.Getenv("PROXY_HOST")
baseDialer := &net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}
var dialContext DialContext
@cute-angelia
cute-angelia / build.sh
Last active March 4, 2020 05:35 — forked from tmpbook/build.sh
Jenkins build setup for Go Projects.
# You need install jenkins go plugin first -> https://wiki.jenkins.io/display/JENKINS/Go+Plugin
#!/usr/bin/bash
pwd
export GOPROXY=https://goproxy.io
cd ./ && make proto
export GOROOT=/usr/local/go
export GOPATH=$WORKSPACE
mkdir -p $GOPATH/src
@cute-angelia
cute-angelia / aes-256-cbc-test.js
Created February 28, 2020 15:19 — forked from brettscott/aes-256-cbc-test.js
AES 256 CBC encryption between Golang and Node JS
// Node v6.9.0
//
// TEST FILE (cut down for simplicity)
// To ensure Golang encrypted string can be decrypted in NodeJS.
//
let crypto;
try {
crypto = require('crypto');
@cute-angelia
cute-angelia / userhomedir.go
Created November 4, 2019 13:49 — forked from miguelmota/userhomedir.go
Golang get user home directory path
package main
import (
"fmt"
"os"
"runtime"
)
func userHomeDir() string {
if runtime.GOOS == "windows" {
/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
*
**/
var Base64 = {
// private property
@cute-angelia
cute-angelia / nginx
Last active December 25, 2017 02:12 — forked from pzorn/nginx
php-fpm and nginx init.d script
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: NGINX is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
@cute-angelia
cute-angelia / mm.go
Created October 31, 2017 01:31 — forked from lerry/mm.go
package main
import (
"io"
"os"
"fmt"
"sync"
"strconv"
"strings"
@cute-angelia
cute-angelia / toCsv.php
Created October 20, 2017 06:06 — forked from ring0li/toCsv.php
csv
/**
* Export an array as downladable Excel CSV
* http://stackoverflow.com/questions/155097/microsoft-excel-mangles-diacritics-in-csv-files
* @param array $header
* @param array $data
* @param string $filename
*/
function toCSV($header, $data, $filename) {
$sep = "\t";
$eol = "\n";