Skip to content

Instantly share code, notes, and snippets.

View KinglittleQ's full-sized avatar
🍦

Chengqi Deng KinglittleQ

🍦
  • Zhejiang University
  • hangzhou
View GitHub Profile
@michimani
michimani / count-github-stargazers.py
Last active January 2, 2022 13:33
Count GitHub stargazers. Execute `python3 count-github-stargazers.py github_user_name` . ⚠️tested with only Python 3.7.5
from time import sleep
from urllib.request import Request, urlopen
import argparse
import json
import traceback
GITHUB_REPOS_API = 'https://api.github.com/users/{user_name}/repos?per_page=100&page={page}'
PRINT_LINE = '{repo_name: <40}:{star_cnt: >6}'
p = argparse.ArgumentParser()
@thomwolf
thomwolf / gpt-2-wikitext-103.py
Last active December 3, 2025 07:57
A very small and self-contained gist to train a GPT-2 transformer model on wikitext-103
# Copyright (c) 2019-present, Thomas Wolf.
# All rights reserved. This source code is licensed under the MIT-style license.
""" A very small and self-contained gist to train a GPT-2 transformer model on wikitext-103 """
import os
from collections import namedtuple
from tqdm import tqdm
import torch
import torch.nn as nn
from torch.utils.data import DataLoader
from ignite.engine import Engine, Events
@wangz10
wangz10 / pca_eigen_docomposition_np.py
Created March 16, 2019 14:25
Perform PCA by eigen decomposition
def pca(X):
# Data matrix X, assumes 0-centered
n, m = X.shape
assert np.allclose(X.mean(axis=0), np.zeros(m))
# Compute covariance matrix
C = np.dot(X.T, X) / (n-1)
# Eigen decomposition
eigen_vals, eigen_vecs = np.linalg.eig(C)
# Project X onto PC space
X_pca = np.dot(X, eigen_vecs)
@pcmid
pcmid / BaiduPCS-appid-getter.py
Created September 20, 2018 06:44
获取有效的百度app_id
from __future__ import print_function
import requests
import threading
import sys
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
@yjzhang
yjzhang / k_means.py
Last active February 9, 2024 21:04
basic python implementation of k-means and online k-means clustering
# Online k-means algorithm
# see http://www.cs.princeton.edu/courses/archive/fall08/cos436/Duda/C/sk_means.htm
import numpy as np
def k_means(data, k, threshhold=2):
"""
Does k-means clustering of the data.
Args:
@loufranco
loufranco / make3d.py
Created July 17, 2017 12:41
A Python script to make red/cyan 3D photos
from PIL import Image
import sys
# Check arguments
if len(sys.argv) < 3:
print "Usage: python make3d.py <leftimage> <rightimage> <3doutputname>"
quit()
# Open the left and right images
imLeft = Image.open(sys.argv[1])
^
| 7
| /
|/
+----------->
or
7 Z-axis
@bluethon
bluethon / git_proxy_socks5.sh
Created January 18, 2017 08:25
设置git使用socks5代理
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
ffmpeg -i data/video.mp4 -vcodec h264 -b:v 1000k -acodec mp2 data/output.mp4
@jonhoo
jonhoo / go-test-many.sh
Last active April 20, 2025 03:54
Script for running go tests many times in parallel, printing the current status, and logging errors
#!/bin/bash
#
# Script for running `go test` a bunch of times, in parallel, storing the test
# output as you go, and showing a nice status output telling you how you're
# doing.
#
# Normally, you should be able to execute this script with
#
# ./go-test-many.sh
#