Skip to content

Instantly share code, notes, and snippets.

View everthis's full-sized avatar
:octocat:
...

Nothing everthis

:octocat:
...
View GitHub Profile
@everthis
everthis / a.sh
Created November 23, 2023 03:21
acme
curl https://get.acme.sh | sh
~/.acme.sh/acme.sh --issue --dns dns_cf -d mydomain.me
@everthis
everthis / ss+v2ray+cf-wss+ubuntu.sh
Created November 22, 2023 04:09 — forked from whoizit/ss+v2ray+cf-wss+ubuntu.sh
shadowsocks v2ray-plugin cloudflare-wss ubuntu.sh
#!/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
}
@everthis
everthis / p.js
Created April 20, 2023 07:37
Promise implementation
class MyPromise {
constructor(executor) {
this.state = 'pending';
try {
executor(this._resolve.bind(this), this._reject.bind(this));
} catch (error) {
this._reject(error);
}
}
@everthis
everthis / parseHTML.js
Last active August 1, 2022 09:25
parseHTML
class Node {
constructor(type, val) {
this.type = type
this.val = val
this.children = []
}
}
// input: string
// return node
function parse(str) {
@everthis
everthis / parse.md
Last active June 28, 2022 09:05
parse
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
@everthis
everthis / parse.md
Created April 25, 2022 07:35
parse

/*
  <div><span></span></div>
*/

class Node {
  constructor(type, val) {
    this.type = type
    this.val = val
@everthis
everthis / i2.md
Created February 11, 2022 01:22
i2.md
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]
@everthis
everthis / i1.md
Last active February 11, 2022 01:12
i1.md
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:
@everthis
everthis / w26.md
Created November 19, 2021 00:54
w26
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 
@everthis
everthis / w25.md
Created November 19, 2021 00:45
w25
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.