Press "Enter" to skip to content

Category: Misc Languages

Integrating VBA and R Code

Steven Sanderson has become Dr. Moreau. Part 1 shows how to call R code from VBA:

This line defines a subroutine called “CallRnorm”. A subroutine is a block of code that can be executed repeatedly from any part of the code, and it starts with the “Sub” keyword followed by the subroutine name and any arguments in parentheses.

Part 2, as you might expect, covers the obverse:

Yesterday I posted on using VBA to execute R code that is written inside of the VBA script. So today, I will go over a simple example on executing an R script from VBA. So let’s get into the code and what it does.

First, let’s look at the Function called “Run_R_Script”. This function takes four arguments, where the first two are mandatory, and the last two are optional.

Comments closed

An Introduction to Polyglot Notebooks

Matt Eland walks us through a sample:

Polyglot Notebooks allows you to create notebooks composed of multiple cells. These cells can be either markdown cells for documentation or code cells containing code in either C#, F#, PowerShell, SQL, KQL, HTML, JavaScript, or mermaid markdown for diagramming.

This allows you to mix together rich documentation supported by little pieces of code that progressively expand upon an idea, tell a story, or otherwise provide insight or information to you as a developer.

Click through for the example. The thing I hadn’t realized—because I don’t really do this in Jupyter—is that you can share variables between languages. That’s a fairly useful feature when you want to do most of your work in one language but just happen to need a library using a different language.

Comments closed

Working with .NET Polyglot Notebooks

Matt Eland installs Polyglot notebooks in VSCode:

Polyglot Notebooks is a powerful new interactive notebook technology that lets you run experiments in your editor, mix together code and rich documentation, and write code in a variety of languages to accomplish your tasks.

This article will guide you through the setup process to get Polyglot Notebooks running on your machine so you can do local data science and analytics notebooks using dotnet.

In case you’re curious, my installation has the ability to create notebooks in F#, C#, HTML, JavaScript, KQL, Markdown, Mermaid, Powershell, and SQL. I’m not positive how many of those come with the extension itself and how many are additional kernels I got from installing other extensions.

Comments closed

Building a URL Redirect Service in Azure

Bob Pusateri spams the 302 response code:

In WordPress, I used a plugin called Redirection, which enabled me to create URLs that would redirect to other websites. They can come in handy, especially when presenting. I’ll often create a custom redirect link for each presentation I give that will point my attendees toward my resources for that topic. For example, if I were giving a talk about isolation levels, I might direct attendees to visit https://sqlbob.com/isolation, which would redirect them to my GitHub repo with links to slides, demo code, and other materials.

But a HTML file really can’t redirect you to another page. To be fair, you can do it via a <meta> tag, but it’s not guaranteed to work in all browsers. I’m told there’s also a way to do it in JavaScript, but I really wanted a seamless experience for users like the Redirection plugin offered. I also was in need of a little project over the winter months.

Click through for Bob’s solution to the problem.

Comments closed

Understanding the Fold Function

Prakhar takes us through the fold function in functional programming, using Scala as the language of choice:

“fold” is a common operation in programming languages including Scala where we essentially use it to “reduce” (note that “reduce” is also an operation in programming languages and has a special meaning in Scala as well). In this blog, we will learn how to use the fold function, understand different types of fold operations (including foldLeft and foldRight), and try to understand how it all works. Although fold operation can be applied on Option, Future, Try, etc.. but here we will understand it through List

Fold is extremely useful for things like “I want to calculate a sum but it’s got to be a conditional sum” or when you have more complex mathematical operations to combine elements together. It can take a while to get comfortable with the syntax, but once you do, it opens mental doors.

Comments closed

Trying out DuckDB

Mark Litwintschik gives DuckDB a go:

DuckDB is primarily the work of Mark Raasveldt and Hannes Mühleisen. It’s made up of a million lines of C++ and runs as a stand-alone binary. Development is very active with the commit count on its GitHub repo doubling nearly every year since it began in 2018. DuckDB uses PostgreSQL’s SQL parser, Google’s RE2 regular expression engine and SQLite’s shell.

Click through to see how you can install it on Ubuntu, perform some basic configuration, and work with the tool.

Comments closed

A Primer on Stan

Jack Kennedy explains the concepts of Stan and JAGS:

You may have used a probabilistic programming language (PPL) in the past, such as BUGS, to perform Bayesian inference. You’ve heard about Stan and want to learn a little more. Or maybe you’re about to step into the Bayesian paradigm and don’t know where to start. You want to know whether you should make the switch from JAGS to Stan, or you’ve used neither of JAGS or Stan and want to know which will suit you best. This post will focus solely on the differences between JAGS and Stan as I have experience with both of them, but there are many more PPLs out there. For example, I have never used Bean Machine, but of all the PPLs, it certainly takes the crown for best name.

Stan has been on my to-learn list for a while and I did successfully get one of my employees (a rassa-frassin’ frequentist) to use and enjoy the power of Bayesian analysis. One of these days, I’ll have to get back to it.

Comments closed

Simplified Syntax for Scala 3

Anshika Agrawal shows a few examples of how Scala 3 is a bit easier to pick up than Scala 2:

Scala 3 is a remodel/refit for the scala language. It attracts developers due to its improved features such as simpler syntax, better type inference, improved error messages, and enhanced support for functional programming. In this article, we will compare the syntactical enhancement of Scala 2 & Scala 3. How indentation will help developers to write code efficiently and effortlessly.

Click through for some examples. On the whole, these are small but welcome changes in eliminating unnecessary code cruft.

Comments closed