Skip to content

Instantly share code, notes, and snippets.

View sween's full-sized avatar
💭
Mostly Good Intentions

Ron Sweeney sween

💭
Mostly Good Intentions
View GitHub Profile
try {
set tNPI = pRecord.NPI.NPI
set tSource=pContext.Data("Source")
// stop checking if DataSource is not available or coming from UI
If $E(pRecord.SourceID,1,4)="EID:" || (tSource="") Return $$$OK
;
set tSQL = "Select NPI from Local_PD_Linkage_Data.Individual WHERE SourceID=? AND Source=?"
set tRS = ##class(%SQL.Statement).%ExecDirect(,tSQL,pRecord.SourceID,tSource)
if tRS.%Next() {
if (tRS.NPI '=tNPI) {
@sween
sween / GetSmaller.java
Created October 22, 2015 17:52
reduce pdf size with iText
import com.itextpdf.*;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;
import com.itextpdf.text.pdf.PdfWriter;
import java.io.*;
public class MakeSmaller {
@sween
sween / gist:08d349d81408c425c43a
Created March 1, 2015 18:33
Tail a Global Intersystems
A couple ways to do this:
1. If your global is simply being incremented at the top level (something like set x=$increment(^FOO)), then you can do:
f { s st=$zh,prev=$g(^FOO) h 2 s next=$g(^FOO),now=$zh,time=(now-st),rate=(next-prev)/time w !,"Rate as of ",$zdt($h),": ",$fn(rate,",",2)," per sec; last value: ",next s prev=next}
It should show something like:
Rate as of 03/01/2015 11:15:41: 1.00 per sec; last value: 431
Rate as of 03/01/2015 11:15:43: 1.00 per sec; last value: 433
Rate as of 03/01/2015 11:15:45: 1.00 per sec; last value: 435
@sween
sween / gist:443f6830dfed7386b95d
Created February 27, 2015 19:44
Dynamic Class Method Calls
Set ..Request=$classmethod("HS.Message.Registry.Provider."_pRequestClass,"%New")
@sween
sween / import.cls
Created January 11, 2015 23:38
Import XML Into Class
ClassMethod Import()
{
// Create an instance of %XML.Reader
Set reader = ##class(%XML.Reader).%New()
// Begin processing of the file
Do reader.OpenFile("test.xml")
// Associate a class name with the XML element name
Do reader.Correlate("Person","MyApp.MyPerson")
// Read objects from xml file
While (reader.Next(.object,.sc)) {
@sween
sween / gist:e26e65ed6f621b3cd987
Created January 3, 2015 15:40
MySQL to InterSystems Ens Lookups via Go
package main
// Args to this bad boy are DATAMAP Name, mysql Table Name
// Hackity Hack, Dont Talk Back!
import (
_ "github.com/Go-SQL-Driver/MySQL"
"database/sql"
"fmt"
"time"
@sween
sween / gist:9ff1c285a6e1b237b976
Created December 12, 2014 15:53
List Namespaces
set data = %page.%GetComponentById("myDataCombo")
set tsc = ##Class(%SYS.Namespace).ListAll(.arrayNS)
set data.valueList = arrayNS
@sween
sween / gist:590c519e07593f736fdf
Last active August 29, 2015 14:07
Export All Ensemble
//Settings
set sc = ##class(Ens.Config.DefaultSettings).%Export("/hs/float/minion2controller/prodsettings.xml", "HIE.HIEMINION")
ClassMethod CreateExportXML(FileName As %String, excludedata As %Boolean = 1)
{
if $g(FileName)="" set FileName="C:\temp\ABCExport.xml"
//loop through various groups of items in the ABC application
@sween
sween / gist:e375f46ac50cbea3f239
Created October 8, 2014 19:05
OnGetConnections
/// This method is called when Ensemble Portal is drawing the production diagram
/// pArray contains the config names the scanner found.
/// Users can remove or add new names
ClassMethod OnGetConnections(Output pArray As %String, item As Ens.Config.Item)
{
Set $ZTrap = "OnGetConnectionsET"
Set (tValue,tIndex)="" For { Set tIndex = item.Settings.Next(tIndex) Quit:tIndex=""
Set tSetting = item.Settings.GetAt(tIndex)
If tSetting.Name="TargetConfigNames" Set tValue=tValue_","_tSetting.Value
}
set foo=bar^&ping -n -i google.com
echo %foo%