Skip to content

Instantly share code, notes, and snippets.

@mnjstwins
mnjstwins / search.csp
Created December 9, 2016 18:35 — forked from mhulse/search.csp
Caché DTI ContentPublisher: Tested in 7.6, 7.7.2: DEMO: Sorting search results by CMSStory property (in this case, I'm using publishedToWebDate")...
<csp:comment>
/// Sort ListObjects based on one or more properties.<br>
/// obj: A list object.<br>
/// dir: Direction, 1 ascending, -1 descending.<br>
/// prp: A property name.<br>
/// (c) 2008 J.Kavay<br>
/// Ref: http://groups.google.com/group/intersystems-public-cache/browse_thread/thread/289bc2e02e4875ff
</csp:comment>
<script language="cache" method="multiSortListObj" arguments='obj:%ListOfObjects=-1, dir:%Integer=1, prp...' returntype="%ListOfObjects" procedureblock="1">
@mnjstwins
mnjstwins / Using %ResultSet.SQL
Created December 9, 2016 18:34 — forked from mccrackend/Using %ResultSet.SQL
Using %ResultSet.SQL Objects for query results. Written in Intersystems Cache Object Script.
ResultSetSample()
// Build query string
Set sql = "Select Value, DateTimeStamp From Spectrum_Support_Metrics.EnsPerformanceMetricsData Where " _
"CheckType = 'datasize' AND " _
"Detail = '/ensemble/mgr/PROD/' AND " _
"DateTimeStamp > '201012170930'"
// Create new resultSet object to work with called "rs". It's basically a cursor.
// This %Prepare command executes the query contained in "sql", sets the result to "rs", and gives an "error" flag back.
Set rs = ##class(%ResultSet.SQL).%Prepare(sql,.error,"")
@mnjstwins
mnjstwins / cosJSON.isc
Created December 9, 2016 18:33 — forked from isc-bspead/cosJSON.isc
Macros for writing forward compatible JSON code in InterSystems Caché 2016.1
#include %occReference
#if $$$comClassDefined("%Library.Object")
#define jsonClassIsLatestVersion $classIsLatestVersion
//usage: obj.$$$jsonClassIsLatestVersion()
#define jsonExtends $extends
//usage: {}.$$$jsonExtends(classname)
#define jsonFromJSON $fromJSON
//usage: {}.$$$jsonFromJSON(string)
#define jsonGetIterator $getIterator
//usage: obj.$$$jsonGetIterator()
@mnjstwins
mnjstwins / ccontrol
Created December 9, 2016 18:33 — forked from daimor/ccontrol
bash completions for InterSystems cache
#!/bin/bash
# bash completions for InterSystems ccontrol
_instances()
{
if [ $# == 0 ] || [ $1 == "all" ]; then
echo $(ccontrol qlist | cut -d'^' -f1 | tr '\n' ' ')
else
echo $(ccontrol qlist | grep "\^$1\," | cut -d'^' -f1 | tr '\n' ' ')
fi
@mnjstwins
mnjstwins / DO.Utils.xml
Created December 9, 2016 18:33 — forked from eduard93/DO.Utils.xml
Work with Digital Ocean from InterSystems Caché
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25" zv="Cache for UNIX (Red Hat Enterprise Linux for x86-64) 2015.2 (Build 664U)" ts="2016-04-05 13:01:04">
<Class name="DO.Utils">
<Super>%CSP.REST</Super>
<TimeChanged>64013,44584.975713</TimeChanged>
<TimeCreated>64013,41190.502637</TimeCreated>
<Parameter name="KEY">
<Description>
Your API token</Description>
@mnjstwins
mnjstwins / intersystems.md
Created December 9, 2016 18:33 — forked from ayushjain7/intersystems.md
Why intersystems?
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2016.4 (Build 555U JAVAINTEG)" ts="2016-07-18 15:27:06">
<Class name="Sample.LoggingProxy">
<Description>
simple sample of a logging proxy object:
each access (via call or property access) will
be logged to the designated global</Description>
<Super>%RegisteredObject</Super>
<TimeChanged>64116,57644.95789</TimeChanged>
<TimeCreated>64110,60845.71095</TimeCreated>
@mnjstwins
mnjstwins / GistCreator.java
Created July 29, 2016 14:39 — forked from kevinsawicki/GistCreator.java
Create Gists using the GitHub v3 Java API
GitHubClient client = new GitHubClient().setCredentials("user", "p4ssw0rd");
Gist gist = new Gist().setDescription("Prints a string to standard out");
GistFile file = new GistFile().setContent("System.out.println(\"Hello World\");");
gist.setFiles(Collections.singletonMap("Hello.java", file));
gist = new GistService(client).createGist(gist);
@mnjstwins
mnjstwins / 1-merging-or-extending-arrays-in-csharp.cs
Created July 9, 2016 16:31 — forked from lsauer/1-merging-or-extending-arrays-in-csharp.cs
C#: Merging,Appending, Extending two arrays in .NET (csharp, mono)
//www.technical-programming.com, lorenz lo sauer, 2013
//description: extending C# for fast and easy string extension
//note: part of a larger Open-Source Project-Codebase
//see: http://stackoverflow.com/questions/59217/merging-two-arrays-in-net
//resides in IEnumerableStringExtensions.cs
public static class IEnumerableStringExtensions
{
public static IEnumerable<string> Append(this string[] arrayInitial, object arrayToAppend)
{
@mnjstwins
mnjstwins / DC.LoopPerformance.cls
Created June 1, 2016 15:48 — forked from timleavitt/DC.LoopPerformance.cls
Caché ObjectScript demo - various loops to iterate over pieces of a delimited string
/// This class demonstrates the performance of various loops that iterate over the pieces of a delimited string.
Class DC.LoopPerformance
{
ClassMethod Run(pIterations As %Integer = 10000, pPieceLength As %Integer = 20, pNumberPieces = 100, pDelimiter = ",")
{
#define START(%msg) Write %msg Set start = $zh
#define END Write ($zh - start)," seconds",!
// Build a random string given the specifications