Skip to content

Instantly share code, notes, and snippets.

@xiaoli
xiaoli / Setup_Huggingface_Transformers_on_Macbook_Air_M1.txt
Last active June 20, 2023 03:00
Installation of Huggingface Transformers on Macbook Air M1
```sh
conda create --name transformers python=3.11
conda activate transformers
conda install pytorch::pytorch torchvision torchaudio -c pytorch
pip install git+https://github.com/huggingface/accelerate
pip install git+https://github.com/huggingface/transformers
git clone https://github.com/huggingface/transformers.git
cd transformers/examples/pytorch/token-classification
@xiaoli
xiaoli / bdd100k_labels_filter_of_timeofday.py
Created June 10, 2023 13:30
Filtering bdd100k dataset by timeofday attribute
import json
def filter_train():
data = []
with open('bdd100k_labels/bdd100k_labels_images_train.json') as f:
train = json.load(f)
for image in train:
if image['attributes']['timeofday'] == 'daytime':
data.append(image)
@xiaoli
xiaoli / install_graph-cut-ransac_on_ubuntu_22.04.02_LTS.md
Last active May 12, 2023 04:38
Install Graph-Cut RANSAC on Ubuntu 22.04.2 LTS
@xiaoli
xiaoli / ubuntu_22.04.1_LTS_for_deep_learning.md
Last active May 14, 2024 14:40
Ubuntu 22.04.1 LTS for Deep Learning

Ubuntu 22.04.1 LTS for Deep Learning

This gist contains steps to setup Ubuntu 22.04.1 LTS for deep learning.


Install Ubuntu 22.04.1 LTS

  • Computer name: Name-PC
  • Name: Name
@xiaoli
xiaoli / zhihu_unfollow.js
Created September 28, 2022 09:59
Zhihu Unfollow Script
function unfollow() {
setTimeout(function() {
console.log('unfollowed');
let list = document.querySelectorAll('.FollowButton');
console.log(list);
for (i = 0; i < list.length; i++) {
list[i].click();
}
unfollow();
}, 3000);
@xiaoli
xiaoli / SwiftUI-TextView.swift
Last active September 19, 2020 08:52 — forked from shaps80/SwiftUI-TextView.md
A SwiftUI view that wraps a UITextView but provides almost all functionality though modifiers and attempts to closely match the Text/TextField components.
/*
Notes:
The font modifier requires the following gist:
https://gist.github.com/shaps80/2d21b2ab92ea4fddd7b545d77a47024b
*/
@xiaoli
xiaoli / AutoProxy.ahk
Last active February 9, 2018 12:30
Http Proxy Enable/Disable Script
Gui, Add, Button, x46 y20 w100 h30 Gon , Proxy ON
Gui, Add, Button, x46 y60 w100 h30 Goff , Proxy OFF
Gui, Add, Button, x46 y100 w100 h30 Ggtfo , Exit
; Generated using SmartGUI Creator 4.0
Gui, Show, x129 y99 h146 w194, Proxy Status
Return
on:
setproxy("ON", "127.0.0.1:1080")
return
@xiaoli
xiaoli / Ping.cs
Last active September 15, 2017 02:58 — forked from Mailaender/Ping.cs
Ping a host and calculate packet loss.
void GetNetworkStats(string host, int pingAmount, int timeout, out int averagePing, out int packetLoss)
{
Ping pingSender = new Ping();
PingOptions options = new PingOptions(); // default is: don't fragment and 128 Time-to-Live
string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
byte[] buffer = Encoding.ASCII.GetBytes(data); // 32 bytes of data
var failedPings = 0;
var latencySum = 0;
@xiaoli
xiaoli / video_player.c
Last active October 5, 2022 04:07
Simple Video Player for FreeScale IMX53 QSB on Debian Wheezy Without X11
#include <gst/gst.h>
#include <glib.h>
#include <string.h>
// Compile command:
// gcc -Wall $(pkg-config --cflags --libs gstreamer-0.10) test.c -o test
// Gstreamer test:
// gst-launch filesrc location=<your video file> typefind=true ! aiurdemux name=demux demux. ! queue max-size-buffers=0 max-size-time=0 ! mfw_vpudecoder ! autovideosink demux. ! queue ! mfw_aacdecoder ! autoaudiosink