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
-- Let PG compute as many of the DBI attributes as is practicable -- | |
SELECT | |
a.attname AS name, | |
t.typname AS type_name, | |
CASE | |
WHEN a.attlen > 0 THEN a.attlen | |
WHEN a.atttypmod > 65535 THEN a.atttypmod >> 16 | |
WHEN a.atttypmod >= 4 THEN a.atttypmod - 4 | |
ELSE NULL | |
END AS precision, |
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
/* Quick GETTIMEOFDAY() UDF, because FB TIMESTAMPs are not TIME ZONE aware */ | |
/* Mike Pomraning 2011 for FB 2.1; this code is in the Public Domain */ | |
#include <sys/time.h> | |
/* | |
DECLARE EXTERNAL FUNCTION gettimeofday | |
RETURNS DOUBLE PRECISION BY VALUE | |
ENTRY_POINT 'UDF_gettimeofday' MODULE_NAME 'udf_gettimeofday'; |
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
/* FB_SLEEP() UDF - pause an FB thread for a number of seconds */ | |
/* Mike Pomraning 2011 for FB 2.1; this code is in the Public Domain */ | |
#include <sys/select.h> | |
/* | |
DECLARE EXTERNAL FUNCTION fb_sleep | |
DOUBLE PRECISION | |
RETURNS INTEGER BY VALUE | |
ENTRY_POINT 'UDF_fb_sleep' MODULE_NAME 'udf_fb_sleep'; |
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
-- UTIL$RANGE(start, stop, step) | |
-- | |
-- This file is in the Public Domain. | |
-- Firebird selectable stored procedure for producing integer ranges. | |
-- (Mike Pomraning; 2011-03-30) | |
-- | |
CREATE EXCEPTION util$err_range_zero_step 'step size may not be zero'; | |
SET TERM !!; | |
CREATE PROCEDURE util$range("Start" INTEGER, "Stop" INTEGER, "Step" INTEGER) | |
RETURNS (i INTEGER) AS |
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
#! /usr/bin/perl | |
# Test whether a DBD returns sensible object TYPE listings for a given | |
# database. | |
# | |
# | |
# Usage: perl table_info_types.t DSN [USER [PASS]] | |
# -or- | |
# perl table_info_types.t DBIx_CONFIG_SPEC | |
# -or- |
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 itertools | |
def natatime(n, iterable, fillvalue = None): | |
"""Returns an iterator yielding `n` elements at a time. | |
:param n: the number of elements to return at each iteration | |
:param iterable: the iterable over which to iterate | |
:param fillvalue: the value to use for missing elements | |
:Example: |
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
# Public Domain | |
# Written 2020-08-21, Mike Pomraning | |
# | |
# upto N command [args...] | |
# | |
# Repeatedly execute command until successful, up to N times, returning the | |
# exit status of the last invocation of command. | |
# | |
upto () { | |
NumAttempts=$1; |
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
def coalesce(*args): | |
# return first(lambda x: x is not None, args) | |
return next(_ for _ in args if _ is not None) | |
def first(selector, iterable, default = None): | |
return next((_ for _ in iterable if selector(_)), default) |
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
/** | |
* Public Domain | |
* 2023-10-19 Mike Pomraning, first version | |
*/ | |
package local; | |
import java.util.Map; | |
import java.util.AbstractMap.SimpleEntry; | |
import java.util.AbstractMap.SimpleImmutableEntry; |