Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeff Rade jeffrade

View GitHub Profile
@jeffrade
jeffrade / bitcoind-start.sh
Last active May 20, 2022
bitcoind systemd service and start script.
View bitcoind-start.sh
#!/bin/bash
# Just a simple wrapper to start bitcoind.
#
# If using systemd, simply create a file (e.g. /etc/systemd/system/bitcoind.service)
# from example file below and add this script in ExecStart.
# https://raw.githubusercontent.com-/bitcoin/bitcoin/76deb30550b2492f9c8d9f0302da32025166e0c5/contrib/init/bitcoind.service
#
# Then run following to always start:
# systemctl enable bitcoind
@jeffrade
jeffrade / fail2ban_install.sh
Created Jun 30, 2019
Install fail2ban on Debian Linux
View fail2ban_install.sh
#!/bin/sh -x
echo "Starting..."
apt-get install -y fail2ban
systemctl start fail2ban
systemctl enable fail2ban
> /etc/fail2ban/jail.local
@jeffrade
jeffrade / native_mobile_connecting_to_graphql_api.md
Last active Mar 4, 2021
Securing Native Mobile connecting to a GraphQL API
View native_mobile_connecting_to_graphql_api.md

Certificate Pinning is highly recommended. OWASP has outlined the Who, What, Why and How.

Static keys (as opposed to user generated keys with randomness) need to be, at a minimum, obfuscated away. There are many ways (and in complexity) to do this (e.g. at a minimum, Proguard for Android) and Carve Systems has a good write-up on this.

It should go without saying, but all APIs (not just GraphQL) should only be served over HTTPS and every request authenticated (e.g. HMAC and many libraries in all languages already implement this).

Common attacks on a GraphQL API with best practices and recommendations outlined here by OWASP.

A good GraphQL security audit tool [here](https://github.com/doyense

@jeffrade
jeffrade / process_queue.sh
Last active Aug 17, 2020
Bash Script (infinite loop) to Upload Files to AWS S3 Glacier
View process_queue.sh
#!/bin/bash
QUEUE_DIR="./queue"
COMPLETED_DIR="./completed"
S3_BUCKET_NAME="<YOUR_BUCKET_NAME_HERE>"
OLDEST_FILENAME=""
echo "Running..."
while :; do
echo "Finding oldest file..."
@jeffrade
jeffrade / update_on_ip_change.sh
Last active Aug 17, 2020
Bash script that checks for IP change and updates Route53
View update_on_ip_change.sh
#!/bin/bash
# Usage: Launch in the background and pass RECORD_SET_NAME (e.g. sub.example.com.)
# as a first argument for the Route53 record. Log file can be found at /var/tmp/r53-record.log
NOTIFY_DIR=/var/tmp
LOG_FILE=${NOTIFY_DIR}/r53-record.log
CURR_IP_FILE=${NOTIFY_DIR}/ip.out
TMP_IP_FILE=${NOTIFY_DIR}/ip.tmp
IP_LKP_URL=https://ifconfig.me/ip
RECORD_SET_FILE=${NOTIFY_DIR}/r53-record-set.json
@jeffrade
jeffrade / BitcoinCoreFullNode.md
Last active Feb 6, 2020
Running a Bitcoin Core Full Node - Additional Installation Notes
View BitcoinCoreFullNode.md

Addtional Setup and Installation Notes for Running a Full Node (Linux)

  • Install fail2ban
  • (Optional) Block data is getting larger (although at a slower pace), so you might be mounting an external drive to .bitcoin dir. If so follow these steps:
   # You want this to auto mount on reboot (or else you'll have to manually mount every time):
 - `sudo blkid` # Make note of the UUID of your drive
 - `sudo vim /etc/fstab` # Append additional entry and your mount directory (easy to default to `$HOME/.bitcoin`)
    e.g. `UUID=<hexadecimal-dashed-uuid> /home/<your-user-name>/.bitcoin/ ext4 defaults 0 0` 
 - `sudo mount -a` # Test this, you'll get errors if any
@jeffrade
jeffrade / install_kafka.sh
Created Sep 11, 2019
Install Kafka on CentOS 7
View install_kafka.sh
#!/bin/bash
echo "Starting..."
cd ~/
wget https://download.java.net/java/GA/jdk12.0.1/69cfe15208a647278a19ef0990eea691/12/GPL/openjdk-12.0.1_linux-x64_bin.tar.gz
tar -xzvf openjdk-12.0.1_linux-x64_bin.tar.gz
echo "PATH=$PATH:$HOME/jdk-12.0.1/bin" >> ~/.bash_profile
echo "export PATH" >> ~/.bash_profile
echo "export JAVA_HOME=$HOME/jdk-12.0.1" >> ~/.bash_profile
@jeffrade
jeffrade / openssl.x509.sh
Last active Sep 11, 2019
Bash script to check certificate information - uses openssl.
View openssl.x509.sh
#!/bin/sh
if [ -z "$1" ]
then
echo "Please supply a domain, e.g. www.example.com"
exit 1
fi
echo | openssl s_client -servername $1 -connect $1:443 2>/dev/null | openssl x509 -text
echo "Saving public ./cert.pem..."
@jeffrade
jeffrade / list_fun.ex
Created Jun 24, 2019
Tail recursive implementaion of doubling every other number in a list.
View list_fun.ex
defmodule ListFun do
def double_every_other([], acc), do: acc
def double_every_other([head | nil], acc) do
new_acc = [head * 2 | acc]
double_every_other([], new_acc)
end
def double_every_other([head | tail], acc) when length(tail) == 0 do
@jeffrade
jeffrade / recursion.ex
Created Jun 11, 2019
Tail recursion is optimized way to do recursion in Elixir
View recursion.ex
defmodule Recursion do
@moduledoc """
Showing how tail recursion is optimized way to do recursion (i.e. no memory loss since function calls not kept on stack).
"""
def correct_tail_recursion_adding([head | tail], accumalator) do
correct_tail_recursion_adding(tail, accumalator + head)
end
def correct_tail_recursion_adding([], accumulator) do