This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE PackageImports #-} | |
module RandomStr6 where | |
-- Uses `crypto-api` package, but with `newGenIO` rather than | |
-- `newGen`; doesn't result in "*** Exception: NeedsInfiniteSeed" | |
-- | |
-- extension `PackageImports` is needed because `Crypto.Random` | |
-- appears in `crypto-api`, `crypto-random`, and `cryptonite` | |
-- packages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RandomStr7 where | |
-- Couple more random token generators based on `random` package. | |
-- Do `:set +s` in ghci for quick timing checks. | |
import Control.DeepSeq (force) | |
import Control.Monad (replicateM, (>=>)) | |
import Data.List (nub) | |
import Data.Text (Text, pack) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <thread> | |
#include <mutex> | |
#include <chrono> | |
#include <cstdlib> | |
std::mutex g_mutex; | |
void runner(int tid) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <chrono> | |
#include <cstdlib> | |
#include <iostream> | |
#include <list> | |
#include <mutex> | |
#include <sstream> | |
#include <thread> | |
static std::mutex g_mutex; | |
static const int NUM_THREADS = 10; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <chrono> | |
#include <iostream> | |
#include <list> | |
#include <mutex> | |
#include <random> | |
#include <sstream> | |
#include <thread> | |
static std::mutex g_mutex; | |
static const int NUM_THREADS = 10; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <uuid/uuid.h> | |
// This builds fine on both GNU/Linux (g++ 4.8, util-linux 2.23.2-33) | |
// and macOS Sierra (clang-800.0.42.1). | |
// | |
// On GNU/Linux, libuuid is provided by util-linux; macOS seems to be | |
// shipping things from e2fsprogs. | |
// | |
// No need of passing -luuid flag on macOS though. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <uuid/uuid.h> | |
int main() | |
{ | |
std::vector<std::string> uuids; | |
static const int BIGNUM = 1000; | |
for (auto i = 0; i < BIGNUM; ++i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cassert> | |
#include <getopt.h> | |
#include <unistd.h> | |
#include <libmount/libmount.h> | |
#define _PATH_PROC_MOUNTINFO "/proc/self/mountinfo" | |
#define _PATH_PROC_MOUNTS "/proc/mounts" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
URL = https://www.kernel.org/pub/linux/utils/util-linux/v2.27/util-linux-2.27.tar.xz | |
LIBPATH = /tmp/util-linux-install | |
CXXFLAGS += -Wall -ggdb -std=c++11 | |
CPPFLAGS += -I$(LIBPATH)/include | |
LIBMOUNT := $(LIBPATH)/lib/libmount.a | |
LIBBLKID := $(LIBPATH)/lib/libblkid.a | |
PROGRAM = mounts-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdexcept> | |
#include <getopt.h> | |
#include "mounts.h" | |
// TODO: if a path is given, and nothing is mounted on it, find its | |
// parent. | |
// TODO: handle multiple inputs. |