Skip to content

Instantly share code, notes, and snippets.

View ibreathebsb's full-sized avatar

Isaac Young ibreathebsb

View GitHub Profile
function Promise(exec) {
const self = this;
self.status = "pending";
self.value = undefined;
self.onResolvedCallbacks = [];
self.onRejectedCallbacks = [];
function resolve(value) {
if (self.status === "pending") {
setTimeout(() => {
@ibreathebsb
ibreathebsb / gopl Exercise 8.8.go
Last active October 20, 2018 14:57
Exercise 8.8: Using a select statement, add a timeout to the echo server from Section 8.3 so that it disconnects any client that shouts nothing within 10 seconds.
package main
import (
"bufio"
"fmt"
"io"
"net"
"time"
)
@ibreathebsb
ibreathebsb / Combination Sum II.go
Created October 13, 2018 01:12
LeetCode 40. Combination Sum II
func combinationSum2(candidates []int, target int) [][]int {
sort.Ints(candidates)
var result [][]int
var dfs func([]int, int, []int, int)
dfs = func(candidates []int, startIndex int, currentSet []int, newTarget int) {
if newTarget == 0 {
newSet := make([]int, len(currentSet))
copy(newSet, currentSet)
result = append(result, newSet)
return
function qsort(arr) {
partSort(arr, 0, arr.length - 1);
}
function partSort(arr, start, end) {
if (start >= end) {
return;
}
const p = arr[end];
let left = start;
let right = end;
@ibreathebsb
ibreathebsb / Remove Element.go
Created October 6, 2018 03:03
LeetCode 27. Remove Element
func removeElement(nums []int, val int) int {
start := 0
current := 0
for current < len(nums) {
if nums[current] != val {
nums[start] = nums[current]
start++
}
current++
@ibreathebsb
ibreathebsb / Remove Duplicates from Sorted Array.go
Last active October 6, 2018 02:51
LeetCode 26. Remove Duplicates from Sorted Array
func removeDuplicates(nums []int) int {
start := 0
current := 1
for current < len(nums) {
if nums[current] != nums[start] {
nums[start+1] = nums[current]
start++
}
current++
}
@ibreathebsb
ibreathebsb / Reverse Nodes in k-Group.go
Created October 5, 2018 14:15
Leetcode 25. Reverse Nodes in k-Group
func reverseKGroup(head *ListNode, k int) *ListNode {
if nil == head || k <= 1 {
return head
}
dummy := &ListNode{-1, head}
stack := make([]*ListNode, k)
pointer := 0
start, last := head, dummy
for nil != start {
stack[pointer] = start
@ibreathebsb
ibreathebsb / Swap Nodes in Pairs.go
Last active October 5, 2018 11:28
LeetCode 24. Swap Nodes in Pairs
func swapPairs(head *ListNode) *ListNode {
if head == nil {
return head
}
dummy := &ListNode{-1, head}
previous, current := dummy, head
for current != nil {
// adjust
next := current.Next
if next == nil {
import * as qs from 'qs'
import {env} from 'src/env'
import {timestamp} from './timestamp'
// 用于配置不同环境api地址
interface IAPIURL {
development: string
test: string
production: string
}

netstat

参数

  • -a 列出所有连接数据
  • -t tcp
  • -u udp
  • -n 列出端口号
  • -p 列出PID