Skip to content

Instantly share code, notes, and snippets.

View jdmar3's full-sized avatar

John D. Martin III jdmar3

View GitHub Profile
@jdmar3
jdmar3 / logging-middleware.js
Last active March 8, 2022 18:10 — forked from cgmartin/logging-middleware.js
Morgan JSON log format example
'use strict';
const morgan = require('morgan');
module.exports = function jsonLog() {
return morgan(jsonFormat);
};
function jsonFormat(tokens, req, res) {
return JSON.stringify({
'remote-address': tokens['remote-addr'](req, res),
@jdmar3
jdmar3 / zha-adurolight-4-button-dim-switch.yaml
Last active January 16, 2022 13:16 — forked from HcgRandon/zha-adurolight-4-button-dim-switch.yaml
ZHA - ADUROLIGHT ERIA 4 Button Dim Switch
blueprint:
name: ADUROLIGHT ERIA 4 Button Dimming Switch (works with ZHA)
description: Automate ADUROLIGHT ERIA 4 Button Dimming Switch using ZHA events to control entities.
domain: automation
input:
target_switch:
name: Select Target Switch
selector:
device:
integration: zha
@jdmar3
jdmar3 / yet_another_motion_automation.yaml
Created November 28, 2021 15:26 — forked from networkingcat/yet_another_motion_automation.yaml
Homeassistant blueprint for motion-activated light scene
blueprint:
name: Yet Another Motion Automation
description: >
# YAMA V10
Turn on lights or scenes when motion is detected.
Four different scenes can be defined depending on time of day.
@jdmar3
jdmar3 / instructions.md
Last active November 4, 2022 13:08 — forked from asmateus/instructions.md
Simple Slurm configuration in Debian based systems

Slurm Configuration Debian based Cluster

Here I will describe a simple configuration of the slurm management tool for launching jobs in a really simplistic cluster. I will assume the following configuration: a main node (for me it is an Arch Linux distribution) and 3 compute nodes (for me compute nodes are Debian VMs). I also assume there is ping access between the nodes and some sort of mechanism for you to know the IP of each node at all times (most basic should be a local NAT with static IPs)

Basic Structure

Slurm management tool work on a set of nodes, one of which is considered the master node, and has the slurmctld daemon running; all other compute nodes have the slurmd daemon. All communications are authenticated via the munge service and all nodes need to share the same authentication key. Slurm by default holds a journal of activities in a directory configured in the slurm.conf file, however a Database management system can be set. All in all what we will try to do is:

  • Install `munge
@jdmar3
jdmar3 / script-template.sh
Created December 23, 2020 20:15 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
#!/usr/bin/python
# Title: Reddit Data Mining Script
# Authors: Clay McLeod
# Description: This script mines JSON data
# from the Reddit front page and stores it
# as a CSV file for analysis.
# Section: Python
# Subsection: Data Science
want=["domain", "subreddit", "subreddit_id" "id", "author", "score", "over_18", "downs", "created_utc", "ups", "num_comments"]
@jdmar3
jdmar3 / onc_converter.py
Last active September 7, 2018 17:33 — forked from woodrow/onc_converter.py
Convert OpenVPN config files to ChromeOS ONC files
#!/usr/bin/python
import argparse
import json
import re
import sys
import uuid
class OpenVPNNetworkConfiguration(object):
@jdmar3
jdmar3 / keybase.md
Last active January 30, 2017 17:13

Keybase proof

I hereby claim:

  • I am jdmar3 on github.
  • I am jdmar3 (https://keybase.io/jdmar3) on keybase.
  • I have a public key whose fingerprint is 67BB C847 14E0 C31A 736A 5E08 C787 DF8D D41F A8D1

To claim this, I am signing this object:

library(ggplot2)
library(Cairo) # MAGIC PACKAGE
fake.data <- data.frame(x = rnorm(100), y = rnorm(100), z = rbinom(100, 1, 0.5))
p <- ggplot(fake.data, aes(x=x, y=y)) +
geom_line() +
labs(x="Science", y="More science", title="Here's a title") +
facet_wrap(~ z) +
theme_bw() +
#!/usr/bin/env python3
import re
import os
import sys
import requests
import argparse
# This website allows information about a paper to be retrieved by accessing
# http://dx.doi.org/DOI