Skip to content

Instantly share code, notes, and snippets.

View bencord0's full-sized avatar

Ben Cordero bencord0

View GitHub Profile
@bencord0
bencord0 / connect-headphones.sh
Created October 30, 2018 13:35
Enable "quiet" mode
#!/bin/bash
BOSEMAC="28:xx:xx:xx:xx:xx"
SONYMAC="70:xx:xx:xx:xx:xx"
if [[ $1 == "--sony" ]]; then
MAC=$SONYMAC
elif [[ $1 == "--bose" ]]; then
MAC=$BOSEMAC
else
echo "usage: ./connect-headphones.sh <--sony|--bose>"
@bencord0
bencord0 / Onioned?
Last active September 21, 2018 00:08
Am I Onioned?
map $server_port $onioned {
800 "yep";
default "nope";
}
server {
listen 127.0.0.1:443 ssl http2; # web
listen 127.0.0.1:800 ssl http2; # onion
server_name dl.condi.me;
@bencord0
bencord0 / .gitignore
Last active September 4, 2018 04:48
Playing with function pointers
main
*.o
*.so
@bencord0
bencord0 / bin2hex.c
Last active August 28, 2018 15:04
Convert base32 encoded TOTP tokens for oath-toolkit
/*
* bin2hex.c - base32 to hex conversion tool for TOTP tokens
* Copyright (C) 2018 Ben Cordero
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
@bencord0
bencord0 / bazel dependencies
Created July 22, 2018 08:43
What exactly does bazel depend on?
docker pull gentoo/stage3-amd64
docker run -it --rm -v /usr/portage:/usr/portage gentoo/stage3-amd64
echo 'USE="-cups -gtk -webstart -X"' >> /etc/portage/make.conf
emerge -pvt dev-util/bazel
@bencord0
bencord0 / envoy example
Last active July 27, 2019 21:55
Envoy original dst
Launch a service on 127.0.0.1:9090
hit it, sending the original destination IP:host as a header.
problems:
- Can't do domains
- Can't do https
-> envoy doesn't support `http_proxy` or the CONNECT protocol yet
curl localhost:10000 -H x-envoy-original-dst-host:\ 127.0.0.1:9090 -v
@bencord0
bencord0 / pstate.sh
Last active July 15, 2018 21:50
Want to keep your laptop cool and stop the fans from spinning up?
Here's some stuff to extend your laptop's battery life and stop it making
loud noises whenever you open up a new browser tab.
Slows things down a bit, but the GUI stays responsive, so who cares?!
# cat /usr/local/bin/set_intel_pstate.sh
#!/bin/sh
set -ex
# Cap the CPU at 20%, slows the computer down, but modern processors are fast enough anyway.
# You'll be fine.
@bencord0
bencord0 / db_maintenance_ping.sh
Created June 20, 2018 08:32
Send a pushover messsage when my database is back online
PUSHOVER_TOKEN=
PUSHOVER_USER_TOKEN=
DATABASE_URL=
# https://pushover.net/ is a service that sends notifications to your phone
# It's free for a week, or a $5 one-time charge if you want to keep it.
# Save this function in ~/.bashrc
function pushover {
if [ -z "${1}" ]; then
return 1;
@bencord0
bencord0 / package.diff
Created April 5, 2018 11:22
EC2/ECS package diff
--- packagelist.txt 2018-04-05 12:06:50.325274557 +0100
+++ ecs-packagelist.txt 2018-04-05 12:21:47.146084516 +0100
@@ -1,28 +1,12 @@
Loaded plugins: priorities, update-motd, upgrade-helper
Installed Packages
-acl.x86_64 2.2.49-6.11.amzn1 installed
acpid.x86_64 2.0.19-6.7.amzn1 installed
-alsa-lib.x86_64 1.0.22-3.9.amzn1 installed
-amazon-ssm-agent.x86_64 2.2.120.0-1.amzn1 installed
-at.x86_64 3.1.10-48.15.amzn1 installed
/*
* Copyright 2005-2014 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
*
* Copyright 2005-2010 Ned Ludd - <[email protected]>
* Copyright 2005-2014 Mike Frysinger - <[email protected]>
*/
#ifdef APPLET_qmerge