Skip to content

Instantly share code, notes, and snippets.

View ppLorins's full-sized avatar
🎯
Focusing

arthur ppLorins

🎯
Focusing
  • Tencent
  • ShenZhen,China
View GitHub Profile
@ppLorins
ppLorins / nanosecond.cc
Last active November 25, 2018 10:17
A std::chrono::nanoseconds issue found under MSVC.
#include <stdio>
#include <chrono>
/* Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x86 */
int main(int argc, char** argv)
{
//auto _nano = std::chrono::nanoseconds(3 * 1000 * 1000 * 1000); //wrong
auto _nano = std::chrono::duration<uint32_t, std::ratio<1, 1000000000>>(3 * 1000 * 1000 * 1000); //right
@ppLorins
ppLorins / sample.py
Created May 31, 2018 07:22
demonstrate a pdfrw problem
import os
import pdfrw
INVOICE_TEMPLATE_PATH = 'sample-template.pdf'
INVOICE_OUTPUT_PATH = 'sample-output.pdf'
ANNOT_KEY = '/Annots'
ANNOT_FIELD_KEY = '/T'
ANNOT_VAL_KEY = '/V'
ANNOT_RECT_KEY = '/Rect'
@ppLorins
ppLorins / shared_mutex.hpp
Created May 10, 2018 13:26
boost::shared_mutex
class upgrade_mutex
{
typedef boost::mutex mutex_t;
typedef boost::condition_variable cond_t;
typedef unsigned count_t;
mutex_t mut_;
cond_t gate1_;
cond_t gate2_;
count_t state_;