Skip to content

Instantly share code, notes, and snippets.

Changsheng Jiang zuoyan

Block or report user

Report or block zuoyan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@zuoyan
zuoyan / sum.h
Last active Nov 3, 2016
Inexact Sum of Floating Point Numbers
View sum.h
// Returns s and e, such that s = T(a + b), and e = (a + b) - s, i.e. s + e = a
// + b exactly.
template <class T>
std::pair<T, T> AddPair(const T& a, const T& b) {
auto s = a + b;
auto b_v = s - a;
auto e = (a - (s - b_v)) + (b - b_v);
// auto a_v = s - b_v;
// auto b_r = b - b_v;
@zuoyan
zuoyan / scholar_alert_parse.py
Created Jun 8, 2016
Download all pdf files from google scholar alert emails and push them to google drive, depending on gmail_cli, google_drive_cli, pjobs and csv_sql.
View scholar_alert_parse.py
#!/bin/env/python
# coding: utf8
#
# Parse google scholar alerts email, and output a csv file.
import re
import sys
from HTMLParser import HTMLParser
import traceback
import md5
@zuoyan
zuoyan / f256.h
Last active Aug 29, 2015
F256, operations of finite field 2^8.
View f256.h
// Author: Changsheng Jiang(jiangzuoyan@gmail.com)
// Public domain.
namespace weizi {
namespace f256 {
inline unsigned char Add(unsigned char a, unsigned char b) { return a ^ b; }
inline unsigned char Sub(unsigned char a, unsigned char b) { return a ^ b; }
@zuoyan
zuoyan / build.cmake
Last active Aug 29, 2015
BUILD like functions in CMake
View build.cmake
INCLUDE(CMakeParseArguments)
FUNCTION(WEIZI_ABSOLUTE NAME OUT)
IF (${NAME} MATCHES "^/")
SET(${OUT} ${NAME} PARENT_SCOPE)
RETURN()
ENDIF()
IF ("${CMAKE_SOURCE_DIR}/weizi" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
SET(${OUT} "/${NAME}" PARENT_SCOPE)
RETURN()
View rearranged_tuple.cpp
#include <atomic>
#include <iostream>
#include <tuple>
#include "tmp.hpp" // see http://github.com/zuoyan/tmp
template <template <class ...> class F, class ...A>
struct tcurry {
template <class ...T>
struct apply {
You can’t perform that action at this time.