Skip to content

Instantly share code, notes, and snippets.

View bencord0's full-sized avatar

Ben Cordero bencord0

View GitHub Profile
@bencord0
bencord0 / .gitignore
Last active September 4, 2020 22:10
Hello World Without Webpack
index.js
@bencord0
bencord0 / Makefile
Last active August 23, 2020 12:05
crossdev musl
# Set the compiler toolchain to musl-gcc
# In gentoo, create the toolchain with crossdev
#
# crossdev -t x86_64-pc-linux-musl -S
#
CC = x86_64-pc-linux-musl-gcc
# The toolchain sets the ELF Interpreter to /lib/ld-musl-x86_64.so.1
# Either, set the interpreter in the binary to the musl dynamic loader,
# which is the same file as the libc, or symlink the expected loader.
@bencord0
bencord0 / git-clean-branches
Last active July 13, 2020 10:07
Rebase all local branches and scrub those that are already merged.
#!/bin/bash
set -e
git detach origin/master
set +e
mapfile -t BRANCHES < <(git branch | grep -v -e '\*' -e '\+')
for branch in "${BRANCHES[@]}"; do
branch_name="$(echo "$branch"|awk '{print $1}')"
@bencord0
bencord0 / init_tracer.rs
Created June 6, 2020 07:53
Rust init opentracing
fn init_tracer() -> Result<(), tracing_subscriber::util::TryInitError> {
let exporter_config = opentelemetry_zipkin::ExporterConfig::builder()
.with_service_name("service".to_string())
.with_service_endpoint("127.0.0.1:9411".parse().expect("valid sockaddr"))
.build();
let exporter = opentelemetry_zipkin::Exporter::from_config(exporter_config);
le
@bencord0
bencord0 / enter_docker.sh
Created March 31, 2019 11:51
NSEnter into a docker container
#!/bin/bash
CONTAINER_NAME="$1"
exec nsenter --target $(
docker inspect --format "{{.State.Pid}}" $(
docker ps -q --filter name="${CONTAINER_NAME}"
)
) --mount --uts --ipc --net --pid
@bencord0
bencord0 / async_main.js
Created January 31, 2019 01:42
Write everything in node with async
const fs = require("fs").promises; // nodejs 10.x
const { b64decode, getGithubClient } = require("./utils");
// If API clients need some async setup, create a placeholder for them.
let octokit = undefined;
async function main() {
// Fill in placeholders first
octokit = await getGithubClient();
@bencord0
bencord0 / find_script_dir.sh
Created January 18, 2019 15:20
cd into the directory of this script (bash-5 edition)
#!/bin/bash
cd "$(dirname "$(readlink -f "${BASH_ARGV0}")")"
echo "${PWD}"
@bencord0
bencord0 / appsync.py
Last active February 2, 2022 23:02
Accessing AppSync GraphQL APIs from python
import json
import requests
from boto3.session import Session as AWSSession
from gql_py import Gql
from requests import Session
from requests_aws4auth import AWS4Auth
aws = AWSSession()
session = Session()
@bencord0
bencord0 / data.json
Created December 8, 2018 06:25
Playing with service workers
{
"foo": "bar"
}
bencord0@localhost ~/src/f_or_d $ cat Pipfile
[[source]]
verify_ssl = true
name = "pypi"
url = "https://pypi.python.org/simple"
[requires]
python_version = "3.7"
[packages]