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
template<typename T> | |
class [[nodiscard]] Result { | |
public: | |
Result(const T& value) : _result(value) {} | |
Result(T && value) : _result(std::move(value)) {} | |
Result(std::exception error) : _result(std::unexpected<std::exception>(std::move(error))) {} | |
bool isOk() const { | |
markChecked(); | |
return _result.has_value(); |
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 <auto> | |
auto main() { | |
for (auto auto = 1; auto <= 100; auto++) { | |
if (auto % 15 == 0) auto << "FizzBuzz" << auto; | |
else if (auto % 5 == 0) auto << "Buzz" << auto; | |
else if (auto % 15 == 0) auto << "FizzBuzz" << auto; | |
else auto << auto << auto; | |
} |
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
# clang-format configuration file | |
# | |
--- | |
DisableFormat: false | |
Language: Cpp | |
Standard: Cpp11 | |
# Spacing | |
AccessModifierOffset: -4 | |
ColumnLimit: 100 |
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
from multiprocessing import cpu_count | |
import matplotlib | |
matplotlib.use('Agg', warn=False) | |
import matplotlib.pyplot as plt # noqa: E402 | |
import numpy as np # noqa: E402 | |
import pymc3 as pm # noqa: E402 | |
import six.moves | |
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
// Tested with clang-6.0 on Ubuntu 14.04 using: | |
// clang --std=c++14 -stdlib=libstdc++ -lstcd++ -fasm-blocks -O3 tls_guardvar.cpp -o tls_guardvar | |
// I will be genuinely surprised if this works in any other circumstance. | |
#include <iostream> | |
struct S { | |
int x; | |
S() { x = 42; } | |
}; |
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
function allWithProgress(promises, callback) { | |
let completed = 0 | |
callback(0, promises.length) | |
promises.forEach(p => { | |
p.then(() => callback(++completed, promises.length)) | |
}) | |
return Promise.all(promises) | |
} |
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
/** | |
* Safely retrieve a value from a nested object using a string path such as | |
* 'a.b.c' or an array ['a', 'b', 'c']. | |
*/ | |
function valueAtPath (obj, path) { | |
if (!Array.isArray(path)) { | |
if (!path) return obj | |
path = path.split('.') | |
} |
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
namespace BN = BinaryNinja; | |
using std::map; | |
using std::pair; | |
using std::priority_queue; | |
using std::vector; | |
int32_t dijkstra(vector<BN::Ref<BN::BasicBlock>> blocks, BN::Ref<BN::BasicBlock> source, BN::Ref<BN::BasicBlock> target) { | |
using path = pair<int32_t, uint64_t>; | |
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
#!/usr/bin/env bash | |
COUNTRY=us | |
APPID=1081557588 | |
curl -s "https://itunes.apple.com/${COUNTRY}/rss/customerreviews/id=${APPID}/sortBy=mostRecent/json" |\ | |
jq '[.feed.entry[]."im:rating".label // empty | tonumber] | add/length' |
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
var viewer = new Cesium.Viewer('cesiumContainer', {timeline: false, animation: false}); | |
var promise = Cesium.GeoJsonDataSource.load( | |
'https://s3.amazonaws.com/jhurliman/oakland-building-footprints.geojson'); | |
promise.then(function(dataSource) { | |
viewer.dataSources.add(dataSource); | |
// Get the array of buildings | |
var entities = dataSource.entities.values; |