Skip to content

Instantly share code, notes, and snippets.

View eklitzke's full-sized avatar

Evan Klitzke eklitzke

View GitHub Profile
@eklitzke
eklitzke / firefox.sh
Last active April 29, 2023 13:49
minimal working example of firefox with bubblewrap
#!/bin/sh
exec bwrap --ro-bind /usr /usr --ro-bind /bin /bin --ro-bind /etc /etc --bind ~/.cache/mozilla ~/.cache/mozilla --bind ~/.mozilla ~/.mozilla --ro-bind ~/.config/pulse ~/.config/pulse --bind /run/user/$UID/pulse /run/user/$UID/pulse --symlink usr/lib64 /lib64 --proc /proc --dev /dev --unshare-pid firefox
@eklitzke
eklitzke / gist:1053328
Created June 29, 2011 07:34
add_callback example
import tornado.ioloop
loop = tornado.ioloop.IOLoop.instance()
def callback(*args):
loop.add_callback(callback)
callback()
loop.start()
#include "absl/container/flat_hash_map.h"
#include "absl/container/node_hash_map.h"
#include "benchmark/benchmark.h"
#include <map>
#include <unordered_map>
#include <vector>
// std::vector benchmark
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
cc_binary(
name = "iterperf",
srcs = ["main.cc"],
deps = [
"@benchmark",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:node_hash_map",
],
std::string DecodeBase64(std::string_view input) {
static const uint8_t b64_decode[] = {
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62,
64, 64, 64, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64, 64, 0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 64, 64, 64, 64, 64, 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
#include "cryptopals/aes.h"
#include "cryptopals/answer.h"
#include "cryptopals/block.h"
#include "cryptopals/codec.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/str_split.h"
namespace cryptopals {
std::string EncodeBase64(std::string_view v) {
size_t sz = v.size();
size_t padding = sz % 3;
if (padding) {
padding = 3 - padding;
}
sz += padding;
ASSERT_DEBUG(sz % 3 == 0);
std::string out(sz * 4 / 3, 0);
#include "advent/answer.h"
namespace advent2020 {
namespace {
static const std::vector<std::pair<int, int>> dirs{
{-1, -1}, {-1, 0}, {-1, 1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {0, -1},
};
size_t Neighbors1(const std::vector<std::string> &grid, int i, int j) {
size_t count = 0;
#include "advent/answer.h"
#include <numeric>
namespace advent2020 {
void Solution9(std::istream &input, advent::Answer &ans) {
std::vector<uint64_t> nums;
ans.ParseInts(input, nums);
// part1
$ wc -l .bash{rc,_profile} .bash.d/*
49 .bashrc
33 .bash_profile
13 .bash.d/ac.sh
74 .bash.d/aliases.sh
9 .bash.d/bash.sh
174 .bash.d/bazel.sh
4 .bash.d/blog.sh
18 .bash.d/cmake.sh
36 .bash.d/colors.sh