This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from 'fs'; | |
export default class X12 { | |
constructor(file) { | |
if (file.includes('/')) { | |
fs.readFile(file, 'utf8', (err, contents) => { | |
return this.parseTextToJSON(contents); | |
}); | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3" | |
services: | |
homeassistant: | |
image: homeassistant/home-assistant | |
ports: | |
- "8123:8123" | |
- "3218:3218" | |
volumes: | |
- /opt/docker/home-assistant:/config | |
- /etc/localtime:/etc/localtime:ro |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
NewerOlder