Skip to content

Instantly share code, notes, and snippets.

View dkolb's full-sized avatar

David Kolb dkolb

View GitHub Profile
@dkolb
dkolb / gist:6345750
Last active December 21, 2015 18:09
Function Templates
my $cliSettings = {};
my $cliSettings->{'testName'} = "Standard";
my $verbose = 1;
{
# A function to return functions!
# you call &$getPathTemplate with a function that accepts a single, scalar (not reference)
# argument and returns true or false (1 or 0 in Perl) the second argument is
# a flag for the second argument that denotes if the destination this GetOptions
@dkolb
dkolb / MapAbuse.pl
Created September 14, 2013 03:12
A blatant abuse of map and Perl Hash/Array quirks to parse some output.
#!/usr/bin/perl
use Data::Dumper;
$reports = [
'16:02:10,663 INFO [log] STNDRDTESTRESULT operation=getEntityA,endpoint=http://server01.example.com/SomeService,status=VALID',
'16:02:18,485 INFO [log] STNDRDTESTRESULT operation=getEntityB,endpoint=http://server01.example.com/SomeOtherService,status=VALID',
'16:02:18,490 INFO [log] STNDRDTESTRESULT operation=getEntityB,endpoint=http://server02.example.com/SomeOtherService,status=VALID',
'16:02:20,657 INFO [log] STNDRDTESTRESULT operation=getEntityB,endpoint=http://server03.example.com/SomeOtherService,status=VALID',
'16:02:20,657 INFO [log] STNDRDTESTRESULT operation=getEntityB,endpoint=http://server04.example.com/SomeOtherService,status=VALID',
'16:02:22,276 INFO [log] STNDRDTESTRESULT operation=getEntityB,endpoint=http://server05.example.com/SomeOtherService,status=VALID',
@dkolb
dkolb / parseXsdDateTime.groovy
Created September 14, 2013 03:17
Making xsd:dateTime values for SoapUI tasks (e.g. getting today and 30 days ago).
import java.util.Calendar
import javax.xml.bind.DatatypeConverter
now = Calendar.getInstance()
endDate = DatatypeConverter.printDateTime(now)
now.add(Calendar.DAY_OF_MONTH, -30)
startDate = DatatypeConverter.printDateTime(now)
@dkolb
dkolb / a.js
Last active December 24, 2015 02:29
Node.js Module Globals Example
var b = require(__dirname + "/b"),
c = require(__dirname + "/c");
b.doIt();
console.log(c.get()); //Outputs 'b.doIt is updating stuff!'
@dkolb
dkolb / StoneBreakingListener.java
Created February 6, 2016 19:29
Optional In the Wild
package com.krinchan.minecraft.spongediamondfinder.listeners;
import org.slf4j.Logger;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.block.ChangeBlockEvent;
/**
* Created by david on 2/6/16.
*/
@dkolb
dkolb / keybase.md
Created September 19, 2017 14:40
keybase.md

Keybase proof

I hereby claim:

  • I am dkolb on github.
  • I am dkub (https://keybase.io/dkub) on keybase.
  • I have a public key ASCbWZkyUNuYmtePFCoI1BGkk3aKVqcA67FBKzmrnL5NpAo

To claim this, I am signing this object:

@dkolb
dkolb / airrecord_table_utilities.rb
Last active December 1, 2018 22:51
Airrecord Patches
module AirrecordTableUtilities
def self.included base
base.extend ClassMethods
base.include InstanceMethods
end
module ClassMethods
def map_field(method_name, field_name)
define_method method_name do
self[field_name]
@dkolb
dkolb / import-reminders.js
Created October 9, 2023 17:27
Reading in reminders from a CSV file and then adding them to Apple Reminders
import {runJxa} from 'run-jxa'
import { parse } from 'csv-parse'
import { readFile } from 'node:fs/promises'
const fileContents = await readFile('/Users/david/Downloads/Cinema_2023-10-09_11-53-49.csv', {encoding: 'UTF-8'})
parse(fileContents, {
columns: true
}, async function(err, records){
for ( const toDoItem of records) {