function parse(str) {
if (str === '' || str == null) return null
let at = 0, // current index of JSON text
ch = str[0] // character at current index
function next() {
// increments at
// updates ch
at += 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
curl https://get.acme.sh | sh | |
~/.acme.sh/acme.sh --issue --dns dns_cf -d mydomain.me |
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 -e | |
# For Ubuntu 18.04 | |
# How to launch: | |
# $ curl https://gist.githubusercontent.com/whoizit/5d29de6161270c7eb20c079add6019d2/raw/ss+v2ray+cf-wss+ubuntu.sh | |
# $ sh ss+v2ray+cf-wss+ubuntu.sh | |
[ ${EUID:-$(id -u)} -eq 0 ] && { | |
echo "This script must NOT be run as root" | |
exit | |
} |
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
class MyPromise { | |
constructor(executor) { | |
this.state = 'pending'; | |
try { | |
executor(this._resolve.bind(this), this._reject.bind(this)); | |
} catch (error) { | |
this._reject(error); | |
} | |
} |
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
class Node { | |
constructor(type, val) { | |
this.type = type | |
this.val = val | |
this.children = [] | |
} | |
} | |
// input: string | |
// return node | |
function parse(str) { |
/*
<div><span></span></div>
*/
class Node {
constructor(type, val) {
this.type = type
this.val = val
Given the root of a binary tree, collect a tree's nodes as if you were doing this:
1. Collect all the leaf nodes.
2. Remove all the leaf nodes.
3. Repeat until the tree is empty.
Example 1:
Input: root = [1,2,3,4,5]
Given an array of meeting time intervals intervals where intervals[i] = [start_i, end_i],
return the minimum number of conference rooms required.
Example 1:
Input: intervals = [[7,10],[2,4]]
Output: 1
Example 2:
Given a bi-directional graph with n vertices,
where each vertex is labeled from 0 to n - 1 (inclusive).
The edges in the graph are represented as a 2D integer array edges,
where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi.
Every vertex pair is connected by at most one edge, and no vertex has an edge to itself.
You want to determine if there is a valid path that exists from vertex start to vertex end.
Given edges and the integers n, start, and end, return true if there is a valid
In a classroom, the students are being divided into groups.
The teacher put the students in a line and associated each child with his or her integer charisma value.
Each child should go to exactly one group.
Each group should be a non-empty segment of consecutive students of a line.
A group's sociability is the maximum difference of charisma of two students in the group (in particular,
if the group consists of one child, its sociability equals a zero).
The teacher wants to divide the students into some number of groups in such way that
the total sociability of the groups is maximum. Help him find this value.
NewerOlder