Skip to content

Instantly share code, notes, and snippets.

@sancarn
sancarn / CGSPrivate.h
Created May 15, 2017 20:30 — forked from siddhantjain/CGSPrivate.h
CGSPrivate.h - undocumented APIs for OSX. Re-licensed under MIT licence.
/* CGSPrivate.h -- Header file for undocumented CoreGraphics stuff. */
/* This file is a relicensed portion of DesktopManager and was originally released under
* the terms of the GNU General Public Licence. Original licence text follows the new terms.
* The contents of this file has been re-released by the original author under the following terms:
*
* Copyright (C) 2003, 2004, 2013 Richard J Wareham <richwareham@users.sourceforge.net>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
* software and associated documentation files (the "Software"), to deal in the Software
@sancarn
sancarn / .InfoWorks ICM - Node naming defaults with Ruby.md
Last active February 5, 2018 10:57
InfoWorks ICM - Node naming defaults with Ruby

InfoWorks ICM - Node naming defaults with Ruby

Many water companies provide guidelines to their consultants/staff defining how to name dummy nodes in a hydraulic model. This gives the water company full leverage over the hydraulic model externally and keeps data organised. However, for the most part, these conventions are easy to talk about but difficult to remember...

A hydraulic modeller often doesn't get payed for searching through the, often verbose, documentation on model building to find what they should use while naming their nodes. Instead, they often choose one standard and stick with it. To make the modeller's lives a little easier we can build a 'model build' ruby script library/add-on. Something which provides functionality which is so useful a modeller is insentifised to use it. In such a library we can include our node-naming conventions.

Custom node naming defaults

A well known feature of ICM is that you can automatically generate node names following a selected format.

@sancarn
sancarn / .Ruby InfoWorksICM Encryption.md
Last active February 5, 2018 10:58
Article to transfer to linkedin

Encryption in InfoWorks ICM using Ruby

What is Encryption?

Over the past few months I have been spending a large amount of time wondering how to encrypt data using Ruby, in InfoWorks ICM. For those who don't know, encryption refers to the process of transforming sensitive data into an unreadable form where it is unlikely to be intercepted by unauthorized viewers.

Note: Encryption does have other uses, for example, file modification prevention and software signing.

From the description above you might be able to see why encryption is so important, especially when handling sensitive client data. In hydraulic modelling this is often overlooked. However if the results or comments inside a hydraulic model became public, clients may be put in an uncomfortable position. Of course, as professionals this is something that we would like to avoid at all costs.

ListView control in Excel spreadsheets

List view controls can be exceptionally useful for viewing data on a spreadsheet.

Step 1: Add control to spreadsheet.

Click on the Insert dropdown button in the Controls group of the Developer tab. When here click the More controls button of the ActiveX Controls sub menu.

Step 2: Find ListView control

Hello everyone! In this video we will briefly cover the current features of the health and safety database, as well as those currently waiting to be implemented.

When you first launch the viewer you are greeted with a password box. If you enter a password incorrectly you well be prompted and will have to try again. If you don’t know the password then you won’t be able to access any new information from the server.

After entering the password you'll be greeted with the 'search engine'. Here you can type any text and the database will score every record against the text you entered. For example, if I wanted to search for an employee, I can simply type the employees name. To search for a specific department, I can type all or part of the department's name, "Quantity" in this example. To search for all employees who are managed by a particular person, I can type that person's name, in this example "Hamilton". The more the query I enter is mentioned for a specific employee, the higher that employee will rank in

MapBasic - Comments in MapInfo Project File.md

2 years ago I visited the MapInfo User Group UK conference held at the Institution of Engineering and Technology (IET), Birmingham. At the conference I met Peter Horsbøll Møller. At the time I hadn't had much experience with MapBasic Project (.mbp) files. A MapBasic project is often required when working on large projects or using libraries that others have made. The basic layout of a MapBasic project is as follows:

[Link]
Application = UpdateFromAmp5.mbx
Module = UpdateFromAmp5.MBO  
Module = FULL_RIBBON.MBO

Issue:

#"Starting REPL..."
3743
#>3743
sim = _.db.model_object_from_type_and_id("Sim",3743)
#>#<WSSimObject:0x00000031f63c28>
sim.list_max_results_attributes
#> Error: The method cannot be run from the user interface
# This method of obtaining objects is WIP
$instances = {}
$instances[:WSOpenNetwork] = WSApplication.current_network
$instances[:WSDatabase] = WSApplication.current_database
$instances[:WSModelObjectCollection] = $instances[:WSDatabase].model_object.collection("Model Group")
$instances[:WSModelObject] = $instances[:WSModelObjectCollection][0]
$instances[:WSNumbatNetworkObject] = $instances[:WSDatabase].model_object.collection("Model Network")[0]
$instances[:WSSimObject] = $instances[:WSDatabase].model_object.collection("Sim")[0]

Infoworks ICM - Illusive Macros in SQL

In InfoWorks ICM intermediate users may use SQL queries to automate their workflows. One part of the SQL system in InfoWorks which is fairly misunderstood is the macro system.

To be fair, macros aren't really explained very well in the help file either... The explanation given is as follows:

Macros are variables for representing values within a query. The Macro dialog is displayed when you click on either the button or the button on the User Macros tab on the SQL dialog. Enter a title and value for the macro, then click on OK.

Though this is correct, it is also a bit misleading. In this article I want to go into a little more detail as to what the Macro system actually does, and bounce around some ideas as to how it can be used.

Infoworks ICM - AFX and MFC

Ever since I started working with ICM, I have been tasked with automating aspects of it. I started my journey with knowing nothing about ICM, Ruby scripting, or even SQLs for that matter. Initially I automated ICM like I automate most applications, using low-level Windows APIs.

https://www.youtube.com/watch?v=zHVeZP6DQ2Q

I still remember having a conversation with an Innovyze support employee, while I was reporting a 'bug' where a dialog button wasn't being 'clicked' when I used PostMessage, but was only if I used SendMessage... In the end though, it wasn't really a bug, but myself misunderstanding which windows messages are used for which purposes.

Gradually over the years I have built up my knowledge of how ICM works and how to automate each aspect of it. Whether that be autonymously creating, setting up and running sims, finding and performing actions on database model objects, exporting a number of model networks, or using Ruby scripting to perform detailed analysis o