Skip to content

Instantly share code, notes, and snippets.

function GM_addStyle(css) {
const style =
document.getElementById("GM_addStyleBy8626") ||
(function () {
const style = document.createElement("style");
style.type = "text/css";
style.id = "GM_addStyleBy8626";
document.head.appendChild(style);
return style;
})();
import abc
import os.path
import git
import numpy as np
import torch
from torch.utils.data import Dataset
from mpd.datasets.normalization import DatasetNormalizer
from mpd.utils.loading import load_params_from_yaml
@soraxas
soraxas / transparent_wrapper
Created March 21, 2024 00:28
This is a transparent wrapper that pretty much does nothing (aka it passthrough and eval all arguments). This is useful in-place of `sudo`, where you might have sudo-right (e.g. inside a container) but cannot perform `setuid` (because you are not actually sudo or using fakeroot as far as the host-machine's concern).
#!/bin/sh
requote_args() {
# Given a list of args, add quotes if necessary
C=''
for i in "$@"; do
case "$i" in
*[[:space:]]*|*'*'*) # contain space or literal astrisk
case "$i" in
*\'*) # escape single quote
@soraxas
soraxas / cascade-delete.py
Last active October 18, 2023 06:53
A script that rename recorded videos into friendly name
#!/usr/bin/env python3
import glob
import dataclasses
import subprocess
import os
import tqdm
from abc import ABC
from datetime import datetime

== Resources ==

  • A good list of resources on fairness in NLP

  • Understanding Metric: A paper about "How to evaluate LLMs":

  • [github]

@soraxas
soraxas / crop_all_sub_pictures.py
Last active September 7, 2023 03:06
Using this script on an image will crop all sub-regions that are surrounded by white pixels boarder as new images. Useful to extract all sub images, say, in a screenshot.
#!/usr/bin/env python3
from pathlib import Path
import argparse
from PIL import Image
import numpy as np
from scipy.ndimage.measurements import label
@soraxas
soraxas / cb
Last active January 7, 2024 10:24
copy to clipboard
#!/bin/sh
_scs_col="\e[0;32m"
_wrn_col='\e[1;31m'
_trn_col='\e[0;33m'
_res_col='\e[0m'
# set -x
stderr_color() {
@soraxas
soraxas / urdf
Created June 5, 2021 02:43
urdf file for j2n6s300_standalone.xacro. Created with `rosrun xacro xacro j2n6s300_standalone.xacro > model.urdf`
<?xml version="1.0"?>
<!-- =================================================================================== -->
<!-- | This document was autogenerated by xacro from j2n6s300_standalone.xacro | -->
<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | -->
<!-- =================================================================================== -->
<!-- j2n6s300 refers to jaco v2 6DOF non-spherical 3fingers -->
<robot name="j2n6s300" xmlns:body="http://playerstage.sourceforge.net/gazebo/xmlschema/#body" xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller" xmlns:gazebo="http://playerstage.sourceforge.net/gazebo/xmlschema/#gz" xmlns:geom="http://playerstage.sourceforge.net/gazebo/xmlschema/#geom" xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface" xmlns:joint="http://playerstage.sourceforge.net/gazebo/xmlschema/#joint" xmlns:model="http://playerstage.sourceforge.net/gazebo/xmlschema/#model" xmlns:physics="http:
@soraxas
soraxas / tldr.fish
Created June 5, 2020 14:47
completions:tldr completion for fish shell (one line) by searching within cached files
# This is slower, to echo everything one by one.
#
# function __fish_tldr_complete_available_pages
# for f in ~/.local/share/tldr/pages/**/*.md
# echo (string replace -r '.*/([^/]*)\.md' '$1' $f)
# end
# end
#complete -x -c tldr -a '(__fish_tldr_complete_available_pages)'
# it is faster to find everything and use a single sed command to replace it to the correct format.
@soraxas
soraxas / SurfingKeys.js
Last active November 3, 2023 21:09
SurfingKeys settings (vim keybindings for browser)
// git.io url: https://tinyurl.com/SurfingKeys-settings or https://git.io/JfXjB
// inspired by https://github.com/Foldex/surfingkeys-config/blob/master/config.js
// remove conflict with browser's history, download pannel toggle
// unmap('<Ctrl-j>');
// iunmap('<Ctrl-j>');
// vunmap('<Ctrl-j>');
// unmap('<Ctrl-h>');
// iunmap('<Ctrl-h>');
// vunmap('<Ctrl-h>');