Skip to content

Instantly share code, notes, and snippets.

View chaelim's full-sized avatar

C.S. Lim chaelim

View GitHub Profile
@davedice
davedice / InflatableSeqLock.cpp
Last active January 17, 2021 00:53
Inflatable SeqLock
// InflatableSeqLock
// Copyright(C) 2016 Oracle and/or its affiliates
// Dave Dice : https://blogs.oracle.com/dave
//
// Remarks:
// * Implements composite writer mutex and seqlock in a single word-sized lock.
// Allows optimistic reading and pessimistic writing.
// Readers don't write to shared synchronization metadata, which helps avoid
// coherence traffic. Readers must tolerate observing inconsistent state, however.
// * Writer mutex is based on LIFO-CR lock from http://arxiv.org/abs/1511.06035.
// Build: g++ -O3 -std=gnu++14 -m64 MonoTime.cc -lpthread -o MonoTime -mmemory-model=tso
//
// Dave Dice -- blogs.oracle.com/dave
#include <thread>
#include <chrono>
#include <iostream>
#include <vector>
#include <mutex>
#include <random>
@lefticus
lefticus / iife.cpp
Last active July 13, 2021 15:01
Immediately-invoked Function Expressions in C++
#include <chrono>
#include <string>
#include <sstream>
#include <vector>
#include <iostream>
std::string to_string(const int i)
{
std::stringstream ss;
ss << i;
@preshing
preshing / capped_spsc_queue.cpp
Created October 23, 2014 00:13
Generate benchmarks for three implementations of a wait-free queue using C++11 atomics
//
// Generate benchmarks for the three queue implementations shown in
// Jeff Preshing's CppCon 2014 talk, "How Ubisoft Montreal Develops Games for
// Multicore - Before and After C++11".
//
// Slides: https://github.com/CppCon/CppCon2014/blob/master/Presentations/How%20Ubisoft%20Montreal%20Develops%20Games%20for%20Multicore/How%20Ubisoft%20Montreal%20Develops%20Games%20for%20Multicore%20-%20Before%20and%20After%20C++11%20-%20Jeff%20Preshing%20-%20CppCon%202014.pdf?raw=true
//
#include <iostream>
#include <atomic>
@staltz
staltz / introrx.md
Last active November 17, 2024 01:08
The introduction to Reactive Programming you've been missing

Plaintext 8 threads

Connections: 8		Haywire		Requests/sec:  57334.75
Connections: 8		Go		    Requests/sec:  42901.57
-------------------------------------------------------
Connections: 16		Haywire		Requests/sec:  71460.01
Connections: 16		Go		    Requests/sec:  71891.07
-------------------------------------------------------
Connections: 32		Haywire		Requests/sec:  78421.15
Connections: 32		Go		    Requests/sec:  89202.96

@ib-lundgren
ib-lundgren / github_flask_oauth2.py
Created September 10, 2013 10:53
Example of how to use Flask with requests-oauthlib to fetch a GitHub user profile using an OAuth 2 token.
from requests_oauthlib import OAuth2Session
from flask import Flask, request, redirect, session, url_for
from flask.json import jsonify
import os
app = Flask(__name__)
# This information is obtained upon registration of a new GitHub
client_id = "<your client key>"
------- data ------ --------------------- load -------------------- - child -
keys mem clients blocked requests connections
577999 113.36M 1 0 0 (+0) 1
748999 138.92M 1 0 1 (+0) 1
922999 169.01M 1 0 2 (+1) 1
1076999 211.63M 1 0 3 (+1) 1
1216999 235.84M 1 0 4 (+1) 1
1366999 253.78M 1 0 5 (+1) 1
1520999 280.39M 1 0 6 (+1) 1
1675999 307.18M 1 0 7 (+1) 1
@j3tm0t0
j3tm0t0 / Upload2Glacier.ps1
Created August 21, 2012 09:11
Upload a file to Glacier PowerShell script version
Add-Type -Path "C:\Program Files (x86)\AWS SDK for .NET\bin\AWSSDK.dll"
$region="ap-northeast-1"
$accesskey="ACCESSKEY"
$secretkey="SECRETKEY"
$vaultname="myvault"
$description="some binary file"
$file="c:\hoge\target.bin"
$endpoint = [Amazon.RegionEndpoint]::GetBySystemName($region)