Programming Leftovers
-
Remix, React, and State
Whenever a piece of state changes, React reconciles the old state with the new state and figures out where in the component tree it needs to re-render UI elements.
What that means — and what might not always be immediately obvious — is that if you don’t store and modify your application’s state in React, then React won’t be of much use to you. React needs state to be useful.
React state, however, is ephemeral: it lives and dies with the browser tab unless you persist it somewhere. That means it’s up to you to keep React state in sync with your application’s data, i.e. the source of truth.
To reframe Josh’s statement: React’s main job is to keep its state in sync with your application’s user interface but not your application itself. That’s up to you.
-
Secure your machine learning with Semgrep | Trail of Bits Blog
Picture this: You’ve spent months curating images, trying out different architectures, downloading pretrained models, messing with Kubernetes, and you’re finally ready to ship your sparkling new machine learning (ML) product. And then you get the (hopefully not dreaded) question: What security measures have you put into place?
Maybe you’ve already applied tools like Counterfit and PrivacyRaven to test your model against model extraction and model inversion, but that shouldn’t be the end. You’re not just building a model; you’re building a pipeline. And the crux of your pipeline is the source code. ML models cannot be treated as standalone objects. Their creators must account for every element of the pipeline, from preprocessing procedures to the underlying hardware.
Semgrep is a powerful static analysis tool that enables users to search for potentially problematic code patterns at scale. Previously, we released several Semgrep rules to find goroutine leaks that are included in our public set of Semgrep rules. To strengthen the ML ecosystem, we’ve analyzed the source code of many ML libraries and identified some common problematic patterns. Instead of relying on developers to thoroughly examine the source code or documentation of each library they use, we decided to turn these patterns into Semgrep rules to make it easy to find and fix potential vulnerabilities.
-
Understanding leaf node numbers when using rpart and rpart.rules | Statistical Odds - Ends
I recently ran into an issue with matching rules from a decision tree (output of rpart.plot::rpart.rules()) with leaf node numbers from the tree object itself (output of rpart::rpart()). This post explains the issue and how to solve it.
-
Probabilistic Photograph Manipulation with ggplot2 and imager - Mark H. White II, PhD
I started taking photos earlier this year. And as someone who loves thinking about probability, statistics, chance, randomness, and R programming, I started thinking about ways to apply probabilistic programming to photography. This is my first attempt.
I’m going to be using one shot I particularly like. It’s a tower on 47th between Wyandotte and Baltimore in Kansas City, Missouri—as seen from the parking garage roof above The Cheesecake Factory:
-
Perceptual Hashing
Hashing algorithms map data to an arbitrary fixed-size value. Most hashing algorithms actively try to avoid collisions – e.g., minimizing the probability of two different keys having the same hash. Perceptual hashes do the opposite – they maximize collisions by creating some dimension of data locality – similar keys have similar hashes.
-
libsdl2 version bump in OE
EasyOS has libsdl2 version 2.0.12, but I was looking at a project that requires 2.0.18 or greater. So, I have compiled 2.0.20 in OpenEmbedded.
-
How to Build A Real-Time Communication Application with Django-Channels and The WebSocket Protocol
In this tutorial, we’ll learn how to build a real-time communication application with The Django Channels package and The WebSocket Protocol. The application we will create will be a platform where users can join multiple pre-created groups and share ideas with members of the group.
-
Handling Empty Paragraphs from R Markdown
From time to time I find empty paragraph tags (
) inserted into my HTML when knitting an R Markdown document.Beyond being an affront to my OCD, these empty tags are mostly just an irritation. But if I’m trying to produce a very specific layout, then the extra space allocated to them can become a real annoyance.
-
A Gentle Introduction to using Support Vector Machines for Classification | Harshvardhan
Support vector machines (SVM) are remarkable for the unification of geometric theory, elegant mathematics, theoretical guarantees with strong practical use cases. In this blog post, I demonstrate certain properties of SVM and how to use them with caret package in R.
-
Team Collaboration in R and Python Made Easy - RStudio
Bilingual teams that want to do serious data science require collaboration, transparency, and reproducibility across R and Python workflows while empowering professionals to work in their preferred language(s). Accomplishing this requires tools built for interoperability at scale and a shared standard between data science languages.
-
Update: rtfdump.py Version 0.0.11
This new version of rtfdump, my tool to analyze RTF files, brings json output for options -O and -F.
-
Video: C Programming on System 6 - VCF Midwest, Wikipedia Reader, and Subterm
I attended the Vintage Computer Festival Midwest 17 and wrote two new programs.
-
Macros in C
“As you know that C is quite a diverse general-purpose language and came up with many different structures. The Macros in C language come in handy when swapping your large code with a single piece of line code to avoid complexity and more. The macros can be utilized in the C codes using the “#define” keyword. Although macros have many types, we will demonstrate the use of object-like macros and function-like macros in this article. Let’s have a fresh start on this guide by updating it in the shell by the “update” query shown in the attached image. Provide this query with your Linux password to continue the processing.”
-
Fork System Call in C
“The basic purpose of the fork command method is to create one or more child processes; the newly created child processes run concurrently with the parent process that created these child processes using fork statements. The next statement that is followed by the fork command will be executed by both child and parent processes simultaneously. The same CPU registers, the program counter (PC), and open files that the parent process accesses are used by the child process. The fork command doesn’t take any parameter as input, but it returns an integer value by using which we can easily identify whether either fork command created the child process successfully or not.”
-
Calloc in C
“The utilization and assignment of memory or space in a system are said to be the most important thing in any programming script when you have a lot of data in the form of variables and arrays. The C language is very dynamic when it comes to allocating memory as it contains many memory-specific functions in it. One of those functions is calloc(). Contiguous allocation is another name for the “calloc”. This C language method allocates dynamic memory for a certain type. This technique is used to dynamically allocate the desired number of memory blocks of a particular type.”