├── .dockerignore ├── .gitignore ├── .gitattributes ├── iris.script ├── docker-compose.yml ├── src └── dc │ └── aoc2022 │ ├── Base.cls │ └── Day1.cls ├── module.xml ├── .github └── workflows │ └── objectscript-quality.yml ├── .vscode ├── launch.json └── settings.json ├── Dockerfile ├── LICENSE ├── data └── input1.txt ├── dev.md └── README.md /.dockerignore: -------------------------------------------------------------------------------- 1 | **/.DS_Store 2 | .git -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sh text eol=lf 2 | *.cls text eol=lf 3 | *.mac text eol=lf 4 | *.int text eol=lf 5 | Dockerfil* text eol=lf -------------------------------------------------------------------------------- /iris.script: -------------------------------------------------------------------------------- 1 | zn "%SYS" 2 | Do ##class(Security.Users).UnExpireUserPasswords("*") 3 | 4 | zn "USER" 5 | zpm "load /opt/irisapp/ -v":1:1 6 | halt 7 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | iris: 4 | build: 5 | context: . 6 | dockerfile: Dockerfile 7 | restart: always 8 | command: --check-caps false 9 | ports: 10 | - 1972 11 | - 52773 12 | - 53773 13 | volumes: 14 | - ./:/irisdev/app -------------------------------------------------------------------------------- /src/dc/aoc2022/Base.cls: -------------------------------------------------------------------------------- 1 | Class dc.aoc2022.Base 2 | { 3 | 4 | Parameter Folder = "/irisdev/app/data/"; 5 | 6 | ClassMethod GetInput(fn) As %Stream 7 | { 8 | 9 | set fn=..#Folder_fn 10 | set stream = ##Class(%Stream.FileCharacter).%New() 11 | set sc=stream.LinkToFile(fn) 12 | return stream 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /module.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | aoc-template 6 | 1.0.0 7 | module 8 | src 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.github/workflows/objectscript-quality.yml: -------------------------------------------------------------------------------- 1 | name: objectscriptquality 2 | on: push 3 | 4 | jobs: 5 | linux: 6 | name: Linux build 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - name: Execute ObjectScript Quality Analysis 11 | run: wget https://raw.githubusercontent.com/litesolutions/objectscriptquality-jenkins-integration/master/iris-community-hook.sh && sh ./iris-community-hook.sh 12 | 13 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "type": "objectscript", 6 | "request": "launch", 7 | "name": "ObjectScript Debug Class", 8 | "program": "##class(PackageSample.ObjectScript).Test()", 9 | }, 10 | { 11 | "type": "objectscript", 12 | "request": "attach", 13 | "name": "ObjectScript Attach", 14 | "processId": "${command:PickProcess}", 15 | "system": true 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=intersystemsdc/irishealth-community:2020.3.0.200.0-zpm 2 | ARG IMAGE=intersystemsdc/iris-community:2020.3.0.221.0-zpm 3 | ARG IMAGE=intersystemsdc/iris-community:2020.4.0.524.0-zpm 4 | ARG IMAGE=intersystemsdc/iris-community 5 | FROM $IMAGE 6 | 7 | 8 | WORKDIR /opt/irisapp 9 | ARG TESTS=0 10 | ARG MODULE="dc-sample-template" 11 | ARG NAMESPACE="IRISAPP" 12 | 13 | #COPY Installer.cls . 14 | RUN --mount=type=bind,src=.,dst=. \ 15 | iris start IRIS && \ 16 | iris session IRIS < iris.script && \ 17 | ([ $TESTS -eq 0 ] || iris session iris -U $NAMESPACE "##class(%ZPM.PackageManager).Shell(\"test $MODULE -v -only\",1,1)") && \ 18 | iris stop IRIS quietly 19 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | 4 | "Dockerfile*": "dockerfile", 5 | "iris.script": "objectscript" 6 | }, 7 | "objectscript.conn" :{ 8 | "ns": "USER", 9 | "username": "_SYSTEM", 10 | "password": "SYS", 11 | "docker-compose": { 12 | "service": "iris", 13 | "internalPort": 52773 14 | }, 15 | "active": true 16 | }, 17 | "sqltools.connections": [ 18 | { 19 | "namespace": "USER", 20 | "connectionMethod": "Server and Port", 21 | "showSystem": false, 22 | "previewLimit": 50, 23 | "server": "localhost", 24 | "port": 32770, 25 | "askForPassword": false, 26 | "driver": "InterSystems IRIS", 27 | "name": "objectscript-docker", 28 | "username": "_SYSTEM", 29 | "password": "SYS" 30 | } 31 | ] 32 | 33 | } -------------------------------------------------------------------------------- /src/dc/aoc2022/Day1.cls: -------------------------------------------------------------------------------- 1 | Class dc.aoc2022.Day1 Extends dc.aoc2022.Base 2 | { 3 | 4 | Parameter InputFile = "input1.txt"; 5 | 6 | // w ##class(dc.aoc2022.Day1).Run() 7 | 8 | ClassMethod Run(verbose = 0) As %Integer 9 | { 10 | set stream=..GetInput(..#InputFile) 11 | set sum=0 12 | while 'stream.AtEnd { 13 | set line=stream.ReadLine() 14 | set line=line\3-2 15 | set sum=sum+line 16 | if verbose write "line="_line," ","sum="_sum,! 17 | } 18 | return sum 19 | } 20 | 21 | ClassMethod Run2(verbose = 0) As %Integer 22 | { 23 | 24 | set stream=..GetInput(..#InputFile) 25 | set sum=0 26 | while 'stream.AtEnd { 27 | set line=stream.ReadLine() 28 | set fuel=line 29 | set full=0 30 | for { 31 | set fuel=fuel\3-2 32 | quit:fuel<0 33 | set full=full+fuel 34 | } 35 | set sum=sum+full 36 | if verbose write "line="_line," ","sum="_sum,! 37 | } 38 | 39 | return sum 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 InterSystems Developer Community 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /data/input1.txt: -------------------------------------------------------------------------------- 1 | 55131 2 | 114008 3 | 145297 4 | 76135 5 | 50317 6 | 134036 7 | 122136 8 | 97704 9 | 51245 10 | 141732 11 | 120427 12 | 142020 13 | 88166 14 | 55313 15 | 110391 16 | 112436 17 | 78195 18 | 74294 19 | 128984 20 | 68240 21 | 137098 22 | 142016 23 | 83577 24 | 89257 25 | 107744 26 | 67357 27 | 131342 28 | 98247 29 | 137501 30 | 134577 31 | 65696 32 | 84925 33 | 50159 34 | 110319 35 | 91921 36 | 103303 37 | 84505 38 | 84683 39 | 100811 40 | 82626 41 | 66774 42 | 123216 43 | 95151 44 | 88237 45 | 60705 46 | 124319 47 | 102926 48 | 143160 49 | 92780 50 | 64283 51 | 132434 52 | 113935 53 | 84907 54 | 113698 55 | 117240 56 | 129327 57 | 78837 58 | 144841 59 | 138054 60 | 130990 61 | 100191 62 | 141768 63 | 138941 64 | 108165 65 | 62138 66 | 121690 67 | 117305 68 | 90147 69 | 134422 70 | 78031 71 | 121331 72 | 120947 73 | 120235 74 | 138880 75 | 141076 76 | 119480 77 | 66844 78 | 77660 79 | 106364 80 | 99187 81 | 144244 82 | 120483 83 | 77715 84 | 135703 85 | 125521 86 | 123253 87 | 127556 88 | 96458 89 | 91965 90 | 73924 91 | 95176 92 | 87540 93 | 122083 94 | 146013 95 | 67761 96 | 100413 97 | 145994 98 | 149450 99 | 94330 100 | 112824 -------------------------------------------------------------------------------- /dev.md: -------------------------------------------------------------------------------- 1 | # useful commands 2 | ## clean up docker 3 | ``` 4 | docker system prune -f 5 | ``` 6 | 7 | ## build container with no cache 8 | ``` 9 | docker-compose build --no-cache 10 | ``` 11 | ## start iris container 12 | ``` 13 | docker-compose up -d 14 | ``` 15 | 16 | ## open iris terminal in docker 17 | ``` 18 | docker-compose exec iris iris session iris -U IRISAPP 19 | ``` 20 | 21 | ## load code from source folder to docker 22 | it loads and compiles all the objectscript from /src folder 23 | ``` 24 | do $System.OBJ.LoadDir("/opt/irisapp/src","ck",,1) 25 | 26 | ``` 27 | 28 | 29 | ## install docker-compose 30 | ``` 31 | sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose 32 | 33 | sudo chmod +x /usr/local/bin/docker-compose 34 | 35 | ``` 36 | 37 | ## select zpm test registry 38 | ``` 39 | repo -n registry -r -url https://test.pm.community.intersystems.com/registry/ -user test -pass PassWord42 40 | ``` 41 | 42 | ## get back to public zpm registry 43 | ``` 44 | repo -r -n registry -url https://pm.community.intersystems.com/ 45 | ``` 46 | 47 | ## create a web app in dockerfile 48 | ``` 49 | zn "%SYS" \ 50 | write "Create web application ...",! \ 51 | set webName = "/csp/irisweb" \ 52 | set webProperties("NameSpace") = "IRISAPP" \ 53 | set webProperties("Enabled") = 1 \ 54 | set webProperties("CSPZENEnabled") = 1 \ 55 | set webProperties("AutheEnabled") = 32 \ 56 | set webProperties("iKnowEnabled") = 1 \ 57 | set webProperties("DeepSeeEnabled") = 1 \ 58 | set sc = ##class(Security.Applications).Create(webName, .webProperties) \ 59 | write "Web application "_webName_" has been created!",! 60 | ``` 61 | 62 | zw ##class(community.csvgen).GenerateFromURL("https://github.com/h2oai/h2o-tutorials/raw/master/h2o-world-2017/automl/data/product_backorders.csv") 63 | 64 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## aoc2020-template 2 | This is a template for [Advent of Code](https://adventofcode.com/) ObjectScript contest. 3 | ## Prerequisites 4 | Make sure you have [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [Docker desktop](https://www.docker.com/products/docker-desktop) installed. 5 | 6 | ## Installation 7 | 8 | Clone/git pull the repo into any local directory 9 | 10 | ``` 11 | $ git clone git@github.com:intersystems-community/aoc-objectscript-template.git 12 | ``` 13 | 14 | Open the terminal in this directory and run: 15 | 16 | ``` 17 | $ docker-compose build 18 | ``` 19 | 20 | 3. Run the IRIS container with your project: 21 | 22 | ``` 23 | $ docker-compose up -d 24 | ``` 25 | 26 | ## How to Test it 27 | 28 | Open IRIS terminal: 29 | 30 | ``` 31 | $ docker-compose exec iris iris session iris 32 | USER>w ##class(dc.aoc2022.Day1).Run() 33 | ``` 34 | ## How to start coding 35 | This repository is ready to code in VSCode with ObjectScript plugin. 36 | Install [VSCode](https://code.visualstudio.com/), [Docker](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker) and [ObjectScript](https://marketplace.visualstudio.com/items?itemName=daimor.vscode-objectscript) plugin and open the folder in VSCode. 37 | Open /src/cls/PackageSample/ObjectScript.cls class and try to make changes - it will be compiled in running IRIS docker container. 38 | 39 | Feel free to delete PackageSample folder and place your ObjectScript classes in a form 40 | /src/Package/Classname.cls 41 | [Read more about folder setup for InterSystems ObjectScript](https://community.intersystems.com/post/simplified-objectscript-source-folder-structure-package-manager) 42 | 43 | The script in Installer.cls will import everything you place under /src into IRIS. 44 | 45 | 46 | ## What's inside the repository 47 | 48 | ### Dockerfile 49 | 50 | The simplest dockerfile which starts IRIS and imports code from /src folder into it. 51 | Use the related docker-compose.yml to easily setup additional parametes like port number and where you map keys and host folders. 52 | 53 | ### iris.script 54 | 55 | Setup Objectscript code which is being executed during docker build phase 56 | 57 | ### .vscode/settings.json 58 | 59 | Settings file to let you immedietly code in VSCode with [VSCode ObjectScript plugin](https://marketplace.visualstudio.com/items?itemName=daimor.vscode-objectscript)) 60 | 61 | ### .vscode/launch.json 62 | Config file if you want to debug with VSCode ObjectScript 63 | 64 | [Read about all the files in this artilce](https://community.intersystems.com/post/dockerfile-and-friends-or-how-run-and-collaborate-objectscript-projects-intersystems-iris) 65 | --------------------------------------------------------------------------------