14:09, 4th August 2021
SAS OnDemand for Academics
SAS OnDemand for Academics offers cloud-based access to statistical analysis, data mining and forecasting tools, enabling independent learners, students and instructors to use SAS software free of charge. Users register through a dedicated application, upload data and access SAS Studio for learning or teaching purposes, with specific guidance provided for each role. The service relies on remote servers to process tasks, which may occasionally require maintenance during non-traditional hours, with updates posted on a status page. Additional resources include tutorials, e-courses, books, community forums and training programs to support users in developing skills with SAS technology, alongside FAQs and documentation tailored to different user categories.
14:01, 4th August 2021
Authentication to SAS Viya: a couple of approaches
Connecting an external application to SAS Viya via its REST APIs requires authentication through OAuth 2.0, and there are three main grant types available depending on the use case. The authorisation code grant is considered the most secure option and is best suited to web applications, while the client credentials grant operates without a specific user context and is scoped to the authorities registered to the client. The password grant, though supported, is not recommended for production environments due to security concerns.
Regardless of grant type, the process begins with a SAS administrator generating a bearer token and using it to register a client ID and secret. From SAS Viya 2023.1 onwards, this no longer requires a Consul token, as members of the SAS Administrators group can generate the necessary access token directly. Once the client is registered and an authorisation code obtained, an access token and refresh token are issued and used to authenticate subsequent API calls. Access tokens expire after ten hours by default, but can be renewed using the refresh token, which itself expires after thirty days. Both values are configurable within SAS environment settings. The password and client credentials grant types follow a similar registration process but bypass the browser-based authorisation code step, making them more suitable for automated or trusted environments.
09:02, 4th August 2021
The SAS/ACCESS Developer's Corner: SUBCHAR-acteristics
When querying database management system data through SAS/ACCESS LIBNAME engines, character encoding differences between systems can cause transcoding errors that prevent data from being read into SAS correctly. The SUBCHAR= option, also known by its alias SUBSTITUTION_CHAR, was introduced to help address this by allowing users to configure how the SAS/ACCESS engine handles such errors within the engine itself, though it does not resolve issues originating in the underlying database client.
The option accepts four values, namely QUESTIONMARK, SPACE, SUB and UESC, each of which determines what character is substituted in place of any character that cannot be represented in the current SAS session encoding. When the option is active, a warning is recorded in the SAS log to signal that substitution has occurred, and users can enable the sastrace facility to obtain more detailed information about which columns and rows contain problematic characters.
The UESC value is particularly useful as it replaces incompatible characters with their Unicode escape sequences, making it possible to identify exactly what could not be translated. As of the time of writing, the option is supported across a range of platforms including Amazon Redshift, PostgreSQL, Microsoft SQL Server, Spark and several others.
09:02, 4th August 2021
JuMP | JuMP is a modelling language and supporting packages for mathematical optimisation in Julia.
JuMP is a modelling language and collection of packages designed to simplify the formulation and solution of various optimisation problems, such as linear, integer and nonlinear programs, with applications spanning industries like energy, transportation and education. It is utilised in real-world scenarios including inventory routing, power grid planning and academic research, while also serving as a teaching tool at universities globally. Resources for learning and implementing JuMP include guides, community forums and third-party materials such as books on operations research. The project benefits from support by NumFOCUS, a nonprofit organisation that facilitates its sustainability through donations, which help fund events and development initiatives.
18:00, 27th July 2021
Linux append text to end of file
On Linux and Unix-like systems, the >> operator can be used in the command line to append content to the end of a file, creating the file if it does not already exist. This works with commands such as echo, date and ls, where the output is redirected and added to a specified file rather than overwriting it.
Both standard output and standard error can be appended simultaneously using the &>> syntax, or by combining >> with 2>&1. When elevated privileges are required, the tee command with the -a flag or sudo with the sh -c or bash -c options can be used to achieve the same result. Further detail on redirection behaviour can be found in the manual pages for bash, zsh and ksh.
17:59, 27th July 2021
Linux Add User To Group Using Command-Line
On Linux, users can belong to two types of groups: a primary group, which is applied at login and governs ownership of files and processes, and secondary groups, which allow access to shared resources and can be used to fine-tune system security. The useradd command is used to create new users and assign them to groups during account creation, while the usermod command is used to modify existing user accounts, including group membership.
To add a user to a supplementary group without removing them from their current groups, the usermod command should be used with both the -a and -G flags, for example usermod -a -G groupname username. New groups can be created using the groupadd command and removed using the groupdel command.
User and group information is stored across several system files, including /etc/passwd, /etc/shadow and /etc/group, though these should not be edited by hand. Group membership for a given user can be verified using either the id or groups command, and all groups on the system can be viewed by reading /etc/group or using the getent command.
14:12, 26th July 2021
These OpenCV-Python tutorials offer a structured guide to using the OpenCV library for computer vision tasks, covering essential topics such as setting up the environment, handling graphical user interface elements, performing core image manipulations and applying advanced techniques in image processing, feature detection, video analysis, camera calibration, machine learning, computational photography and object detection. Additional sections explore the development of Python bindings and provide practical examples to support learning and implementation of vision-related algorithms.
19:07, 24th July 2021
How to Exclude Files and Directories with Rsync
The rsync command-line utility offers flexible options for controlling which files and directories are included or excluded during a synchronisation operation. Using the --exclude flag, users can skip specific files or directories by passing their relative paths, while multiple exclusions can be handled either through repeated --exclude flags, shell brace expansion or by listing items in a separate file referenced with --exclude-from. Glob patterns allow exclusions based on file type or naming structure, and combining --include and --exclude rules enables transfers limited to only matching files.
Before committing to a full transfer, running rsync with the --dry-run and --verbose flags allows users to preview what will and will not be copied without making any actual changes. The --cvs-exclude option provides a convenient shorthand for automatically skipping common temporary and build-related files during project directory syncs, though explicit rules are still recommended for modern version control directories such as those used by Git or Subversion. For more advanced scenarios, the --filter option extends beyond simple exclusion rules by supporting additional modifiers and merge-file functionality, following the same first-match logic as the standard include and exclude options.
10:26, 21st July 2021
Time Travel with py datatable 1.0
Version 1.0 of datatable, the Python counterpart to the widely used R package data.table, introduced support for temporal data types through two new formats and an accompanying family of functions. The date32 type represents a calendar date without a time component, storing values internally as a 32-bit signed integer counting days from the epoch date of 1 January 1970, with a range spanning approximately 5.8 million years in either direction. The time64 type captures a specific moment, stored as a 64-bit integer measuring nanoseconds from the same epoch in UTC.
Both types support initialisation in several ways, including from integer values, ISO 8601 formatted strings and individual date or time components via the constructor functions ymd() and ymdt(). When working with non-standard date strings, a combination of casting and string slicing functions within the datatable API can be used to parse and convert values correctly. The datatable.time family also includes a range of part functions such as year(), month(), day() and hour(), which allow users to extract individual components from date or time columns and apply them in operations such as filtering.
14:57, 15th July 2021
Get image size (width, height) with Python, OpenCV, Pillow (PIL)
In Python, image dimensions can be retrieved using either OpenCV or Pillow (PIL), with a key difference in how each library orders width and height. OpenCV treats images as NumPy arrays, where the shape attribute returns dimensions in the order of height, width and channel for colour images, or height and width for greyscale images, meaning width and height must be accessed by their respective index positions or via tuple unpacking.
Pillow, by contrast, offers a more straightforward approach through its size attribute, which returns a (width, height) tuple directly, as well as dedicated width and height attributes that can be accessed individually, and this behaviour is consistent across both colour and greyscale images.