15:28, 8th October 2021
Scroll-linked Effects in Web Pages
Scroll-linked effects are webpage interactions where elements change based on scroll position, such as parallax scrolling, but these can perform poorly in modern browsers that use asynchronous scrolling to maintain a smooth 60 frames per second experience. Because asynchronous scrolling updates the visual scroll position on the compositor thread before the scroll event fires on the main thread, JavaScript-driven scroll effects tend to lag behind what the user sees, resulting in jittery behaviour.
Often, these effects can be reimplemented using native CSS properties, such as position sticky or scroll snap, which allow the browser to handle the animations on the compositor thread without relying on JavaScript event listeners. Firefox will display a developer console warning when it detects a scroll-linked effect on a page, and there are ongoing proposals to better support such effects at the compositor level in future, including Web Animations and CompositorWorker, each carrying their own advantages and disadvantages. Developers working with scroll-linked effects are encouraged to share their use cases to help inform how such support might be improved.
18:24, 5th October 2021
Scrape Data from PDF Files Using Python
Data stored in PDF files can be difficult to work with, but the Python library tabula-py makes it possible to extract and reshape that data into a usable tabular format. For structured PDF data, the library can automatically detect rows and columns, or the user can manually specify the coordinates of the target area. For unstructured data, such as payroll records with mixed layouts, additional steps are required, including importing the raw data as a DataFrame, creating row identifiers using regular expressions and the Pandas cumulative sum function, reshaping the data from long to wide format using the pivot function, and finally merging the resulting DataFrames into a single, clean panel dataset. Throughout the process, trial and error is often needed to fine-tune coordinate values and determine whether to use stream or lattice mode for column detection. Automating this kind of PDF extraction can save organisations considerable time and effort compared to manual processing, though users should always verify they have permission to scrape any given file before doing so.
14:14, 5th October 2021
SYSODSESCAPECHAR Automatic Macro Variable
The SYSODSESCAPECHAR automatic macro variable in SAS is a read-only variable that stores the hexadecimal representation of the current ODS escape character set within a programme. When a character is assigned using the ODS ESCAPECHAR= option, the variable captures and reflects that value in its hexadecimal form, meaning that a character such as the hash symbol would be stored as its corresponding hex value of 23. This behaviour applies consistently regardless of whether the escape character is defined as a standard character or specified directly in hexadecimal notation, and where a multi-character string is provided, only the first character is used.
12:44, 30th September 2021
Decorators in R
Decorators in R, similar to those in Python, are functionals that modify or extend the behaviour of existing functions without altering their core functionality, often used for tasks such as logging inputs or timing execution. By treating functions as first-class objects, R allows decorators to wrap functions, enabling additional code to run before or after the original function’s execution.
Examples include a timer decorator that records start and end times, or a logger that writes outputs to a file, both demonstrating how decorators can enhance functionality with minimal changes to the original code. While syntactic sugar for decorators in R is less seamless than in Python, tools like the tinsel package offer partial support, allowing decorators to be applied directly above function definitions. A practical application involved using a decorator to log the first argument of the system function during code refactoring, highlighting their utility in improving code readability and debugging complex operations. This approach underscores how decorators can simplify tasks such as monitoring function performance or capturing input data, making them a versatile tool for developers working with R.
13:27, 29th September 2021
R for Loop
Loops in programming are used to repeat code execution efficiently, reducing redundancy and improving clarity. In R, for loops are particularly useful for iterating over sequences such as vectors or lists, executing a block of code for each element. The syntax involves specifying a value and a sequence, with the value taking each element in turn.
Examples demonstrate how for loops can count even numbers in a vector, use break to exit early when a condition is met, or employ next to skip iterations based on specific criteria. Nested for loops allow iteration through multiple sequences simultaneously, enabling tasks like identifying combinations of numbers that meet particular mathematical conditions. These structures provide flexibility in handling repetitive operations, making them essential tools for data processing and analysis in R.
13:26, 29th September 2021
Calmcode is an online learning platform offering 757 short video tutorials spread across 106 courses, designed to teach modern programming concepts and open-source tools in a calm, accessible manner. The platform is particularly focused on Python developers, covering a broad range of topics including code formatting, testing, data science, machine learning, web development and productivity tooling, with additional content for R users and general software development practices. New courses and lessons are published once or twice a month and are communicated through a newsletter, which the platform positions as the primary way for learners to stay informed. The overall philosophy behind Calmcode is one of reducing skill anxiety by presenting technical knowledge in short, straightforward lessons that begin from first principles, with the aim of making professional life in software development more manageable and enjoyable.
10:34, 28th September 2021
Understanding the Parquet File Format
Apache Parquet is a columnar storage file format designed for efficient data storage and querying, widely used in big data systems such as Hadoop. It organises data by columns rather than rows, enabling faster access to specific fields and reducing storage requirements through techniques like run-length encoding, dictionary encoding and compression.
This approach minimises file size, particularly beneficial for large datasets, and supports cross-platform compatibility. Compared to formats like RDS, which are specific to R and can store complex objects, Parquet prioritises storage efficiency and interoperability. It also contrasts with Feather, which focuses on speed and is part of the Apache Arrow ecosystem. The format's structure allows for metadata storage, facilitating efficient data processing and is implemented in tools such as the R package {arrow}, which enables reading and writing Parquet files with options for compression and encoding optimisation.
19:10, 26th September 2021
Statistics with Julia From the Ground Up
Here is a workshop that introduces the Julia programming language to data scientists and statisticians, focusing on statistical applications rather than general programming. Designed for those with experience in languages like R but no prior Julia knowledge, it covers foundational probability, statistical inference, regression and data manipulation using packages such as StatsBase, Distributions and GLM.
The session emphasises practical, goal-oriented scripting through examples and code snippets from a related book, with an accompanying Jupyter notebook for participants to follow along. The approach prioritises statistical methods and tools, treating Julia as a means to achieve analytical tasks rather than a programming language in isolation.
09:02, 24th September 2021
How to Find Files in Linux Using the Command Line
The Linux command line offers a powerful utility called find for locating files and directories within a file system by recursively filtering objects based on specified conditions. Users can search by file name or extension, modification time, file type and ownership, with results refined further using flags such as -iname for case-insensitive searches, -maxdepth to limit directory depth and -not to exclude certain results. Performance can be tuned through three optimisation levels, -O1, -O2 and -O3, with the default being -O1, which filters by file name first.
For content-based searching, the grep command can be paired with find using the -exec flag, which also allows matched files to be processed immediately, for example by changing permissions with chmod. The -execdir variant runs commands in the directory where the match is found rather than the root directory, which can offer security and performance benefits. A -delete flag can remove matched files, though this should be used with considerable caution, and interactive prompting before any action is taken can be enabled by substituting -exec with -ok or -execdir with -okdir.
13:07, 23rd September 2021
Excel TRIM function - quick way to remove extra spaces
Excel's TRIM function offers a straightforward way to remove unwanted spaces from cell data, resolving common formula errors caused by hidden leading, trailing or extra spaces between values. The basic syntax requires only a single cell reference as its argument, instantly stripping all excess spaces whilst preserving single spaces between words. For numeric data, TRIM must be combined with the VALUE function to ensure results behave as numbers rather than as strings, whilst the MID, FIND and LEN functions can be used together to remove only leading spaces whilst keeping multiple spaces between words intact.
Counting excess spaces is achievable by comparing the original string length against the trimmed length using the LEN function, and conditional formatting can highlight affected cells before any changes are made. When the TRIM function fails to remove certain spaces, this is typically due to non-breaking spaces or non-printing characters that require the SUBSTITUTE, CHAR and CLEAN functions in combination to resolve, with the CODE function helping to identify the specific character values causing the problem.