Skip to content

Instantly share code, notes, and snippets.

View dylancwood's full-sized avatar

Dylan Wood dylancwood

View GitHub Profile
@dylancwood
dylancwood / tree.css
Last active April 29, 2024 15:48
CSS to create a simple tree structure with connecting lines. No images or JS required.
ul.tree, ul.tree ul {
list-style: none;
margin: 0;
padding: 0;
}
ul.tree ul {
margin-left: 10px;
}
ul.tree li {
margin: 0;
@dylancwood
dylancwood / install_fips.sh
Last active July 14, 2016 18:00
Shell script to compile and install FIPS-validated Open SSL as well as Apache 2.4. Tested on Ubuntu 12.04. This script does not verify the fingerprint of the OpenSSL FIPS object module, and is therefore incomplete. It is a good place to start though.
#!/bin/bash
echo "installing updates"
sudo apt-get update
echo "installing build-essential"
sudo apt-get install build-essential
echo "moving to home dir"
cd ~
@dylancwood
dylancwood / informed_redirect.html
Created November 21, 2013 03:54
Simple webpage to inform users that a resource has changed locations, and redirect after 10 seconds. Has some cute graphics that are pure CSS: no images for the fastest possible loading times.
<!DOCTYPE html>
<html>
<head>
<script>
;{
var render_timer, initialize_page
, old_app_name = 'Self Assessment'
, new_app_name = 'Participant Portal'
, old_app_url = 'http://chronus.mrn.org/self'
, new_app_url = 'http://coins.mrn.org/p2';
@dylancwood
dylancwood / php_leading_zero_numbers.php
Last active December 31, 2015 02:39
This simple script illustrates that PHP interprets digits with leading zeros as an octal. This can cause problems when interpreting user input as an integer without converting it to a string first then parsing it (e.g with intval()).
<?php
echo 'This simple script illustrates that PHP interprets digits with leading zeros as an octal. This can cause problems when interpreting user input as an integer without converting it to a string first then parsing it (e.g with intval()).';
echo '<br>Notice that numbers greater than 7 do not compare nicely with their leading-zero counterparts.';
echo '<br>';
echo '9';
echo '<br>';
echo '9==09 ... ';
echo iif(9==09, 'true', 'false');
echo '<br>';
echo '9==9 ... ';
@dylancwood
dylancwood / split.js
Created May 10, 2014 00:36
AppData Cleanup!!
/*
TODO:
write a new file that contains calls to each function found in each of the splitFileDirPath
function getSubjectTags() {
return className->getSubjectTags($args);
}
Address methods that reference other methods as '$this->doSomething()'
+ $this->select() Could be addressed by each class extending BaseAppData
+ Grep for methods defined in File 'A' that are referenced in File 'B' using $this->
+ Alternatively, change all calls to '$this' to be $AppData.
@dylancwood
dylancwood / testserver.js
Last active August 29, 2015 14:14
Quick server to test whether http module automatically decodes url
var http = require('http');
var server = http.createServer();
server.on('request', function(req, res) {
console.log(req.url);
res.end();
});
server.listen(8123);
@dylancwood
dylancwood / gist:3ab0569cff6996c17724
Created July 27, 2015 23:12
scans route with todos
'use strict';
//TODO: add '['api']' tags to each route (see auth/login.js for exampe)
//TODO: also add notes and description fields for swagger.
const boom = require('boom');
exports.register = function(server, options, next) {
const path = '/scans';
// TODO: should be Scan
@dylancwood
dylancwood / post.md
Created August 16, 2015 00:52
Promise tips

I spent a little time in a Promise rabbit-hole today, and thought I'd share two rules-of-thumb that I came up with to avoid such holes in the future. This came from writing Mocha tests, but it applies to lots of code:

Example:

describe('Some Async Test', () => {
    var myPromise;
    before('Do some async setup', () => {
        myPromise = doSomethingAsync();
 return myPromise;

Here's how bad channel data is stored in the COINS DB: Each scan session is stored as a row in the mrs_scan_sessions table. Multiple scan series may be associated with each scan, and are stored in the mrs_series table. Scan metadata categories like bad channels are stored in the mrs_scan_data_types table. Series are associated with many metadata categories the mrs_series_data table (which contains a series_id, a scan_data_type_id and a value).

Exporting this data through our more modern API would result in the following format:

[
@dylancwood
dylancwood / data-record-schema.xml
Created December 10, 2015 21:49
add schema for data-records and data-uploads
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<changeSet id="add tables for independent-blob schema"
author="DWOOD">
<comment>Create tables for file-record and file-upload schema</comment>