Skip to content

Instantly share code, notes, and snippets.

View robinsg's full-sized avatar

Glenn Robinson robinsg

  • 05:26 (UTC +01:00)
View GitHub Profile
@forstie
forstie / Searching the IFS by name or date.sql
Last active July 27, 2025 05:22
The request was to provide an easy to use and customize approach for finding files within the IFS based upon generic names and including the date they were created.
-- With this style of SQL, you can search the IFS by file name, or by creation date, or both!
-- In fact, it is simple to search by any criteria you'd like to use.
--
-- Find files within the IFS where:
-- --> The name starts with "P"
-- --> The file suffix is ".txt"
-- --> The file was created on January 10, 2022
--
@forstie
forstie / Who owns the most objects.sql
Created September 24, 2020 17:43
Someone asked me how to use SQL to understand who owns the most objects. The following is a progression of queries to shine a light on this topic.
--
-- description: Objects owned by QTMHHTP1
-- minvrm: V7R3M0
--
select 'QTMHHTP1' as user, 'IFS' as object_type, count(*) as objects_owned
from qsys2.object_ownership
where authorization_name = 'QTMHHTP1' and path_name is not null
union all
select 'QTMHHTP1' as user, 'QSYS' as object_type, count(*) as objects_owned
from qsys2.object_ownership
@forstie
forstie / IFS breakdown objects by subdir.sql
Created September 23, 2020 00:52
Someone asked if you could count the stream file objects, by directory. This solution gets the job done and includes the total size count as well.
-- One time setup
cl:ADDDIRE USRID(<user-profile> RST) USRD('Your name') USER(<user-profile>);
--
-- description: Count the stream file objects, by subdirectory
-- Include the total size of all stream files in each subdirectory
-- Order the result by largest object count, descending
--
-- Note: Please note that this isn't a fast query and is meant to be run once in a while
-- and not During a performance critical period.
@forstie
forstie / Extracting data from a string.sql
Created July 14, 2020 17:59
The SQL language is so robust, there's often more than one way to accomplish a task. In this Gist, I demonstrate how to extract the job user name from a qualified job name.
--
-- Author: Scott Forstie
-- Date : July 14, 2020
--
--
-- Question: How do I extract the Job User Name from a qualfied job name?
-- Answer : Use Locate_In_String with Substring
-- Bonus : Did you know that the QSYS2.JOB_NAME built-in global variable gives you the qualfied job-name of the current connection?
values qsys2.job_name,
@forstie
forstie / Bringing order to the IFS.sql
Last active July 27, 2025 05:15
This example picks on the IFS stream files found within and under the /tmp directory. How much gunk has been accumulated under /tmp and what can you do to manage it? A bit of SQL to the rescue. The IFS_OBJECT_STATISTICS() UDTF returns many elements of data for you to leverage for improved management of the IFS.
--
-- Reference material: https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzajq/rzajqudfifsobjstat.htm
--
--
-- How much space is used by stream files from /tmp (and subdirs) that haven't been used in 6 months
--
select varchar_format(sum(data_size),'999G999G999G999G999G999G999') tmp_size
from table (
qsys2.ifs_object_statistics(start_path_name => '/tmp',
@SKempin
SKempin / Git Subtree basics.md
Last active July 20, 2026 06:43
Git Subtree basics

Git Subtree Basics

If you hate git submodule, then you may want to give git subtree a try.

Background

When you want to use a subtree, you add the subtree to an existing repository where the subtree is a reference to another repository url and branch/tag. This add command adds all the code and files into the main repository locally; it's not just a reference to a remote repo.

When you stage and commit files for the main repo, it will add all of the remote files in the same operation. The subtree checkout will pull all the files in one pass, so there is no need to try and connect to another repo to get the portion of subtree files, because they were already included in the main repo.

Adding a subtree

Let's say you already have a git repository with at least one commit. You can add another repository into this respository like this:

@halberom
halberom / output
Created August 3, 2015 11:26
ansible - example of using from_json
PLAY [localhost] **************************************************************
GATHERING FACTS ***************************************************************
ok: [localhost]
TASK: [shell cat '/tmp/file.json'] ********************************************
changed: [localhost]
TASK: [debug var=result] ******************************************************
ok: [localhost] => {
@ms5
ms5 / verbos-argpary-example.py
Last active July 19, 2024 12:19
manipulating log level with python argparse
import argparse
import logging
parser = argparse.ArgumentParser()
parser.add_argument('--verbose', '-v', action='count', default=1)
args = parser.parse_args()
args.verbose = 70 - (10*args.verbose) if args.verbose > 0 else 0
logging.basicConfig(level=args.verbose, format='%(asctime)s %(levelname)s: %(message)s',
@miseqs
miseqs / syslog-client.py
Created August 14, 2014 16:08
A simple command line python syslog client for generating test messages.
#!/usr/bin/env python
import argparse
import logging
import logging.handlers
parser = argparse.ArgumentParser(__file__,
description="A syslog message generator")
parser.add_argument("--address",