Skip to content

Instantly share code, notes, and snippets.

View SuperShinyEyes's full-sized avatar

Seyoung Park SuperShinyEyes

View GitHub Profile
@SuperShinyEyes
SuperShinyEyes / sources.list
Created April 28, 2021 13:10 — forked from rohitrawat/sources.list
Ubuntu 16.04 Xenial default /etc/apt/sources.list
#deb cdrom:[Ubuntu 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.2)]/ xenial main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
@SuperShinyEyes
SuperShinyEyes / gazebo.sh
Created March 29, 2021 11:18
Gazebo 9 Installation
#!/bin/sh
# Tabs are strictly needed for indentation of message
# vim: set autoindent noexpandtab ts=4 sw=4 :
set -e
# The installation script is heavy based on get.gazebo.io script
#
# Modfied by jrivero@osrfoundation.org
#!/usr/bin/env python3
import re
from typing import *
from typing import Match
import subprocess
def _nvidia_smi() -> List[str]:
'''
Example:
>>> nvidia_smi()
'''
https://youtu.be/tRsSi_sqXjI
'''
def entropy(ps: List[float]) -> float:
return np.sum([-np.log2(p) * p for p in ps])
def cross_entropy(p_trues: List[float], p_preds: List[float]) -> float:
return np.sum([-np.log2(q) * p for p, q in zip(p_trues, p_preds)])

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@SuperShinyEyes
SuperShinyEyes / f1_score.py
Created October 15, 2019 10:16
F1 score in PyTorch
def f1_loss(y_true:torch.Tensor, y_pred:torch.Tensor, is_training=False) -> torch.Tensor:
'''Calculate F1 score. Can work with gpu tensors
The original implmentation is written by Michal Haltuf on Kaggle.
Returns
-------
torch.Tensor
`ndim` == 1. 0 <= val <= 1
@SuperShinyEyes
SuperShinyEyes / convert.py
Created July 30, 2019 10:39 — forked from yokoleia/convert.py
Mass Convert MP4/AVI clips to GIF with a multithreaded Python function, using a variable to set number of threads required.
import imageio
import os, sys
import glob
import threading
import time
class TargetFormat(object):
GIF = ".gif"
MP4 = ".mp4"
AVI = ".avi"
@SuperShinyEyes
SuperShinyEyes / jupyter_essential.py
Created July 3, 2019 11:30
Add this to the very first cell of your Jupyter notebook
%reload_ext autoreload
%autoreload 2
%matplotlib inline
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
#!/usr/bin/env bash
VIDEO_PATH=$1
SRC_X="256"
SRC_Y="256"
TARGET_SIZE="512x256"
ffmpeg \
-i $VIDEO_PATH/$2 -i $VIDEO_PATH/$3 \
-filter_complex "
nullsrc=size=$TARGET_SIZE [base];
[0:v] setpts=PTS-STARTPTS, scale=$SRC_X\x$SRC_Y [left];
@SuperShinyEyes
SuperShinyEyes / .Xresources
Created June 21, 2019 14:58 — forked from liangzan/.Xresources
Xresources for configuring urxvt
! urxvt
URxvt*buffered: true
URxvt*cursorBlink: true
URxvt*underlineColor: yellow
URxvt*font: xft:inconsolata:size=10:antialias=true
URxvt*depth: 32
URxvt*borderless: 1
URxvt*scrollBar: false
URxvt*loginShell: true
Urxvt*secondaryScroll: true # Enable Shift-PageUp/Down in screen