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
defmodule MergeSoredList do | |
def merge(l1, []), do: l1 | |
def merge([], l2), do: l2 | |
def merge(l1, l2), do: merge(l1, l2, []) | |
def merge([], l2, acc), do: acc ++ l2 | |
def merge(l1, [], acc), do: acc ++ l1 | |
def merge([head1| tail1], [head2 | _] = l2, acc) when head1 <= head2 do | |
merge(tail1, l2, acc ++ [head1]) |
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 puppeteer = require('puppeteer'); | |
(async () => { | |
const browser = await puppeteer.launch({headless: false}); // default is true | |
const page = await browser.newPage(); | |
// 116.451673,39.923054 | |
await page.setGeolocation({latitude: 39.923054, longitude: 130.451673}); | |
// iphone x | |
await page.setViewport({ width: 375, height: 812}); |
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
defmodule SocketServer do | |
require Logger | |
import Sentry.Event | |
@doc """ | |
Starts accepting connections on the given `port`. | |
""" | |
def accept(port) do | |
{:ok, socket} = :gen_tcp.listen(port, | |
[:binary, packet: :line, active: false, reuseaddr: true]) |
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 ( | |
...... | |
"golang.org/x/sync/errgroup" | |
) | |
// 一个多阶段的pipeline.使用有限的goroutine计算每个文件的md5值. | |
func main() { |
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
// run https://play.golang.org/p/gVl4Ru_isVA | |
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
func main() { | |
fmt.Println(pair(168, 701)) |
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
apiVersion: networking.istio.io/v1alpha3 | |
kind: VirtualService | |
metadata: | |
name: productpage | |
spec: | |
hosts: | |
- productpage | |
http: | |
- route: | |
- destination: |
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
(setenv "PATH" (concat (getenv "PATH") ":~/go/bin")) | |
;; Set up package.el to work with MELPA | |
(require 'package) | |
(setq package-archives '(("gnu" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/") | |
("melpa" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/"))) | |
(package-initialize) | |
(package-refresh-contents) |
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
apiVersion: extensions/v1beta1 | |
kind: Deployment | |
metadata: | |
annotations: | |
hello: world | |
labels: | |
io.service: zerotier | |
name: zerotier | |
spec: | |
replicas: 1 |
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
// 实现一个 Trie (前缀树),包含 insert, search, 和 startsWith 这三个操作。 | |
// 示例: | |
// Trie trie = new Trie(); | |
// trie.insert("apple"); | |
// trie.search("apple"); // 返回 true | |
// trie.search("app"); // 返回 false | |
// trie.startsWith("app"); // 返回 true |
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" | |
"runtime" | |
"sync" | |
) | |
func main() { | |
memConsumed := func() uint64 { |
NewerOlder