Skip to content

Instantly share code, notes, and snippets.

@keegoo
keegoo / golang_cheatsheet.md
Last active April 3, 2025 04:03
a cheatsheet for go lang

Type

package main
import "fmt"

func main() {

    myString := "dog"
    myByte := []byte("cat")
@keegoo
keegoo / rust_cheatsheet.md
Last active January 17, 2025 14:55
my Rust cheat sheet

Table of Contents

  • Cargo
  • Array
  • 简单数字类型。
  • 简单字符串类型。
  • 字典类型。
  • 自定义类型。
  • 输出
  • 条件
  • 循环
// Collection and Map are interfaces.
// compare to Array and Map in other languages.
import java.util.Collection
import java.util.Map
// sample methods of Collection interface:
//
// add
// clear
// equals
// isEmpty
// --------------- catalog ---------------
//
// * basic data type and size(64-bit platforms)
// * padding for alignment requirements
// * a useful function to print number in binary
// * pointer and double pointer
// * printf
// * struct
// * initialize and access
// * access through pointer
const puppeteer = require('puppeteer')
class Element {
constructor(parent, css='body') {
this._parent = parent
this._css = css
this._page = this._parent.constructor.name == 'Page' ? this._parent : this._parent._page
}
async goto(url) {
# ========== theory ==========
#
# Mock and MagicMock are all classes in `unitest.mock` library.
#
# ---------- The MagicMock Class ----------
# A MagicMock instance can:
# * capture the arguments that the method is called with
# * count how many times it's called
# * return values that we specify
# * return the same or different values each time the mocked method is called
from locust import HttpUser, task, between
import uuid
class User(HttpUser):
wait_time = between(5, 9)
@task
def scenario_01(self):
self.view_computer()
self.create_computer()

puzzle 01

# Description: 
# given a list of integer(no duplicate), find all pairs that add up to a target number
# example: list=[1,3,5,7] target=8, result = 1,7 3,5
# requirement: as fast as possible
require 'set'

def find_pair(ary, sum)