Skip to content

Instantly share code, notes, and snippets.

View isc-rsingh's full-sized avatar

Raj Singh isc-rsingh

View GitHub Profile
{
"datasets": [
{
"name": "The Museum of Modern Art (MoMA) Collection",
"url": "https://github.com/MuseumofModernArt/collection"
},
{
"name": "Coronavirus (Covid-19) Data in the United States",
"url": "https://github.com/nytimes/covid-19-data"
},
@isc-rsingh
isc-rsingh / installzpm.cls
Created February 14, 2022 16:29
Script for InterSystems IRIS terminal. Useful if you don't have ZPM in your IRIS and can install with this one call in the terminal. Courtesy of @guillaume Rongier and @sergei Shutov and @Sergey Mikhailenko
set $namespace="%SYS" do ##class(Security.SSLConfigs).Create("ssl") set r=##class(%Net.HttpRequest).%New(),r.Server="pm.community.intersystems.com",r.SSLConfiguration="ssl" do r.Get("/packages/zpm/latest/installer"),$system.OBJ.LoadStream(r.HttpResponse.Data,"c")
@isc-rsingh
isc-rsingh / cleanbostoncrimes.py
Last active May 2, 2021 03:34
Cleans up broken lines and unquoted strings in Boston crime incident data CSV files
# get the data from https://data.boston.gov/dataset/crime-incident-reports-august-2015-to-date-source-new-system
badfile = open('bostonpolice.csv', 'r')
betterfile = open('tmp.csv', 'w')
while True:
line = badfile.readline().strip()
if not line:
break
# figure out if the line has been broken incorrectly
@isc-rsingh
isc-rsingh / irisflask.py
Created October 7, 2020 14:10
Python Flask middleware app with InterSystems IRIS as the back end database
import pyodbc
from flask import Flask
from flask import request
from flask import render_template
import json
app = Flask(__name__)
connection = None
# default route
@app.route('/')
@isc-rsingh
isc-rsingh / pyodbc_iris_install.md
Created October 4, 2020 03:04
Get ODBC, PyODBC up and running for InterSystems IRIS

PyODBC installation instructions

Install ODBC

  • Windows: no installation necessary
  • Mac
    1. Run brew update
    2. Run brew install unixodbc
  • Linux
  1. Run apt-get update
@isc-rsingh
isc-rsingh / ConcatArrays.cls
Created May 4, 2020 14:00
Concatenate JSON arrays in ObjectScript
/// ObjectScript does not include any built-in method for appending one JSON dynamic array to another.
/// This is equivalent to the JavaScript concat() method.
/// Call it with any number of arguments to concatenate them into a new array.
/// If an argument is a dynamic array, its elements will be added. Otherwise the argument itself will be added.
/// Thanks to Pravin Barton in this article https://community.intersystems.com/post/code-sample-concatenate-json-arrays
ClassMethod ConcatArrays(pArgs...) As %DynamicArray
{
set outArray = ##class(%DynamicArray).%New() // or []
for i=1:1:pArgs {
set arg = pArgs(i)
ROUTINE RightTriangle
/* compute area and hypotenuse of a right triangle
this routine contains examples of
new ObjectScript features */
Write !, "Compute the area and hypotenuse of a right triangle",
!, "given the lengths of its two sides."
Set units = "feet"
Set side1 = 3
Set side2 = 6
Do Compute( units, side1, side2)
@isc-rsingh
isc-rsingh / csv2objectscript.cls
Last active November 19, 2019 15:56
The simplest snippet to read from file in InterSystems Caché
set file = ##class(%File).%New( "data.csv" )
set sc = file.Open( "R" )
if $$$ISERR(sc) quit ; or do smth
while 'file.AtEnd {
set str=file.ReadLine()
for i=1:1:$length( str, ";" ) {
set id=$piece( str, ";" ,i )
write !, id // or do smth
}
@isc-rsingh
isc-rsingh / acs_income_metadata.tsv
Last active October 4, 2018 18:55
metadata example for ACS income
What 2017 American Community Survey 1-Year Estimates INCOME IN THE PAST 12 MONTHS (IN 2017 INFLATION-ADJUSTED DOLLARS)
When 2017
Where US
Who US Census Bureau
How Survey https://www.census.gov/programs-surveys/acs/about.html
Which I don’t know. Probably custom software built by the Census.
Why Public officials, planners, and entrepreneurs use this information to assess the past and plan the future. When you respond to the ACS, you are doing your part to help your community plan for hospitals and schools, support school lunch programs, improve emergency services, build bridges, and inform businesses looking to add jobs and expand to new markets, and more.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.