Skip to content

Instantly share code, notes, and snippets.

View madawei2699's full-sized avatar
🎯
Focusing

Dawei Ma madawei2699

🎯
Focusing
View GitHub Profile
@madawei2699
madawei2699 / CDDR.md
Last active October 30, 2023 11:56
ChatGPT Driven Development Record / SendMessages / myGPTUser

2023-04-13


ChatGPT

You

@madawei2699
madawei2699 / main.py
Created January 2, 2023 05:55
Get cryptocurrency year price history data
import requests
import csv
from datetime import datetime
# 设置 id 和 range 参数
id = 1 # BTC
# id = 1027 # ETH
start = 2022
end = 2022 + 1
@madawei2699
madawei2699 / README.md
Last active April 23, 2022 05:25
Go API Server with remote request benchmark test
@madawei2699
madawei2699 / README.md
Last active April 22, 2022 15:24
Golang JSON API Test Server

How to run?

go get

go run main.go

API

http://localhost:1323/json

@madawei2699
madawei2699 / README.md
Last active March 7, 2022 05:17
samesite strict mode test

SameSite Strict Test

Benefit of SameSite Strict

If the SameSite attribute is set to Strict, then the browser will not include the cookie in any requests that originate from another site. This is the most defensive option, but it can impair the user experience, because if a logged-in user follows a third-party link to a site, then they will appear not to be logged in, and will need to log in again before interacting with the site in the normal way.

If the SameSite attribute is set to Lax, then the browser will include the cookie in requests that originate from another site but only if two conditions are met:

  • The request uses the GET method. Requests with other methods, such as POST, will not include the cookie.
  • Imagine we have a very bad design and all our actions are performed on GET method. The attacker placed link saying "Save puppies" which links to http://oursite.com/users/2981/delete
@madawei2699
madawei2699 / clojure-async.clj
Last active March 6, 2022 13:20
Use clojure.core.async to Implement Http Client Async
;; lein repl
(ns test (:require [clojure.core.async :as async]
[clj-http.client :as client]))
;; define test data
(def urls ["http://www.google.com" "http://www.google1.com" "http://255.255.33.44:8001/"])
;; use async/go to build a async http client
(defn fetch-async
@madawei2699
madawei2699 / Main.java
Created March 5, 2022 15:42
Apache Http Client Time Test
package org.example;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.concurrent.FutureCallback;
import org.apache.http.config.Registry;
@madawei2699
madawei2699 / cloud9-code-server
Created August 19, 2021 15:09 — forked from wongcyrus/cloud9-code-server
Install and run Visual Studio Code (Code-Server) in AWS Cloud9
ip=$(curl http://169.254.169.254/latest/meta-data/public-ipv4)
echo "Code Server"
echo "http://$ip:8443"
security_group=$(ec2-metadata -s | cut -d " " -f 2);
aws ec2 authorize-security-group-ingress --group-name $security_group --protocol tcp --port 8443 --cidr 0.0.0.0/0
version="1.32.0-310"
wget https://github.com/codercom/code-server/releases/download/$version/code-server-$version-linux-x64.tar.gz
tar -xvzf code-server-$version-linux-x64.tar.gz
cd code-server-$version-linux-x64
chmod +x code-server
@madawei2699
madawei2699 / custom.css
Last active October 16, 2024 08:51
logseq/custom.css
/*
/* Theme custom css start
/* https://raw.githack.com/dracula/logseq/master/custom.css
*/
@import url("https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;700&family=Fira+Sans:ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700&display=swap");
:root {
--background: #282a36;
--light-background: #343746;
@madawei2699
madawei2699 / Rx.java
Last active June 4, 2020 16:15
rx java parallel demo
public class Rx {
public static void main(String[] args) {
int threadNum = Runtime.getRuntime().availableProcessors() + 1;
ExecutorService executor = Executors.newFixedThreadPool(threadNum);
final Scheduler scheduler = Schedulers.from(executor);
Observable.range(1, 20)
.flatMap(x -> {
Observable<Integer> observableA = Observable.just(x).observeOn(scheduler).map(a -> {
System.out.println(Thread.currentThread().getName() + ": =observableA=> " + a);
return a;