This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* 经典的概率算法, | |
* $proArr是一个预先设置的数组, | |
* 假设数组为:array(100,200,300,400), | |
* 开始是从1,1000 这个概率范围内筛选第一个数是否在他的出现概率范围之内, | |
* 如果不在,则将概率空间,也就是k的值减去刚刚的那个数字的概率空间, | |
* 在本例当中就是减去100,也就是说第二个数是在1,900这个范围内筛选的。 | |
* 这样 筛选到最终,总会有一个数满足要求。 | |
* 就相当于去一个箱子里摸东西, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": "*", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"runtime" | |
) | |
func userHomeDir() string { | |
if runtime.GOOS == "windows" { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* Base64 encode / decode | |
* http://www.webtoolkit.info/ | |
* | |
**/ | |
var Base64 = { | |
// private property |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"io" | |
"os" | |
"fmt" | |
"sync" | |
"strconv" | |
"strings" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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"; |
NewerOlder