Skip to content

Instantly share code, notes, and snippets.

View nro-bot's full-sized avatar

nro-bot

View GitHub Profile
@nro-bot
nro-bot / README.md
Last active October 20, 2022 00:33
benchmark_distilbert_simpletransformers

pip install simpletransformers pip uninstall torch, then run latest install script from pytorch.org

environment variables:

$ PORCH_N=100_000 PORCH_CUDA=True python bmark_distil.py

@nro-bot
nro-bot / chloropleth_with_popup_tooltips.py
Created May 3, 2022 02:07
Creating folium map with tooltips (way more difficult than it should be)
# Creating chloropleth with colors scaled to a dataframe is super easy,
# but if you want to add the exact values as a tooltip,
# Have to do it by editing the json that defines the boundaries of the states !
# Quite complicated / annoying if unfamiliar with GeoJSON format.
state_abbr = simplejson.load(open('us_state_capitals.json'))
state_abbr = pd.DataFrame(state_abbr).transpose().reset_index().rename(
columns={'index':'abbr'}
)
# Other possibilities
# e.g. Used for RG2 gripper
def olmia():
#force0 = 5
#width0 = 0
#force1 = 5
#width1 = 1100
#force2 = 40
#width2 = 0
@nro-bot
nro-bot / minimal_arucotag.py
Created April 25, 2020 05:05
Read arucotag using opencv in python, convert to euler angle, print to shell and write to file
'''
Date: 24 April 2020
Author: nouyang
Example for reading (multiple) aruco tag.
The code outputs pose estimate to the shell (or to the file).
Motivation: The openCV documentation is oriented at C++, so it may be difficult to
translate to Python. This is a simple example that reads multiple tags, converts
rotation to Euler, and prints to the commandline. I also explain how to obtain camera
@nro-bot
nro-bot / vtt2text.py
Created April 7, 2020 05:04 — forked from glasslion/vtt2text.py
This script convert youtube subtitle file(vtt) to plain text.
"""
Convert YouTube subtitles(vtt) to human readable text.
Download only subtitles from YouTube with youtube-dl:
youtube-dl --skip-download --convert-subs vtt <video_url>
Note that default subtitle format provided by YouTube is ass, which is hard
to process with simple regex. Luckily youtube-dl can convert ass to vtt, which
is easier to process.
@nro-bot
nro-bot / terminalTimer.sh
Last active July 24, 2019 21:37 — forked from tir38/terminalTimer.sh
in-terminal timer shell script
# script to create timer in terminal
# Jason Atwood
# 2013/6/22
# Nouyang -- added large font, send-notify popup, gnome-terminal resize, and play wav file
# 2019
#!/bin/sh
# start up
#echo "starting timer script ..."
@nro-bot
nro-bot / 2019-01-30 20:34:12_arucotagData.csv
Created March 5, 2019 00:41
Files for 6-axis force torque sensor
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 5 columns, instead of 4 in line 2.
Arucotag time, tag1 xyz, tag2 xyz, tag1 rollpitchyaw (xyz), tag2 -- xyz zerod averaged; 1.4325604438781738; -0.04961893824233008; -0.05359939423137295; -0.04982387644324944; -0.05038360130221645; -0.04640478914072482; -0.050179964932310084; 2.8118697239913235; -8.772199918827821; -9.82776223299835; 2.7892837261660275; 9.890234153377573; -14.972194520722148; -0.05000126977227327; -0.05000209168604888; -0.05000192068777976; 2.8005767250786757; 0.5590171172748759; -12.399978376860249
Arucotag time, tag1 xyz, tag2 xyz, tag1 rollpitchyaw (xyz), tag2 -- xyz zerod averaged; 1.4791462421417236; -0.04959811047099668; -0.053596665003502485; -0.04976573979042518; -0.05038360130221645; -0.04640478914072482; -0.050179964932310084; 4.738171612374154; -15.070717763088878; -22.51421969502433; 4.756004713612519; 15.445164648243166; -30.858389788111364; -0.04999085588660657; -0.05000072707211366; -0.04997285236136763; 4.747088162993337; 0.18722344257714418; -26.686304741567845
Arucotag time, tag1 xyz, tag2 xyz, tag1 rollpitchy
@nro-bot
nro-bot / test.sh
Created January 31, 2019 22:34
thinkpad nub (trackpoint) settings
# https://askubuntu.com/questions/37824/what-is-the-best-way-to-configure-a-thinkpads-trackpoint
echo 200 | sudo tee /sys/devices/platform/i8042/serio1/serio2/sensitivity
echo 200 | sudo tee /sys/devices/platform/i8042/serio1/serio2/speed
@nro-bot
nro-bot / fill_pdfrw2.py
Last active January 2, 2019 21:58
sign pdf on ubuntu while retaining fillable fields (using python)
#! /usr/bin/python
import os
import pdfrw
INVOICE_TEMPLATE_PATH = 'delay.pdf'
INVOICE_OUTPUT_PATH = 'delay_pdfrw2.pdf'
@nro-bot
nro-bot / Commands
Last active January 3, 2019 01:19
Ubuntu 18.10 on Thinkapd X1 Yoga Gen 2
* Brightness keys don't work. Instead
rui@chaiX1YG2:~$ xrandr --output eDP-1 --brightness 0.8
As a temp solutions, I created keyboard shortcuts for 0.8 (super-f6) and 0.3 (supers-f5) settings, using
gnome-terminal -e "sh \home\rui\brightdown.sh" (may require chmod +x)
Via the settings GUI -> add a custom shortcut
* Suspend doesn't seem to work
systemctl suspend -i