Skip to content

Instantly share code, notes, and snippets.

View thanakijwanavit's full-sized avatar

Nic Wanavit thanakijwanavit

View GitHub Profile
@edgeboyo
edgeboyo / hashscript.py
Created May 14, 2021 13:36
SHA256 Encoder in python
import hashlib
import time
start_time = time.time()
s = input("Input string: ")
for i in range(1000000):
s = hashlib.sha256(s.encode()).digest().hex()
end_time = time.time()
@scriptpapi
scriptpapi / DocumentPicker.swift
Created April 26, 2021 21:25
Document Picker for SwiftUI
import Foundation
import SwiftUI
import UIKit
struct DocumentPicker: UIViewControllerRepresentable {
@Binding var filePath: URL?
func makeCoordinator() -> DocumentPicker.Coordinator {
return DocumentPicker.Coordinator(parent1: self)
@thanakijwanavit
thanakijwanavit / installStandardLibs.sh
Last active April 20, 2021 08:44
standard requirements for development in python 3.8
pip install -r https://gist.github.com/thanakijwanavit/cc1c456b62315823acdfe6352004e0fc/raw/requirements.txt
@thanakijwanavit
thanakijwanavit / changeMimeType.sh
Created January 29, 2021 06:30
changeMimeType
aws s3 cp s3://villa-remove-bg-small-output/ s3://villa-remove-bg-small-output/ --recursive --content-t
ype="image/png" --no-guess-mime-type --metadata-directive="REPLACE"
@nrubin29
nrubin29 / homebrew_m1.sh
Last active November 24, 2023 11:27
Install Native Homebrew on Apple Silicon M1
# We'll be installing Homebrew in the /opt directory.
cd /opt
# Create a directory for Homebrew. This requires root permissions.
sudo mkdir homebrew
# Make us the owner of the directory so that we no longer require root permissions.
sudo chown -R $(whoami) /opt/homebrew
# Download and unzip Homebrew. This command can be found at https://docs.brew.sh/Installation.
@korakot
korakot / asyncio.py
Last active January 3, 2024 02:15
Use asyncio (async) in Colab
import nest_asyncio
nest_asyncio.apply()

With GitHub Actions, a workflow can publish artifacts, typically logs or binaries. As of early 2020, the life time of an artifact is hard-coded to 90 days (this may change in the future). After 90 days, an artifact is automatically deleted. But, in the meantime, artifacts for a repository may accumulate and generate mega-bytes or even giga-bytes of data files.

It is unclear if there is a size limit for the total accumulated size of artifacts for a public repository. But GitHub cannot reasonably let multi-giga-bytes of artifacts data accumulate without doing anything. So, if your workflows regularly produce large artifacts (such as "nightly build" procedures for instance), it is wise to cleanup and delete older artifacts without waiting for the 90 days limit.

Using the Web page for the "Actions" of a repository, it is possible to browse old workflow runs and manually delete artifacts. But the procedure is slow and tedious. It is fine to delete one selected artifact. It is not for a regular cleanup. We need

@dcchambers
dcchambers / md2pdf.md
Last active September 5, 2024 07:02
Generate a PDF from Markdown files with Pandoc

Generate a PDF from a Markdown file with Pandoc

Easy Steps For Mac OS

  1. Have Homebrew installed and a markdown file you want to render to PDF.
  2. Install Pandoc brew install pandoc
  3. Install basictex brew cask install basictex - needed for the pdflatex tool.
  4. Symlink the pdflatex to your /usr/local/bin so pandoc can easily find it. ln -s /Library/TeX/Root/bin/x86_64-darwin/pdflatex /usr/local/bin/pdflatex
  5. Use Pandoc to generate a PDF from a Markdown file. pandoc input.md -o output.pdf
  • By default the margins are pretty large. To optionally change the margins: pandoc input.md -o output.pdf -V geometry:margin=1in
@emilioramirez
emilioramirez / generate_password.py
Last active July 27, 2022 06:13
Password generator
"""
Based on the python doc https://docs.python.org/3/library/secrets.html
"""
import argparse
import secrets
import string
def generate_password(password_length):
alphabet = string.ascii_letters + string.digits
@korakot
korakot / selenium.py
Last active July 11, 2024 02:09
Use selenium in Colab
# install chromium, its driver, and selenium
!apt update
!apt install libu2f-udev libvulkan1
!wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
!dpkg -i google-chrome-stable_current_amd64.deb
!wget https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/118.0.5993.70/linux64/chromedriver-linux64.zip
!unzip -j chromedriver-linux64.zip chromedriver-linux64/chromedriver -d /usr/local/bin/
!pip install selenium chromedriver_autoinstaller
# set options to be headless, ..