Skip to content

Instantly share code, notes, and snippets.

View fonylew's full-sized avatar
🐝
Go Jackets!

Kamolphan Lewprasert fonylew

🐝
Go Jackets!
View GitHub Profile
@fonylew
fonylew / docker_run_colab.sh
Created March 20, 2024 17:49
Run Google Colab runtime locally
docker run --gpus=all -p 127.0.0.1:9000:8080 us-docker.pkg.dev/colab-images/public/runtime
@fonylew
fonylew / docker_run_jupyter.sh
Created March 20, 2024 16:32
Run Jupyter Notebook on Docker with GPU
docker run -d --gpus all -v $(realpath ~/notebooks):/tf/notebooks -p 8888:8888 tensorflow/tensorflow:latest-gpu-jupyter
@fonylew
fonylew / message_generator_pubsub.py
Last active August 11, 2022 17:50 — forked from antoniocachuan/message_generator_pubsub.py
Simple Message generator for Google Cloud Pub/Sub
#!/usr/bin/env python
# Code modified from https://cloud.google.com/dataflow/docs/samples/join-streaming-data-with-sql#expandable-3
import datetime, json, os, random, time
# Set the `project` variable to a Google Cloud project ID.
project = 'GCP-PROJECT-ID'
BRANCH = ['LIM', 'BOG', 'SFO', 'LAX', 'PEK', 'ATL', 'CDG', 'AMS',
'HKG', 'ICN', 'FRA', 'MAD', 'SEA', 'LAS', 'SIN', 'BKK', 'DFW',
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
git config --global alias.sweep '!git branch --merged $([[ $1 != "-f" ]] \
&& git rev-parse master) | egrep -v "(^\*|^\s*(master|develop)$)" \
| xargs git branch -d'
# สร้าง bucket
gsutil mb gs://[BUCKET]
# ลิสต์ files ใน bucket
gsutil ls gs://[BUCKET]
# ดูว่า bucket ขนาดเท่าไร (du: disk usage)
gsutil du -sh gs://[BUCKET]
@fonylew
fonylew / ingest_to_bq_airflow.py
Last active June 28, 2023 16:50
Simple code to ingest data from REST API (Bitcoin price from Coindesk) to BigQuery in Airflow.
import json
import requests
from airflow.models import DAG
from airflow.operators.bash_operator import BashOperator
from airflow.operators.python_operator import PythonOperator
from airflow.utils.dates import days_ago
URL = "https://api.coindesk.com/v1/bpi/currentprice/SGD.json"
DATASET_ID = "demo"
@fonylew
fonylew / performance.py
Created March 21, 2021 13:07 — forked from greenstick/performance.py
Python Class for Performance Assessment of Classification Tasks
#! /usr/bin/env python3
"""
Development Version: Python 3.5.1
Author: Benjamin Cordier
Description: Module For Performance
Assessment of Classification Task
License: BSD 3 Clause
--
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D WITH_CUDA=ON \
-D ENABLE_FAST_MATH=1 \
-D WITH_FFMPEG=ON \
-D CUDA_FAST_MATH=1 \
-D WITH_CUBLAS=1 \
-D WITH_MKL=ON \
-D MKL_USE_MULTITHREAD=ON \
# Create a new Bucket
gsutil mb gs://[BUCKET]
# List files in bucket
gsutil ls gs://[BUCKET]
# Check bucket usage (du: disk usage)
gsutil du -sh gs://[BUCKET]
# Copy (upload) file to bucket
@fonylew
fonylew / install.sh
Last active April 22, 2020 05:05
Server installation script (update April 2020)
#!/bin/bash
sudo whoami
sudo apt update
sudo apt -y upgrade
sudo apt install -y openssh-server neovim net-tools nfs-common cifs-utils
sudo apt install -y curl git python3-pip gcc cmake nmap