Skip to content

Instantly share code, notes, and snippets.

@bryanhuntesl
bryanhuntesl / make that mac not sleep - let that mac sleep again.markdown
Created January 17, 2018 10:14
make that mac not sleep - let that mac sleep again
sudo pmset -b sleep 0; sudo pmset -b disablesleep 1

and after reenable with

sudo pmset -b sleep 5; sudo pmset -b disablesleep 0
@bryanhuntesl
bryanhuntesl / Riak and Erlang - execute a command upon a node and print to console.md
Last active June 13, 2022 16:00
Riak and Erlang - execute a command upon a node and print to console

verify distributed Erlang working

Ping the riak node, print the response and halt the system.

erl -setcookie riak -name "${USER}-"@127.0.0.1 -noshell \
-eval "Res = net:ping('dev1@127.0.0.1'), io:put_chars(standard_error,io_lib:format(\"~p\",[Res]))." \
-eval "erlang:halt()."

As a result, pong is printed to the console, the response from the remote node, we're ready to start executing Erlang.

@bryanhuntesl
bryanhuntesl / shrink a screen recording session
Created June 29, 2021 17:52
shrink a screen recording session
ffmpeg -i front\ end\ betslip\ validation\ session.mp4 -filter:v fps=30 -vcodec libx264 -crf 28 -preset faster -tune out.mp4
RIJPGQMQNQIQLQKPHPHQGQKQIQIQJQCOGOCONPAPAPHPRPPPAPQPGOLPAPAPRP
@bryanhuntesl
bryanhuntesl / dummy-web-server.py
Last active December 8, 2020 18:43 — forked from bradmontgomery/dummy-web-server.py
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
# Written by Nathan Hamiel (2010)
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class S(BaseHTTPRequestHandler):
def do_GET(self):
@bryanhuntesl
bryanhuntesl / terraform provision sftp server.md
Created May 22, 2019 14:56
terraform provision sftp server

Terraform AWS Transfer server (managed SFTP storing to EC2)

Create two S3 buckets - the first will be used for logfiles - the second will hold client uploads - any requests to the client uploads bucket will result in logs being generated to the log storage bucket.

resource "aws_s3_bucket" "pbdhosts-logging" {
    bucket = "pbdhosts-logging"
cat <<EOF | docker build --build-arg=SOURCE=https://github.com/elixir-lang/elixir/archive/master.tar.gz .
FROM alpine
ARG SOURCE
ENV SOURCE=$SOURCE
RUN apk add curl
RUN echo "building source : $SOURCE"
WORKDIR /tmp

Reading the contents of a zip archive file in Elixir

We want to read (and extract all data from) the zip archive file frequency.zip.

Erlang has built in support for reading zip archives.

The documentation is here:

We'll be using :zip.foldl/3 to itterate the file contents.

# Derived from ./manifests
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: prometheus
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: prometheus
version: 2
jobs:
lint:
docker:
- image: circleci/elixir:1.10.3-node-browsers
steps:
- checkout
- restore_cache:
keys:
- v1-elixir-deps-cache-{{ .Branch }}-{{ checksum "mix.lock" }}