Skip to content

Instantly share code, notes, and snippets.

View sailfish009's full-sized avatar

sailfish009

  • freelancer
  • South Korea
View GitHub Profile
1. What do I want? Not what others want.
2. What am I avoiding.
3. What am I the most great full for?
4. What am I afraid of?
5. What are my biggest strengths and flaws?
@sailfish009
sailfish009 / streamlit_download_button.py
Created February 23, 2021 06:48 — forked from chad-m/streamlit_download_button.py
A download function and examples app for Streamlit
import base64
import os
import json
import pickle
import uuid
import re
import streamlit as st
import pandas as pd
@sailfish009
sailfish009 / color-scale.js
Created February 2, 2021 14:33 — forked from mlocati/color-scale.js
Javascript color scale from 0% to 100%, rendering it from red to yellow to green
function perc2color(perc) {
var r, g, b = 0;
if(perc < 50) {
r = 255;
g = Math.round(5.1 * perc);
}
else {
g = 255;
r = Math.round(510 - 5.10 * perc);
}
https://stackoverflow.com/questions/10825926/python-3-x-rounding-behavior
>>> decimal.Decimal('3.5').quantize(decimal.Decimal('1'), rounding=decimal.ROUND_HALF_UP)
Decimal('4')
>>> decimal.Decimal('2.5').quantize(decimal.Decimal('1'), rounding=decimal.ROUND_HALF_EVEN)
Decimal('2')
>>> decimal.Decimal('3.5').quantize(decimal.Decimal('1'), rounding=decimal.ROUND_HALF_DOWN)
Decimal('3')
def myprint(msg):
print(msg, file=open("log.txt", "a"))
@sailfish009
sailfish009 / python_print_file.txt
Created December 2, 2020 14:39
Writing to a File with Python's print() Function
# https://stackabuse.com/writing-to-a-file-with-pythons-print-function/
import sys
print('This message will be displayed on the screen.')
original_stdout = sys.stdout # Save a reference to the original standard output
with open('filename.txt', 'w') as f:
sys.stdout = f # Change the standard output to the file we created.
@sailfish009
sailfish009 / installing_nvidia_driver_cuda_cudnn_linux.md
Created December 1, 2020 01:12 — forked from kmhofmann/installing_nvidia_driver_cuda_cudnn_linux.md
Installing the NVIDIA driver, CUDA and cuDNN on Linux

Installing the NVIDIA driver, CUDA and cuDNN on Linux (Ubuntu 20.04)

This is a companion piece to my instructions on building TensorFlow from source. In particular, the aim is to install the following pieces of software

on an Ubuntu Linux system, in particular Ubuntu 20.04.

@sailfish009
sailfish009 / .tmux.conf
Last active November 29, 2020 14:01
tmux with mouse scroll (for v2.x)
# Make mouse useful in copy mode
setw -g mouse on
# make scrolling with wheels work
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M
# Allow xterm titles in terminal window, terminal scrolling with scrollbar, and setting overrides of C-Up, C-Down, C-Left, C-Right
# (commented out because it disables cursor navigation in vim)
#set -g terminal-overrides "xterm*:XT:smcup@:rmcup@:kUP5=\eOA:kDN5=\eOB:kLFT5=\eOD:kRIT5=\eOC"
@sailfish009
sailfish009 / stratified_sample.py
Created November 22, 2020 15:26 — forked from srikarplus/stratified_sample.py
Stratified Sampling in Pytorch
def make_weights_for_balanced_classes(images, nclasses):
count = [0] * nclasses
for item in images:
count[item[1]] += 1
weight_per_class = [0.] * nclasses
N = float(sum(count))
for i in range(nclasses):
weight_per_class[i] = N/float(count[i])
weight = [0] * len(images)
for idx, val in enumerate(images):
https://github.com/nodejs/node/blob/master/BUILDING.md#unix-prerequisites