Skip to content

Instantly share code, notes, and snippets.

Isaac Young ibreathebsb

Block or report user

Report or block ibreathebsb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ibreathebsb
ibreathebsb / traverse.js
Created Jun 11, 2019
nodejs traverse directory
View traverse.js
const fs = require("fs");
const path = require("path");
function traverse(current, cb) {
const stat = fs.statSync(current);
if (stat.isDirectory()) {
const files = fs.readdirSync(current);
files.forEach(file => {
const absPath = path.resolve(current, file);
traverse(absPath, cb);
@ibreathebsb
ibreathebsb / Dockerfile
Created May 28, 2019
docker npm scripts 没有运行
View Dockerfile
# --unsafe-perm
RUN npm i -g --unsafe-perm some-package
View android.sh
adb shell settings get global device_name
adb shell settings put global device_name "Pixel-2L"
adb shell settings put global http_proxy 192.168.199.233:8888
View hammerspoon自动切换输入法.lua
local function Chinese()
-- 简体拼音
hs.keycodes.currentSourceID("com.apple.inputmethod.SCIM.ITABC")
end
local function English()
-- ABC
hs.keycodes.currentSourceID("com.apple.keylayout.ABC")
end
@ibreathebsb
ibreathebsb / git stash.md
Created Jan 24, 2019
git stash 保存未跟踪文件
View git stash.md

git stash

默认 git stash 仅会将已经跟踪的文件存储,当工作区有为跟踪文件时,使用git stash --all可以将所有文件存储起来。

@ibreathebsb
ibreathebsb / fix.js
Created Nov 22, 2018
安卓调整系统字体导致rem布局错乱
View fix.js
function calcREM() {
var docEl = document.documentElement;
var width = docEl.getBoundingClientRect().width;
var rem = width / 7.5;
rem = parseFloat(rem.toFixed(3));
docEl.style.fontSize = rem + 'px';
// 修正系统字体调整造成的布局问题
var realitySize = parseFloat(window.getComputedStyle(document.documentElement).fontSize);
if (rem !== realitySize) {
rem = rem * rem / realitySize;
View Promise.js
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 Oct 20, 2018
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.
View gopl Exercise 8.8.go
package main
import (
"bufio"
"fmt"
"io"
"net"
"time"
)
@ibreathebsb
ibreathebsb / Combination Sum II.go
Created Oct 13, 2018
LeetCode 40. Combination Sum II
View Combination Sum II.go
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
View qsort.js
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;
You can’t perform that action at this time.