Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jhartman86's full-sized avatar

Jono Hartman jhartman86

  • The Zero Card
  • Denver
View GitHub Profile
@jhartman86
jhartman86 / where_composer.go
Last active November 16, 2018 23:50
Golang: nested where clause generator
/*Package wherecomposer builds potentially deeply nested WHERE statements.
Supplements GORM's .Where() method to address the following:
https://stackoverflow.com/questions/53213551/how-to-build-where-query-with-grouped-ors
https://github.com/jinzhu/gorm/issues/2059
Quick example, and how to build nested WHERE clauses and apply to a GORM query:
where := build(constraints{
{col:"user_id", val:1},
{
@jhartman86
jhartman86 / queue.go
Created June 6, 2018 19:36
optimistic fan-out concurrency job queue
package queue
import (
"fmt"
"log"
"sync"
"time"
"github.com/jhartman86/conduit/pkg/system/database"
)
@jhartman86
jhartman86 / config.go
Created September 1, 2017 21:14
config store "singleton", kind of
/*
Global config parser. Please actually read this to understand how it works.
There are three ways to set runtime configurations:
- Environment variables
- env.json files (one only)
- CLI flags
Order matters. Environment variables are parsed first. Then the env.json
file. If the env.json file contains the same key as an environment variable
name, the value in env.json takes precedence. Lastly, CLI flags are parsed.
@jhartman86
jhartman86 / index.js
Last active October 31, 2016 18:51
spamcheck.js
var request = require("superagent");
module.exports = function spamCheck(data, callback) {
request
.post("http://spamcheck.postmarkapp.com/filter")
.type("json")
.send(data)
.end(function (res) {
if (res.error) {
return callback(new Error("SpamCheck service failed with: " + res.text));
@jhartman86
jhartman86 / title14Part61FARTransformedXSLT.html
Created April 26, 2016 01:46
title14Part61FARTransformedXSLT
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /><title>Code of Federal Regulations</title><style type="text/css">
.FDSYSLINE {display:block;width:100%;margin-bottom:10px;text-align:left;border-bottom-style:solid;border-width:1px;}
.CFRFDSYS {display:block;width:100%;margin-top:5px;margin-bottom:5px;text-align:left;}
.FDSYSANCESTORS, .FDSYSHEADINGTITLE2, .FDSYSORIGDATE, .FDSYSDATE, .FDSYSVOLUME {display:block;}
.FDSYSNUMTITLE1 {display:block;font-weight:bolder;font-size:12pt;}
.CFRDOC-AMDDATE {display:block;width:90%;margin-top:5px;margin-bottom:5px;text-align:right;}
.TITLEPG-PUB, .FMTR-TITLEPG {display:block;width:90%;margin-top:5px;margin-bottom:5px;text-align:left;}
.TITLEPG-SPECED, .TITLEPG-TITLENUM, .TITLEPG-ANCIL, .TITLEPG-CONTAINS, .TITLEPG-SUBJECT, .TITLEPG-REVISED, .TITLEPG-PARTS, .TITLEPG-CODE {display:block;}
@jhartman86
jhartman86 / FARs61.html
Last active April 24, 2016 22:04
FARsPart61
<div id="browse-layout-mask">
<div>&nbsp;</div>
<h3 class="page-title">Electronic Code of Federal Regulations</h3>
<p></p>
@jhartman86
jhartman86 / index.html
Created April 8, 2016 23:54
sltShareDialogs
<html>
<head>
<title>Configure</title>
<link rel="stylesheet" type="text/css" href="https://code.fluidretail.net/configure-ui/stable/css/configure-app.css">
<style>
* {box-sizing:border-box;}
html, body {width:100%;height:100%;}
body {margin:0;padding:1rem;min-height:100%;background:#eaeaea;}
[configure] {width:920px;max-width:95%;margin:0 auto;background:#fff;padding:1rem;}
[carousel] {margin-bottom:3rem;max-width:400px;margin:0 auto 3rem;}
@jhartman86
jhartman86 / index.html
Created April 7, 2016 21:09
shareDialogs
<html>
<head>
<title>Configure</title>
<link rel="stylesheet" type="text/css" href="https://code.fluidretail.net/configure-ui/stable/css/configure-app.css">
<style>
* {box-sizing:border-box;}
html, body {width:100%;height:100%;}
body {margin:0;padding:1rem;min-height:100%;background:#eaeaea;}
[configure] {width:920px;max-width:95%;margin:0 auto;background:#fff;padding:1rem;}
[carousel] {margin-bottom:3rem;max-width:400px;margin:0 auto 3rem;}
@jhartman86
jhartman86 / node-injector.js
Created October 27, 2015 16:42
AngularJS-style dependency injection for Node
/**
* Angular-ish style dependency injection for node; relies on (but does not
* override) node's require() mechanisms; merely compliments the loading process
* and allows you to structure your app so that you *know* what you'll get back
* from a dependency. Otherwise known as an inversion of control container.
* @usage: require('node-injector').using(module).factory('thing', ['dep1', 'dep2', function( dep1, dep2 ){ }])
* @returns {Injector}
* @constructor
*/
function InversionController(){
angular.module('sstt.common').
/**
* http://blog.thoughtram.io/angularjs/2015/01/02/exploring-angular-1.3-bindToController.html
* https://leanpub.com/recipes-with-angular-js/read#leanpub-auto-editing-text-in-place-using-html5-contenteditable
* http://jonathancreamer.com/working-with-all-the-different-kinds-of-scopes-in-angular/
* http://radify.io/blog/understanding-ngmodelcontroller-by-example-part-1/
* @todo: clean up key binding code; make configurable
* @todo: clean up/make more efficient the overlay list positioning code, and test
* across more browsers