Skip to content

Instantly share code, notes, and snippets.

View zhouyuan's full-sized avatar

Yuan zhouyuan

View GitHub Profile
@kennyz
kennyz / kongwu_pi_tips.md
Last active December 25, 2021 12:41
kongwu pi tips

折腾Pi,解决疑难杂症最好还是去官网论坛

image http://www.raspberrypi.org/phpBB3/

支持Apple TimeMachine,实现Mac备份

在磁盘中创建备份目录 mkdir /media/usbdisk/mactimebak 推荐使用ext4分区(打开notime)

安装nettalk

@magnetikonline
magnetikonline / README.md
Last active December 14, 2023 06:45
Nginx FastCGI cache configuration example.

Nginx FastCGI cache

Example /etc/nginx/nginx.conf using FastCGI (e.g. to PHP-FPM) with FastCGI cache enabled. This will capture returned data and persist it to a disk based cache store for a configurable amount of time, great for robust full page caching.

Will need to create a directory to hold cache files, for the example given here that would be:

$ sudo mkdir -p /var/cache/nginxfastcgi
$ chown www-data: /var/cache/nginxfastcgi
@clayg
clayg / slo.py
Created June 11, 2014 22:52
upload a static large object
import sys
from hashlib import md5
from swiftclient.client import get_auth, put_container, put_object
from swift.common.utils import json
def write_part(url, token, container, i):
body = 'VERIFY%0.2d' % i + '\x00' * 1048576
part_name = 'manifest_part_%0.2d' % i
import time
import os
import uuid
import random
from swift.container.backend import ContainerBroker
from swift.common.utils import normalize_timestamp
INSERT_COUNT = 200
@josiahcarlson
josiahcarlson / rate_limit2.py
Last active April 17, 2022 09:22
Regular and sliding window rate limiting to accompany two blog posts.
'''
rate_limit2.py
Copyright 2014, Josiah Carlson - josiah.carlson@gmail.com
Released under the MIT license
This module intends to show how to perform standard and sliding-window rate
limits as a companion to the two articles posted on Binpress entitled
"Introduction to rate limiting with Redis", parts 1 and 2:
@smerritt
smerritt / bench-xattr.py
Created December 5, 2014 22:11
benchmarking different xattr sizes on XFS on a spinning disk
#!/usr/bin/env python
import benchmark
import cPickle as pickle
import hashlib
import os
import xattr
PILE_O_METADATA = pickle.dumps(dict(
("attribute%d" % i, hashlib.sha512("thingy %d" % i).hexdigest())
@benjaminbarbe
benjaminbarbe / README.md
Last active September 18, 2023 17:29 — forked from raucao/nginx-lua-s3.nginxconf
Nginx proxy to S3 with caching

Listpack specification

Version 1.0, 1 Feb 2017: Intial specification.

Version 1.1, 2 Feb 2017: Integer encoding simplified. Appendix A added.

Version 1.2, 3 Feb 2017: Better specify the meaning of the num-elements
                         field with value of 65535. The two 12 bits

positive/negative integers encodings were

A Tour of PyTorch Internals (Part I)

The fundamental unit in PyTorch is the Tensor. This post will serve as an overview for how we implement Tensors in PyTorch, such that the user can interact with it from the Python shell. In particular, we want to answer four main questions:

  1. How does PyTorch extend the Python interpreter to define a Tensor type that can be manipulated from Python code?
  2. How does PyTorch wrap the C libraries that actually define the Tensor's properties and methods?
  3. How does PyTorch cwrap work to generate code for Tensor methods?
  4. How does PyTorch's build system take all of these components to compile and generate a workable application?

Extending the Python Interpreter

PyTorch defines a new package torch. In this post we will consider the ._C module. This module is known as an "extension module" - a Python module written in C. Such modules allow us to define new built-in object types (e.g. the Tensor) and to call C/C++ functions.

@stgatilov
stgatilov / gen.cpp
Created August 2, 2017 16:12
Vectorizing std::merge with vpermd from AVX2 and lookup table
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <assert.h>
#include <stdint.h>
#include <algorithm>
#include <vector>
//======================== Perfect hash generator =========================