Skip to content

Instantly share code, notes, and snippets.

View ibreathebsb's full-sized avatar
🤠

Isaac Young ibreathebsb

🤠
View GitHub Profile
@ibreathebsb
ibreathebsb / android.sh
Last active October 24, 2020 04:15
android
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
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
Last active April 3, 2023 07:01
git stash 保存未跟踪文件

git stash

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

@ibreathebsb
ibreathebsb / fix.js
Created November 22, 2018 04:58
安卓调整系统字体导致rem布局错乱
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;
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++
}