Skip to content

Instantly share code, notes, and snippets.

View rcj4747's full-sized avatar
⌨️

Robert Jennings rcj4747

⌨️
View GitHub Profile
# Host file to block twitter
# Title: Twitter DNS block list
0.0.0.0 twitter.com
0.0.0.0 www.twitter.com
0.0.0.0 t.co
0.0.0.0 analytics.twitter.com
0.0.0.0 platform.twitter.com
0.0.0.0 pbs.twimg.com # Photo Blob Store
@rcj4747
rcj4747 / sample-nginx-hello
Created September 16, 2021 00:09
Sample Digitalocean docker image-based app (nginx hello)
name: hello
services:
- name: hello
http_port: 80
image:
registry_type: DOCKER_HUB
registry: nginxdemos
repository: hello
tag: latest
@rcj4747
rcj4747 / healthchecks.sh
Last active May 14, 2021 14:43
Run a command and report status to https://healthchecks.io
#!/bin/bash -eu
set -o pipefail
# Run a command and report status to https://healthchecks.io
usage() {
echo "Usage: $0 <healthchecks.io UUID> <command>"
exit 1
}
trap usage EXIT
@rcj4747
rcj4747 / aws_ec2_describeInstanceTypes.py
Created September 2, 2020 16:44
Play with AWS EC2 describe_instance_types
"""
Play with AWS EC2 describe_instance_types
"""
from boto3.session import Session
sess = Session()
ec2c = sess.client('ec2')
resp = ec2c.describe_instance_types()
@rcj4747
rcj4747 / print_function_args.py
Created April 19, 2019 13:25
python snippet to print a callers function name and arguments
import inspect
def print_args():
'''Print the callers function name along with argument values'''
# TODO: print * and ** args
frame, _, _, name, _, _ = inspect.getouterframes(inspect.currentframe())[1]
args, _, _, values = inspect.getargvalues(frame)
print("%s: %s)" % (name, ["%s=%s" % (i, values[i]) for i in args]))
@rcj4747
rcj4747 / count_read_io.sh
Last active February 9, 2019 19:46
Sum bytes read by a process (and children)
#!/bin/bash -e
# Measure the bytes read by a command
# count_command_io <cmd> <args>*
# Credit to shodanex from https://stackoverflow.com/a/8853287
if [ -z $@ ] ; then
echo "Usage: $0 <cmd> <args>*"
exit 1
fi
@rcj4747
rcj4747 / 3dp_tramming.md
Created January 30, 2019 21:21
Adjusting a 3D printer bed tramming sensor

From https://toms3d.org/2014/09/15/3d-printing-guides-setting-up-auto-bed-tramming-leveling-tilt-compensation/

  1. send a G29 to run through the autotramming procedure
  2. grab a piece of copy paper and slide that under the preheated hotend
  3. send a G92 Z10, which tells the printer / to assume that the printhead is now actually 10mm above the bed’s surface
  4. move the Z axis down in increments of 0.1mm until the tip of the hotend just touches the surface of the paper
  5. send M114 to see how much length of the 10mm on Z you have used up to # get down this far
  6. enter that into the z probe offset from extruder as a negative value since the trigger point of the probe is actually # closer to the bed’s surface than the tip of your hotend
@rcj4747
rcj4747 / s3_presigned_url.py
Last active October 16, 2018 07:16
Generate a presigned URL to download an S3 object
#!/usr/bin/env python3
"""Generate a presigned URL to download an S3 object
<cmd> bucket_name key_name [expiration_days]"""
import sys
import boto3
from botocore.client import Config
@rcj4747
rcj4747 / clipboard.py
Last active August 7, 2018 15:32
Watch the clipboard for URLs and open them in the browser (on Linux)
#!/usr/bin/env python3
"""
Watch the clipboard for URLs and open them in the browser (on Linux)
"""
import subprocess
import time
import pyperclip # Requires xclip to be apt installed
@rcj4747
rcj4747 / apt_pinning_priorities.md
Created June 27, 2018 13:08 — forked from JPvRiel/apt_pinning_priorities.md
Apt package pinning and priorities