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 / ingest_to_bq_airflow.py
Last active September 13, 2024 17:25
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
@fonylew
fonylew / docker-run.sh
Created April 18, 2020 17:36
RStudio Docker run command
docker run -d --name rstudio -p [TARGET_PORT]:8787 -v $(pwd):/home/[USER]/[MOUNT_DIR] --restart=always -e ROOT=TRUE -e USER=[USER] -e PASSWORD=[PASSWORD] rocker/rstudio
@fonylew
fonylew / install_python3.7.sh
Created March 6, 2020 12:27
Install Python 3.7 (Ubuntu 18.04)
sudo apt install python3.7
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1
@fonylew
fonylew / .bash_aliases
Created February 27, 2020 07:55
Bash Password Generator
function gen_pass(){
default_len=13
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-${1:-$default_len}};echo;
## OpenSSL random (alternatives: base64)
#openssl rand -base64 ${1:-$default_len} | colrm 17
}
@fonylew
fonylew / README.md
Last active March 6, 2020 11:41
Common Python Problem

Common Python Problems and Solutions

pip3 is broken

Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
ImportError: cannot import name 'main'

Solution: sudo python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall Ref: pypa/pip#5447 (comment)

@fonylew
fonylew / install-local-server.sh
Last active August 31, 2023 12:50
A bunch of script to install Nvidia with CUDA10, CUDNN 7.4 and so on.
#!/bin/bash
# First sudo command
sudo whoami
# Update and upgrade
sudo apt update
sudo apt upgrade -y
# Utility