Skip to content

Instantly share code, notes, and snippets.

@willir
willir / build-luarocks-local-server.py
Created September 20, 2021 17:26
Builds local luarocks server of specified rocks and their dependencies
#!/usr/bin/env python3
import argparse
import re
import sys
from contextlib import ExitStack
from pathlib import Path
from subprocess import run, PIPE
from typing import Set, Tuple
@willir
willir / build_rust.gradle
Created November 4, 2019 17:20
Android Rust
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.Path
class BuildRust extends DefaultTask {
String variant
static String OUT_LIB_NAME = "libhello.so"
enum TargetType {
ARM64("arm64", "aarch64-linux-android", "arm64-v8a"),
@willir
willir / rapidjson-ostream-wrapper-benchmark.cpp
Created October 13, 2019 11:01
Benchmark of rapidjson BasicOstreamWrapper vs BufferedOStreamWrapper.
// To Compile: g++ -O3 -std=c++17 -I${RAPIDJSON_INCLUDE} rapidjson-ostream-wrapper-benchmark.cpp -lbenchmark
#include <sstream>
#include <cstdlib>
#include <memory>
#include <random>
#include <string>
#include <string_view>
@willir
willir / 5_non_shared_substring_test.cpp
Last active August 20, 2018 00:35
Tests for Shortest Non-Shared Substring task
#include "catch.hpp"
#include <memory>
#include <random>
#include <unordered_set>
#include "non-shared-substring.h"
using std::string;
using std::unordered_set;
@willir
willir / preinclude_header.cmake
Created July 6, 2016 22:39
Preinclude Headers Cmake Function
function(preinclude_header headers)
foreach(header ${ARGV})
message(STATUS "header: ${header}")
if(MSVC)
add_definitions(/FI${header})
else()
add_definitions(-include ${header})
endif()
endforeach(header)
endfunction()
@willir
willir / Rust - Towns File Parser
Last active April 21, 2016 05:53
Rust: Towns File Parser
To give gist a name.
#include "CsvReader.h"
#include <stdexcept>
using namespace std;
CsvReader::CsvReader(const char *filePath, size_t bufSize) :
mBufSize(bufSize),
mBuf(new char[bufSize]) {
mFile = fopen(filePath, "rt");
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import asyncio
import signal
def my_handler():
print('Stopping')
for task in asyncio.Task.all_tasks():
task.cancel()
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import asyncio
import signal
def my_handler():
print('Stopping')
for task in asyncio.Task.all_tasks():
task.cancel()
@willir
willir / LambdaSlotSimple.hpp
Last active August 29, 2015 14:23
LambdaSlot for sigslot library
#include <sigslot/sigslot.h>
#include <functional>
template <class arg1, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
class Slot1 : public sigslot::has_slots<mt_policy> {
public:
template<class Functor>
Slot1(const Functor &fun) : mFun(fun) {}
Slot1(std::function<void(arg1)> &&fun) : mFun(fun) {}