Skip to content

Instantly share code, notes, and snippets.

View hsfzxjy's full-sized avatar
💻
Hacking

Xie Jingyi hsfzxjy

💻
Hacking
View GitHub Profile
@hsfzxjy
hsfzxjy / metrics.plugin.activity.svg
Last active August 22, 2023 03:54
Metrics Render
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from math import ceil, sqrt
def isprime(n):
for x in range(2, ceil(sqrt(n + 1))):
if n % x == 0:
return False
return True
@hsfzxjy
hsfzxjy / deferred.rs
Created March 29, 2022 15:42
Rust Deferred
pub mod sync {
use crate::prelude::*;
use std::ops::{Deref, DerefMut};
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
pub enum DeferredState {
Created,
Pending,
Resolved,
Rejected,
@hsfzxjy
hsfzxjy / weighted_upsampling.py
Last active July 25, 2019 11:19
Weighted Upsampling
import torch
import torch.nn.functional as F
import numpy as np
def _grid(in_w, in_h, out_w, out_h, x_coerce,y_coerce):
result = np.zeros((out_h, out_w, 2), dtype=np.float64)
for j in range(out_h):
for i in range(out_w):
if i * (in_w - 1) % (out_w - 1) == 0:
tx = i * 2.0 / (out_w - 1) - 1
@hsfzxjy
hsfzxjy / gdl.sh
Created May 15, 2019 15:36
Download large file from google-drive using terminal only.
# Usage: gdl <URL> <OUTPUT>
function gdl() {
URL=$1
tmp_file=$(mktemp)
code=$(wget --save-cookies $tmp_file --keep-session-cookies --no-check-certificate $URL -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1/p')
echo $code
URL+="&confirm=$code"
wget --load-cookies $tmp_file $URL -O $2
rm $tmp_file
}
@hsfzxjy
hsfzxjy / reranking.py
Created May 2, 2019 05:37
Re-Ranking Technique Used By PCB
"""
Created on Mon Jun 26 14:46:56 2017
@author: luohao
Modified by Houjing Huang, 2017-12-22.
- This version accepts distance matrix instead of raw features.
- The difference of `/` division between python 2 and 3 is handled.
- numpy.float16 is replaced by numpy.float32 for numerical precision.
"""
"""