Skip to content

Instantly share code, notes, and snippets.

View henrybear327's full-sized avatar

Chun-Hung Tseng henrybear327

View GitHub Profile
@luk6xff
luk6xff / ARMonQEMUforDebianUbuntu.md
Last active June 6, 2024 17:16 — forked from bruce30262/ARMDebianUbuntu.md
Emulating ARM with QEMU on Debian/Ubuntu

You might want to read this to get an introduction to armel vs armhf.

If the below is too much, you can try Ubuntu-ARMv7-Qemu but note it contains non-free blobs.

Running ARM programs under linux (without starting QEMU VM!)

First, cross-compile user programs with GCC-ARM toolchain. Then install qemu-arm-static so that you can run ARM executables directly on linux

If there's no qemu-arm-static in the package list, install qemu-user-static instead

@scottt
scottt / stack-and-sp.c
Created June 11, 2018 23:12
stack-and-sp: test whether stack access without setting the stack pointer register would cause SEGFAULTs on x86-64
/* x86-64 program to test wether stack access without setting the stack poitner register would cause SEGFAULTs
* $ ./stack-and-sp # just access stack adjacent memory until SEGFAULT.
* $ ./stack-and-sp --set-sp # set stack pointer register before accessing memory.
*
* Output:
* stack-and-sp: do_set_sp: 1
* RLIMIT_STACK: 8192/unlimited (cur/max)
* sp0: 0x7ffd5fdd3000
* sp: 0x7ffd5f5d7000, size: 8176K
*/
@jdh747
jdh747 / Google IO 2012.md
Last active September 15, 2023 02:24
Go Concurrency Patterns: Google IO 2012

Concurrency Patterns in Go

Notes taken from Rob Pike's presentation 'Google I/O 2012 - Go Concurrency Patterns'.

1. Generator: function that returns a channel

The code is as follows:

c := boring("boring!")  // function returning a channel

for i := 0; i < 5; i++ {
@APTy
APTy / Makefile
Last active June 13, 2024 16:24
Run a makefile command with cleanup
# This file includes example usage and tests for the 'run-with-cleanup' call-able function.
.PHONY: test test-success test-failure main cleanup
-include cleanup.mk
test:
test.sh
main:
@yssharma
yssharma / join-cluster.go
Last active November 15, 2021 02:11
Writing a basic distributed system in go lang - part 1 - confused coders
package main
/* Al useful imports */
import (
"flag"
"fmt"
"net"
"strings"
"strconv"
"time"
@kanetai
kanetai / bound.rb
Created April 24, 2016 13:17
cpp-like lower_bound, upper_bound in Ruby
def lowerBound(a, key)
lb = -1; ub = a.length
while ub - lb > 1
mid = (lb + ub) / 2
if a[mid] >= key
ub = mid
else
lb = mid
end
end
// 1. 打開 Slack 網頁版
// 2. 開啟需要備份的對話視窗,包含 Direct Message 或 Channel 都可以
// 3. 打開 Chrome Dev Tools 的 Console
// 4. 複製貼上以下程式碼
// 5. 執行 JS 並輸出歷史訊息
// 6. 換下一個 Channel 繼續備份
// 7. 重複第4個步驟
// PS. 輸出到 Console 的歷史訊息,可以透過在空白處按右鍵 -> Save as ,另存成文字檔
var historyMessages = `[Slack Export History Messages] SEHM\n`;
@heathermiller
heathermiller / scala-cheatsheet.md
Last active May 11, 2024 14:06
Scala Cheatsheet

This cheat sheet originated from the forum, credits to Laurent Poulain. We copied it and changed or added a few things.

Evaluation Rules

  • Call by value: evaluates the function arguments before calling the function
  • Call by name: evaluates the function first, and then evaluates the arguments if need be
    def example = 2      // evaluated when called
    val example = 2      // evaluated immediately
@joepie91
joepie91 / vpn.md
Last active June 25, 2024 22:03
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

  • A Russian translation of this article can be found here, contributed by Timur Demin.
  • A Turkish translation can be found here, contributed by agyild.
  • There's also this article about VPN services, which is honestly better written (and has more cat pictures!) than my article.
@amoshyc
amoshyc / binary_search_tutorial.md
Last active April 6, 2020 18:17
二分搜教學

二分搜:講解

以下出現 A[l, r] 代表 A 陣列中 [l, r] 這個區間。 同理 A[l, r) 代表 A 陣列中 [l, r) 這個區間。

以下範例皆不處理 IO 的部份,都假設變數皆已被讀入。

基本使用

大一時學過,我們可以用二分搜在一個單調(遞增或遞減)的陣列中,尋找某個值在哪裡: