Skip to content

Instantly share code, notes, and snippets.

View lighth7015's full-sized avatar
Perpetually exhausted.

Robert Butler lighth7015

Perpetually exhausted.
View GitHub Profile
@lighth7015
lighth7015 / query.sql
Created December 12, 2019 18:39
SQL to execute
SELECT "primary"."NDC" as "primaryNDC",
"generic"."NDC" as "genericNDC",
"primary"."MONY",
"primary"."ProductName" as "primaryDrug",
"generic"."ProductName" as "genericDrug",
"primary"."Strength",
"primary"."StrengthUOM",
FROM "drugs" AS "primary",
"drugs" AS "generic"
@lighth7015
lighth7015 / SQL schemav
Created December 10, 2019 14:12
schema.sql
CREATE TABLE IF NOT EXISTS "drugs_list" (
"NDC" TEXT,
"DrugName" TEXT,
"GenericName" TEXT,
"Strength" INTEGER,
"StrengthUOM" TEXT,
"DoseForm" TEXT,
"MONY" TEXT,
"GPI" REAL,
"PackageSize" REAL,
@lighth7015
lighth7015 / filter.sh
Created November 23, 2019 03:42
filter.sh
#!/usr/bin/env sh
IFS=' ';
parse() {
while read -r line; do
list=${line}
for NDC in ${list[@]}; do
if [[ "list[${NDC}]" -gt 0 ]]; then
@lighth7015
lighth7015 / service-query.c
Created November 1, 2019 13:15
Query systemd's user bus to check for a service's existence.
#include <stdio.h>
#include <stdlib.h>
#include <systemd/sd-bus.h>
static sd_bus_error error = SD_BUS_ERROR_NULL;
static sd_bus_message *response;
static sd_bus *bus;
static int result;
static const char *path;
@lighth7015
lighth7015 / soap.php
Last active September 8, 2019 23:09
PHP soap client
<?php
class UserCredentials {
public $Username;
public $Password;
public function __construct( $username, $password ) {
$this->Username = $username;
$this->Password = $password;
}
}
@lighth7015
lighth7015 / soap.xml
Created September 8, 2019 21:59
Soap XML description
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<UserCredentials xmlns="http://mws.envisionrx.com/">
<UserID>string</UserID>
<Password>string</Password>
</UserCredentials>
</soap:Header>
<soap:Body>
<GetBrandEquivalentByGenericNDC xmlns="http://mws.envisionrx.com/">
[http@saturn app]$ transform input.txt
Arr::unique => array_unique
Arr::unshift => array_unshift
Arr::values => array_values
Arr::walk_recursive => array_walk_recursive
@lighth7015
lighth7015 / App\Models\Plan
Created September 3, 2019 02:13
So I'm trying to get eager loading to work correctly with a model I have; but it only ever wants to either return `null` or throw an exception because it's using the wrong column value to look up the related record;
<?php
namespace App\Models;
class Plan extends Model
{
protected $connection = 'sqlite3_db';
public $timestamps = false;
protected $hidden = [ 'plan_id' ];
protected $primaryKey = 'plan_type';
/* Copyright (c) 2014 Christopher Swenson. */
#include <stdlib.h>
#include <string.h>
#ifndef VECTOR_NAME
#error "Must declare VECTOR_NAME"
#endif
#ifndef VECTOR_TYPE
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
typedef struct {
union {
uint8_t zero: 1;
uint8_t fault: 1;
uint8_t present: 1;
uint8_t virtual: 1;