Instantly share code, notes, and snippets.

View keys.js
class T {
[() => {}]() {
return 10;
}
}
class T_ {
[() => {}] = () => ({});
}
View cheatsheet.matlab
% Matlab cheat sheet
% Author: Steven Van Vaerenbergh
% Last version: https://gist.github.com/steven2358/7578242
%% SYSTEM
% seed a random generator
seed = 1;
rng('default');
View 1-easy.js
// Create a Promise that resolves after ms time
var timer = function(ms) {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
// Repeatedly generate a number starting
// from 0 after a random amount of time
var source = async function*() {
View async-gen.js
async function* handle() {
let i = 0;
while (true) {
yield i++;
}
}
const sleep = () => new Promise(r => setTimeout(() => r(undefined), 1000));
async function main() {
View effective_modern_cmake.md

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

View CMakeLists.txt
set(LIBFOO_TAR_HEADERS
"${CMAKE_CURRENT_BINARY_DIR}/include/foo/foo.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/foo/foo_utils.h"
)
add_custom_command(OUTPUT ${LIBFOO_TAR_HEADERS}
COMMAND ${CMAKE_COMMAND} -E tar xzf "${CMAKE_CURRENT_SOURCE_DIR}/libfoo/foo.tar"
COMMAND ${CMAKE_COMMAND} -E touch ${LIBFOO_TAR_HEADERS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include/foo"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/libfoo/foo.tar"
View uninstall_vmware.sh
#!/usr/bin/env bash
# Usage: bash uninstall_vmware.bash
remove() {
entry="$1"
echo -ne "Removing $entry ["
sudo rm -rf "$entry"
if [[ ! -e "$entry" ]]; then
echo -ne "OK"
View new-features.cpp
// clang++ -ggdb -std=c++17 -fsanitize=address src/cool-features.cpp -o T
#include <cstdio>
#include <map>
#include <string>
#include <tuple>
using namespace std;
class record {
public:
View threaded-queue.cpp
// Compile With: $ clang++ -ggdb -std=c++17 -fsanitize=address src/main.cpp -o T
#include <condition_variable>
#include <iostream>
#include <mutex>
#include <queue>
#include <sstream>
#include <thread>
int main() {
View boost_split.cpp
#include <boost/algorithm/string.hpp>
#include <string>
#include <vector>
#include <iostream>
int main()
{
std::string splitMe = "aa,b,cc,d";
std::vector<std::string> tokens;
boost::algorithm::split(tokens, splitMe, boost::is_any_of(","));