Skip to content

Instantly share code, notes, and snippets.

-- Get the libary list information
SELECT * FROM QSYS2.LIBRARY_LIST_INFO;
-- Get the jobd of the current user and the current user name
SELECT a.JOBD,CURRENT USER FROM QSYS2.USER_INFO a WHERE AUTHORIZATION_NAME = CURRENT USER;
-- Get Job log information
SELECT * FROM table(QSYS2.JOBLOG_INFO('*')) a;
-- Get Even more info from the Special Registers
SELECT CURRENT CLIENT_ACCTNG AS ACCOUNTINGSTRINGSPCREG,
CURRENT CLIENT_APPLNAME AS APPLICATIONNAMESPCREG,
CURRENT CLIENT_PROGRAMID AS CLIENTPROGRAMIDSPCREG,
#WorkSpace
export GOPATH=$HOME/work
#Binaries produced by GO
export PATH=$PATH:$GOPATH/bin
@phpdave
phpdave / hello.go
Created January 10, 2017 03:48
Hello World Go Lang
package main
import (
"fmt"
"github.com/phpdave/string"
)
func main() {
fmt.Printf(string.Reverse("\nHello I'm writing some go code\n"))
}
@phpdave
phpdave / Converting MDDYY to YYYYMMDD.sql
Created December 9, 2016 15:23
Figuring out if SQL is slow because of date manipulation into YYYYMMDD format and whats the best way to approach this.
--TRANSDATE is Decimal(6,0) with no leading zero in MDDYY format in a 4 million record file
--i.e. 10199, 10116, 120816
WITH TABLE_TRANSACTION_WITH_YYYYMMMD_DATE as
(
SELECT a.*,
CASE
WHEN SUBSTR(DIGITS(TRANSDATE),5,2)>70 THEN '19' || SUBSTR(DIGITS(TRANSDATE),5,2) || SUBSTR(DIGITS(TRANSDATE),1,4)
ELSE '20' || SUBSTR(DIGITS(TRANSDATE),5,2) || SUBSTR(DIGITS(TRANSDATE),1,4)
END AS TRANSDATEYYYYMMDD
FROM MYLIB.TRANSACTIONS a
@phpdave
phpdave / Temporary File In PHP.php
Created November 1, 2016 13:24
Creating a temporary file in PHP
<?
$temp = tempnam(sys_get_temp_dir(), 'Prefix');
//or
$temp = tmpfile();
fwrite($temp, "Hello There!");
fseek($temp, 0);
// or could do rewind($temp)
echo fread($temp, 1024);
fclose($temp); // this removes the file
@phpdave
phpdave / CreateView.sql
Last active October 27, 2016 14:20
Instead of Trigger for IBM i DB2
/* Creating view MYLIB.ACCOUNTVIEW */
CREATE OR REPLACE VIEW MYLIB.ACCOUNTVIEW AS
SELECT
CMPNME AS COMPANY_NAME,
ADDR AS COMPANY_ADDRESS
FROM MYLIB.ACCTPF;
/* Setting system view name to ACCOUNTVIE for MYLIB.ACCOUNTVIEW */
RENAME MYLIB.ACCOUNTVIEW TO SYSTEM NAME ACCOUNTVIE;
#create customer
? curl -XPUT "localhost:9200/customer?pretty"
{
"acknowledged" : true,
"shards_acknowledged" : true
}
#view indices
? curl "localhost:9200/_cat/indices?v"
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open customer RqYz-8QcSq-BrmMhbRDRQw 5 1 0 0 650b 650b
CREATE SEQUENCE MYLIB.MYAUTO_INCREMENTING_SEQ
AS BIGINT
START WITH 1
INCREMENT BY 1
NO ORDER
NO CYCLE
NO MINVALUE
NO MAXVALUE
CACHE 20;
#Server (note sometimes nc is netcat instead)
nc -v -v -l -n -p 2222 >/dev/null
#Client
time yes|nc -v -v -n 192.168.0.8 2222 >/dev/null
#Stop by using ctrl+c
sent 87478392, rcvd 0
real 0m9.993s
#Take the bytes sent times by 8 (conversion bytes->bits) and divided by time elapsed to get Mb/s (Megabits per second)
#70Mb/s (=87478392*8/9.993)
appView.getView().setId(100);
appView.getView().setLayoutParams(new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
setContentView(appView.getView());
if (preferences.contains("BackgroundColor")) {
int backgroundColor = preferences.getInteger("BackgroundColor", Color.BLACK);
// Background of activity: