Skip to content

Instantly share code, notes, and snippets.

View MichaelLeeHobbs's full-sized avatar

Michael Hobbs MichaelLeeHobbs

  • United States
View GitHub Profile
@lk321
lk321 / x12.js
Last active October 11, 2023 14:18
EDI X12 Parse to JSON - NodeJS
import fs from 'fs';
export default class X12 {
constructor(file) {
if (file.includes('/')) {
fs.readFile(file, 'utf8', (err, contents) => {
return this.parseTextToJSON(contents);
});
} else {
@Red5d
Red5d / home-assistant_nodered_mqtt.yml
Created November 23, 2017 17:18
docker-compose file for setting up homeassistant, node-red, and mqtt services
version: "3"
services:
homeassistant:
image: homeassistant/home-assistant
ports:
- "8123:8123"
- "3218:3218"
volumes:
- /opt/docker/home-assistant:/config
- /etc/localtime:/etc/localtime:ro
@zfael
zfael / nodejs.checksum.js
Created June 20, 2017 13:57
NODE.JS - How to generate file's Checksum (CRYPTO)
var fs = require('fs');
var crypto = require('crypto');
fs.readFile('file.pdf', function(err, data) {
var checksum = generateChecksum(data);
console.log(checksum);
});
function generateChecksum(str, algorithm, encoding) {
return crypto
@jaime-olivares
jaime-olivares / DicomUID.cs
Last active December 11, 2023 17:50
Dicom UUID-derived UID generator
// A port from javascript: https://hcintegrations.ca/2014/05/14/quick-and-dirty-javascript-dicomweb-uid-generator/
public static string NewUID_dirty()
{
var r = new System.Random();
var uid = System.Text.RegularExpressions.Regex.Replace("2.25.xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx", "x", m => (r.Next()%16).ToString() );
return System.Text.RegularExpressions.Regex.Replace(uid, "y", m => (r.Next()&3|8).ToString());
}
// Trying to strictly follow the Dicom spec: ftp://medical.nema.org/medical/dicom/2013/output/html/part05.html#sect_B.2
// More details at: ISO/IEC 9834-8 / ITU-T X.667, Section 6.3
@mattiaslundberg
mattiaslundberg / Ansible Let's Encrypt Nginx setup
Last active May 14, 2025 21:35
Let's Encrypt Nginx setup with Ansible
Ansible playbook to setup HTTPS using Let's encrypt on nginx.
The Ansible playbook installs everything needed to serve static files from a nginx server over HTTPS.
The server pass A rating on [SSL Labs](https://www.ssllabs.com/).
To use:
1. Install [Ansible](https://www.ansible.com/)
2. Setup an Ubuntu 16.04 server accessible over ssh
3. Create `/etc/ansible/hosts` according to template below and change example.com to your domain
4. Copy the rest of the files to an empty directory (`playbook.yml` in the root of that folder and the rest in the `templates` subfolder)
// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
@nbeloglazov
nbeloglazov / rhino_script.js
Last active July 11, 2020 22:05
setTimeout, clearTimeout, setInterval, clearInterval implementations for Rhino that works in 1.7R4
var setTimeout, clearTimeout, setInterval, clearInterval;
(function () {
var executor = new java.util.concurrent.Executors.newScheduledThreadPool(1);
var counter = 1;
var ids = {};
setTimeout = function (fn,delay) {
var id = counter++;
var runnable = new JavaAdapter(java.lang.Runnable, {run: fn});
@kfox
kfox / tcpproxy.js
Created April 5, 2012 20:03
A basic TCP proxy written in node.js
var net = require("net");
process.on("uncaughtException", function(error) {
console.error(error);
});
if (process.argv.length != 5) {
console.log("usage: %s <localport> <remotehost> <remoteport>", process.argv[1]);
process.exit();
}
@silvein
silvein / pre-commit
Created March 26, 2011 07:52
This is a Git pre-commit hook I'm developing to make sure local submodule changes are pushed before committing. This would probably be better as a pre-push hook, but there does not appear to be a facility for that.
#!/bin/bash
function git_submodule_unchanged () {
SUB_MODULE=$1
GSC_RC=0
pushd $SUB_MODULE > /dev/null
SUB_BRANCH=$(git branch | grep '*' | cut -d' ' -f 2)
if [[ "$(git log --pretty=oneline origin/${SUB_BRANCH}..${SUB_BRANCH})" != "" ]]; then
GSC_RC=1
fi