Skip to content

Instantly share code, notes, and snippets.

View Lmy0217's full-sized avatar
๐ŸŽฏ
Anti-996

Mingyuan Luo Lmy0217

๐ŸŽฏ
Anti-996
View GitHub Profile
@rwightman
rwightman / timm_unet.py
Created April 15, 2021 19:12
An example U-Net using timm features_only functionality.
""" A simple U-Net w/ timm backbone encoder
Based off an old version of Unet in https://github.com/qubvel/segmentation_models.pytorch
Hacked together by Ross Wightman
"""
from typing import Optional, List
import torch
@coo11
coo11 / QuickPageTurning.js
Last active July 15, 2024 02:04
้€š่ฟ‡ Chrome ๆŽงๅˆถๅฐ๏ผŒๅฟซ้€Ÿ่Žทๅ–ๆกƒๅญๅœˆ๏ผˆ http://peachring.com/ ๏ผ‰ๅพฎๅšๅฟซ็…ง้กต็ ๅœฐๅ€ใ€‚
(async () => {
let n = 1000; //Page turning times
let uid = "3139723905";
let cids = ["4208773252239704"];
let index = {};
/* http://m.peachring.com/weibo/user/3139723905/?next=${cid}
* https://m.weibo.cn/${uid}/${cid}
*/
async function getHTML(id) {
const res = await fetch(
@vadimkantorov
vadimkantorov / byteutils.py
Last active October 25, 2021 03:12
PyTorch workaround for missing frombuffer function
import torch
import ctypes
def frombuffer(bytes, dtype, byte_order = 'native'):
dtype2tensor = dict(int16 = torch.ShortTensor)
dtype2storage = dict(int16 = torch.ShortStorage)
return dtype2tensor[dtype](dtype2storage[dtype].from_buffer(bytes, byte_order = byte_order))
def tobytes(tensor):
return ctypes.cast(tensor.data_ptr(), ctypes.POINTER(ctypes.c_ubyte * (tensor.numel() * tensor.element_size()) )).contents
@rebcabin
rebcabin / kalmanSample.py
Created March 7, 2020 22:28
Kalman parameter estimation in PyTorch
import torch
import toolz
def kalman (b, # # rows, cols, in Z; # rows in z
n, # # rows, cols, in P; # rows in x
Z, # b x b observation covariance
x, # n x 1, current state
P, # n x n, current covariance
A, # b x n, current observation partials
@Lyken17
Lyken17 / deep-leakage-from-gradients.ipynb
Last active November 4, 2024 02:59
Deep Leakage from Gradients.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@philwo
philwo / README.md
Created November 11, 2019 14:18
How to build TensorFlow 2.0 on Ubuntu 18.04 (x86_64) with Bazelisk

This is how I managed to build TensorFlow 2.0 on Ubuntu 18.04 (x86_64) with Bazelisk:

$ sudo apt update
$ sudo apt full-upgrade
$ sudo apt install curl

# Install Bazelisk.
$ sudo curl -Lo /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/download/v1.1.0/bazelisk-linux-amd64
$ sudo chmod +x /usr/local/bin/bazel
@bessarabov
bessarabov / gist:674ea13c77fc8128f24b5e3f53b7f094
Last active September 2, 2025 01:50
One-liner to generate data shown in post 'At what time of day does famous programmers work?' โ€” https://ivan.bessarabov.com/blog/famous-programmers-work-time
git log --author="Linus Torvalds" --date=iso | perl -nalE 'if (/^Date:\s+[\d-]{10}\s(\d{2})/) { say $1+0 }' | sort | uniq -c|perl -MList::Util=max -nalE '$h{$F[1]} = $F[0]; }{ $m = max values %h; foreach (0..23) { $h{$_} = 0 if not exists $h{$_} } foreach (sort {$a <=> $b } keys %h) { say sprintf "%02d - %4d %s", $_, $h{$_}, "*"x ($h{$_} / $m * 50); }'
@vladalive
vladalive / gdrive_download.md
Created May 16, 2019 14:38
Download Google Drive files from linux terminal via wget

Setup:

  1. Add this code to your ~/.bash_aliases file.
function gdrive_download () {
  CONFIRM=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate "https://docs.google.com/uc?export=download&id=$1" -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')
  wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$CONFIRM&id=$1" -O $2
  rm -rf /tmp/cookies.txt
}
@y0ngb1n
y0ngb1n / docker-registry-mirrors.md
Last active February 11, 2026 06:36
ๅ›ฝๅ†…็š„ Docker Hub ้•œๅƒๅŠ ้€Ÿๅ™จ๏ผŒ็”ฑๅ›ฝๅ†…ๆ•™่‚ฒๆœบๆž„ไธŽๅ„ๅคงไบ‘ๆœๅŠกๅ•†ๆไพ›็š„้•œๅƒๅŠ ้€ŸๆœๅŠก | Dockerized ๅฎž่ทต https://github.com/y0ngb1n/dockerized

Docker Hub ้•œๅƒๅŠ ้€Ÿๅ™จ

ๅ›ฝๅ†…ไปŽ Docker Hub ๆ‹‰ๅ–้•œๅƒๆœ‰ๆ—ถไผš้‡ๅˆฐๅ›ฐ้šพ๏ผŒๆญคๆ—ถๅฏไปฅ้…็ฝฎ้•œๅƒๅŠ ้€Ÿๅ™จใ€‚

Dockerized ๅฎž่ทต https://github.com/y0ngb1n/dockerized

1๏ธโƒฃ Docker daemon ้…็ฝฎไปฃ็†๏ผˆๆŽจ่๏ผ‰

ๅ‚่€ƒ Docker daemon ้…็ฝฎไปฃ็†

@dojoteef
dojoteef / profile.py
Last active April 8, 2025 07:50
A CUDA memory profiler for pytorch
'''
Memory profiling utilities
'''
import gc
import inspect
import linecache
import os.path
import sys
import time
import threading