This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # | |
| # SPDX-License-Identifier: CC0-1.0 | |
| # SPDX-FileCopyrightText: 2026 Arthit Suriyawongkul | |
| # | |
| # Generate SPDX 3 model artifacts (RDFs, JSON-LD context, JSON Schema) | |
| # | |
| # This script will | |
| # - fetch the latest version of SPDX 3 model from spdx-3-model | |
| # - fetch a JSON-LD annotations from spdx-spec |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-FileCopyrightText: 2025-present Arthit Suriyawongkul | |
| # SPDX-FileType: SOURCE | |
| # SPDX-License-Identifier: 0BSD | |
| # | |
| # Generate a simplified interface to classes and functions. | |
| # | |
| # It import all classes and functions from the original module, | |
| # removing the (long IRI-based) prefix from class names, | |
| # and re-export them to the new module. | |
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jobs: | |
| build: | |
| steps: | |
| - name: Make Python implementation ID (non-Windows) | |
| id: convert-version-id | |
| if: startsWith(matrix.os, 'windows-') == false | |
| run: | | |
| PYTHON_VERSION=${{ matrix.python-version }} | |
| if [[ "$PYTHON_VERSION" == pypy* ]]; then | |
| CP_VER="pp${PYTHON_VERSION:4}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| amount=$1 | |
| regex=$2 | |
| echo "Generating $amount UUIDs with $regex..." | |
| count=0 | |
| while [ $count -lt $amount ]; do | |
| uuid=$(uuidgen | awk '{print tolower($0)}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 1) export text from JSON | |
| import json | |
| import pandas as pd | |
| from pandas import json_normalize | |
| # note: have to remove `window.YTD...` in the first line | |
| data = json.load(open('bact-tweet.json')) | |
| df = pd.DataFrame.from_records(json_normalize(data)) | |
| df = df[df["tweet.lang"] == "th"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _THAI_ARABIC = { | |
| "๐": "0", | |
| "๑": "1", | |
| "๒": "2", | |
| "๓": "3", | |
| "๔": "4", | |
| "๕": "5", | |
| "๖": "6", | |
| "๗": "7", | |
| "๘": "8", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # thai_strftime() | |
| # Thai date and time string formatter | |
| # Formatting directives similar to datetime.strftime() | |
| # | |
| # จัดรูปแบบข้อความวันที่และเวลา แบบเดียวกับ datetime.strftime() | |
| # โดยจะใช้ชื่อเดือนเป็นภาษาไทย และปีเป็นพุทธศักราช | |
| # (ไม่รองรับปีก่อน พ.ศ. 2484 - ก่อนการเปลี่ยนวันปีใหม่ไทย) | |
| # | |
| # No Rights Reserved | |
| # PUBLIC DOMAIN or CC0 1.0 Universal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def is_one_swap_can_sort(nums): | |
| sorted_nums = sorted(nums) | |
| if nums == sorted_nums: | |
| return True | |
| len_nums = len(nums) | |
| for i in range(len_nums): | |
| for j in range(i+1, len_nums): | |
| test = nums.copy() | |
| if test[i] > test[j]: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| def bingap(num): # wronggggg | |
| zeroes = re.findall(r"0+", bin(num)[2:]) | |
| return len(max(zeroes, key=len)) if zeroes else 0 | |
| n = 32 | |
| print(bin(n)) | |
| bingap(n) |
NewerOlder