Skip to content

Instantly share code, notes, and snippets.

View madawei2699's full-sized avatar
🎯
Focusing

Dawei Ma madawei2699

🎯
Focusing
View GitHub Profile
{"sig":"88ae11887adbd14d4674995ee23f72a53deb49cce476c86bc0a4ee48a613ea59df5f78162b2745903cf8ae915cc96e5b61deec0fbbf07a4a358441eb7bb513f81","msghash":"07e1bd0588cf1efe24c1f320dce4081603ad40e772c25ffc3f15751d086d4e98"}
@madawei2699
madawei2699 / CodingAnytimeAnywhere.exs
Created December 28, 2018 06:14
Coding Anytime Anywhere
(for x <- [<<65>><>"ny"], y <- ~w(time where), do: x <> y)
|> Enum.reduce('Co'++~c(deing)--[101], &([&2|["\s"|&1]]))
|> IO.puts
@madawei2699
madawei2699 / fibonacci-algorithms-in-elixir.exs
Created September 19, 2019 14:40
fibonacci-algorithms-in-elixir
defmodule Benchmark do
def measure(function) do
function
|> :timer.tc
|> elem(0)
|> Kernel./(1_000_000)
end
end
defmodule Fibonacci1 do
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/2.1.2/mustache.min.js"></script>
<title>TODO++</title>
</head>
<body>
<script id="todo-list" type="x-tmpl-mustache">
<script type='application/ld+json' class='yoast-schema-graph yoast-schema-graph--main'>
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "Organization",
"@id": "https://www.hallaminternet.com/#organization",
"name": "Hallam",
"url": "https://www.hallaminternet.com/",
"sameAs": [
@madawei2699
madawei2699 / populate_data.py
Created April 1, 2020 13:07
populate millions records into mysql database
from peewee import *
import uuid
import random
import string
from datetime import date, timedelta
db_name = 'db'
table_name = 'table'
db = MySQLDatabase(db_name, user='root', password='123456', host='localhost', port=3307)
@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;
@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 / 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 / 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