Skip to content

Instantly share code, notes, and snippets.

View ahaxu's full-sized avatar

AhaXu ahaxu

View GitHub Profile
@ahaxu
ahaxu / chien-binh-sparta-goya-bao-duong-cung-goya-speed-2024.py
Created June 8, 2024 02:22
chien-binh-sparta-goya-bao-duong-cung-goya-speed-2024
# https://nghienchaybo.com/event/chien-binh-sparta-goya-bao-duong-cung-goya-speed-2024
def f(activities):
import math
from datetime import datetime
act_by_date = dict()
for act in activities:
start_dt_str = act.get('start_date_local') # 2021-02-12T20:40:00Z
end_dt_ts = datetime.strptime(start_dt_str, '%Y-%m-%dT%H:%M:%SZ').timestamp() + act.get('elapsed_time')
dt_obj = datetime.fromtimestamp(end_dt_ts)
@ahaxu
ahaxu / htr_mua_he_ruc_ro_2024.py
Created June 1, 2024 04:45
htr_mua_he_ruc_ro_2024.py
def f(activities):
import math
from datetime import datetime
white_list_acts = [
11448424729,
11443873790,
11443848827,
11442008938,
11443899397,
@ahaxu
ahaxu / htr-mua-he-ruc-ro-2024.py
Last active May 21, 2024 02:46
htr-mua-he-ruc-ro-2024.py
def f(activities):
import math
from datetime import datetime
act_by_date = dict()
for act in activities:
if act.get('type') != "Run":
continue
km = round(act["distance"]/1000, 2)
@ahaxu
ahaxu / htmt-tho-xay-cha-lan-2024.py
Last active March 10, 2024 03:35
HTMT tho xay challenge 2024
def f(activities, team):
import math
from datetime import datetime
act_by_date = dict()
for act in activities:
dt_str = act.get('start_date_local') # 2021-02-12T20:40:00Z
dt_obj = datetime.strptime(dt_str, '%Y-%m-%dT%H:%M:%SZ')
# key for ac_by_date dict
dt_ymd = int("{}{}{}".format(dt_obj.year, dt_obj.month, dt_obj.day))
@ahaxu
ahaxu / distinctG.hs
Last active June 5, 2023 03:05
distinctG.hs
-- Link to youtube https://youtu.be/c4saFSUAmlg
-- | Remove all duplicate integers from a list. Produce a log as you go.
-- If there is an element above 100, then abort the entire computation and produce no result.
-- However, always keep a log. If you abort the computation, produce a log with the value,
-- "aborting > 100: " followed by the value that caused it.
-- If you see an even number, produce a log message, "even number: " followed by the even number.
-- Other numbers produce no log message.
--
-- /Tip:/ Use `filtering` and `StateT` over (`OptionalT` over `Logger` with a @Data.Set#Set@).
@ahaxu
ahaxu / ecert-sketch.sh
Last active April 27, 2023 03:58
gen sketch for cert
#!/bin/bash
set -e
#
# usage:
# cat athelete.txt | xargs -I$ sh -c './ecert-sketch.sh "$"'
#
slugify () {
@ahaxu
ahaxu / ecert.sh
Created April 27, 2023 03:27
ecert generate
#!/bin/bash
set -e
slugify () {
echo "$1" | iconv -c -t ascii//TRANSLIT | sed -E 's/[~^]+//g' | sed -E 's/[^a-zA-Z0-9]+/-/g' | sed -E 's/^-+|-+$//g' | tr A-Z a-z
}
NAME=$1
DISTANCE=$2
LOOPS=$3
@ahaxu
ahaxu / vesting-sample.hs
Created March 18, 2023 06:14
vesting contract generated by chat gpt
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
module VestingSpecificRecipient
( vestingSpecificRecipient
, LockParams(..)
, VestingSchema
@ahaxu
ahaxu / tmux copy to clipboard macOSx.md
Created March 11, 2023 11:46
tmux copy to clipboard macOSx

Env iterm2 macosx

  • Open the iTerm2 menu
  • Select Preferences
  • On the "General" tab, select "Selection."
  • Check "Applications in the terminal may access the clipboard."

need to run

@ahaxu
ahaxu / 3d-triathlon-tet-2023.py
Created January 6, 2023 05:07
3d-triathlon-tet-2023.py
def calculate_set3(rs, acts):
if len(acts) == 0:
return rs
brick = [acts[0]]
for i in range(len(acts)):
if i == 0:
continue