Skip to content

Instantly share code, notes, and snippets.

View tanjuntao's full-sized avatar
🐍
working on RAG now

Juntao Tan tanjuntao

🐍
working on RAG now
  • USTC
  • Hefei, Anhui, China.
  • 01:44 (UTC +08:00)
  • LinkedIn in/tanjuntao
View GitHub Profile
@zed
zed / cydot.pyx
Created March 16, 2012 18:25
Naive O(N**3) 2D np.dot() multithreaded implementation (CPython extension in Cython)
#cython: boundscheck=False, wraparound=False
import numpy as np
cimport numpy as np
from cython.parallel cimport prange
def dot(np.ndarray[np.float32_t, ndim=2] a not None,
np.ndarray[np.float32_t, ndim=2] b not None,
np.ndarray[np.float32_t, ndim=2] out=None):
"""Naive O(N**3) 2D np.dot() implementation."""
@turbo
turbo / std.md
Last active June 24, 2024 03:00
Git Commit Message Standard

Merged from https://github.com/joelparkerhenderson/git_commit_message and https://chris.beams.io/posts/git-commit/

General Rules

  • Commit messages must have a subject line and may have body copy. These must be separated by a blank line.
  • The subject line must not exceed 50 characters
  • The subject line should be capitalized and must not end in a period
  • The subject line must be written in imperative mood (Fix, not Fixed / Fixes etc.)
  • The body copy must be wrapped at 72 columns
  • The body copy must only contain explanations as to what and why, never how. The latter belongs in documentation and implementation.
@huklee
huklee / MyLogger.py
Last active January 6, 2024 18:06
python Logger using example with Singleton Pattern
# -*- coding: utf-8 -*-
import logging
import os
import datetime
import time
class SingletonType(type):
_instances = {}
@weiaicunzai
weiaicunzai / accuracy.py
Created June 22, 2018 13:20
compute top1, top5 error using pytorch
from __future__ import print_function, absolute_import
__all__ = ['accuracy']
def accuracy(output, target, topk=(1,)):
"""Computes the precision@k for the specified values of k"""
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
@marshalhayes
marshalhayes / README.md
Last active July 3, 2024 12:33
TLS encryption of Python sockets using the "SSL" module

README.md

Follow these steps before trying to run any code.

  1. First, generate a Certificate Authority (CA).

openssl genrsa -out rootCA.key 2048

  1. Second, self-sign it.
@y0ngb1n
y0ngb1n / docker-registry-mirrors.md
Last active July 16, 2024 17:06
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized
@Lyken17
Lyken17 / deep-leakage-from-gradients.ipynb
Last active April 9, 2024 11:51
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.
@Kautenja
Kautenja / sftp_pandas.py
Last active January 6, 2023 04:39
Functions for working with remote files using pandas and paramiko (SFTP/SSH).
"""Functions for working with remote files using pandas and paramiko (SFTP/SSH)."""
import pandas as pd
import paramiko
def read_csv_sftp(hostname: str, username: str, remotepath: str, *args, **kwargs) -> pd.DataFrame:
"""
Read a file from a remote host using SFTP over SSH.
Args: