Skip to content

Instantly share code, notes, and snippets.

@mattrefghi
mattrefghi / cwebp-all-files-in-folder.bat
Created December 8, 2023 20:47
This is a fairly dumb batch file that, when placed in a folder, will run Google's cwebp.exe (https://developers.google.com/speed/webp/docs/precompiled) against all .jpg files in the same folder as the script. Could be a lot smarter, but it did the trick, figured it could be a good starting point for someone else.
@echo off
set /a counter=0
for %%f in (*.jpg) do (
C:\libwebp\bin\cwebp.exe -q 80 %%f -o %%~nf.webp
set /A counter=counter+1
)
echo ************************************
@aferriss
aferriss / levels.glsl
Created April 26, 2017 23:20
GLSL Photoshop Style Levels Adjustment
vec3 gammaCorrect(vec3 color, float gamma){
return pow(color, vec3(1.0/gamma));
}
vec3 levelRange(vec3 color, float minInput, float maxInput){
return min(max(color - vec3(minInput), vec3(0.0)) / (vec3(maxInput) - vec3(minInput)), vec3(1.0));
}
vec3 finalLevels(vec3 color, float minInput, float gamma, float maxInput){
return gammaCorrect(levelRange(color, minInput, maxInput), gamma);
@forstie
forstie / JSON_TABLE and survival tips for shredding JSON with SQL
Last active May 2, 2024 07:55
This example shows how to overcome what seems to be commonplace: JSON Web Services that return an invalid JSON document.
-- This fails to return data....why?
SELECT cusip, issueDate, bidToCoverRatio
FROM JSON_TABLE(
SYSTOOLS.HTTPGETCLOB('https://www.treasurydirect.gov/TA_WS/securities/announced?format=json&type=FRN&pagesize=5', null),
'$.root[*]'
COLUMNS(cusip VARCHAR(10) PATH '$.cusip',
issueDate Timestamp PATH '$.issueDate',
bidToCoverRatio double PATH '$.bidToCoverRatio')
) AS X;
stop;
@forstie
forstie / Generating spreadsheets with SQL.sql
Last active May 2, 2024 07:54
In this working example, we establish an SQL table which contains the spreadsheets we'd like to have generated. Each row in the table includes the query that will supply the data for the spreadsheet, and the location in the IFS where the spreadsheet should reside. Further, a different procedure emails the spreadsheets to an interested consumer. …
-- =================================================================
-- Author: Scott Forstie
-- Email : forstie@us.ibm.com
-- Date : January 10, 2020
-- =================================================================
--
-- Setup:
-- 1) create and populate the spreadsheet generator table
-- 2) change the procedure source code:
@forstie
forstie / Use ACS on your IBM i to build spreadsheets.sql
Created January 17, 2020 17:02
This example simplifies a previous gist. ACS is now being shipped on your IBM i via PTFs. Subsequent PTFs will ship when major enhancements are made to ACS.
--
-- Now that ACS is shipped on the IBM i via PTFs, we no longer need to manually move the
-- acsbundle.jar onto the IBM i. Just apply the latest ACS PTFs and reference the jar
-- at: /QIBM/proddata/Access/ACS/Base/acsbundle.jar
--
-- Initial PTFs of ACS
-- V7R4M0 SI71900
-- V7R3M0 SI71934
--
@FradSer
FradSer / iterm2_switch_automatic.md
Last active May 2, 2024 07:54
Switch iTerm2 color preset automatic base on macOS dark mode.

The latest beta (3.5) includes separate color settings for light & dark mode. Toggling dark mode automatically switches colors.

Vist iTerm2 homepage or use brew install iterm2-beta to download the beta. Thanks @stefanwascoding.


  1. Add switch_automatic.py to ~/Library/ApplicationSupport/iTerm2/Scripts/AutoLaunch with:
@forstie
forstie / Extracting the IFS filename from an absolute path name.sql
Created September 28, 2021 01:55
The request was, if you have an absolute path, how can SQL extract the filename from the path? One approach is found below.
--
-- Subject: Extracting the IFS file name from a path, using regular expression built-in functions
-- Author: Scott Forstie
-- Date : September 27, 2021
-- Features Used : This Gist uses regexp_count, regexp_instr, substr, and SQL PL
--
-- Function - The request was, if you have an absolute path, how can SQL extract the filename from the path?
-- One approach is found below.
--
--
@forstie
forstie / Compare the contents of two spooled files.sql
Created December 10, 2021 17:29
The challenge was simple... can SQL be used to compare the contents of two spooled files? The solution follows...
-- ========================================================================
--
-- Subject: Comparing two spooled files
-- Author: Scott Forstie
-- Date : December, 2021
--
-- IBM i Services used : OUTPUT_QUEUE_ENTRIES_BASIC, SYSTOOLS.SPOOLED_FILE_DATA
-- SQL language features used: CTEs, Exception joins, Union, and row_number()
-- ========================================================================
@forstie
forstie / Audit Journal Management.sql
Last active May 2, 2024 07:53
I've been getting asked lots of good questions about how to configure and monitor the Audit Journal. Guess what? #SQLcandoit
--
-- Subject: Audit Journal Management
-- Author: Scott Forstie
-- Date : March, 2023
-- Features Used : This Gist uses qsys2.security_info, qsys2.journal_info, qsys2.object_statistics, qsys2.qcmdexc, CTEs, sysibmadm.env_sys_info, and SYSTOOLS.split
--
-- Notes:
-- ===============================================
-- 1) There are many configuration options to consider using when establishing the Audit Journal, this Gist uses SQL to examine some of the most important choices.
-- 2) Its important to have a retention strategy for audit journal - journal receivers
@jamesmacfie
jamesmacfie / README.md
Created October 22, 2019 02:53
iTerm 2 - script to change theme depending on Mac OS dark mode

How to use

In iTerm2, in the menu bar go to Scripts > Manage > New Python Script

Select Basic. Select Long-Running Daemon

Give the script a decent name (I chose auto_dark_mode.py)

Save and open the script in your editor of choice.