code IndexedDB: Your all purpose browser cache Working on a React static site that is pulling large amounts of data from a public API. Problem Specifically the API request for data looks like this <base url>/objects?metadataDate=YYYY-MM-DD Here the metadataDate indicates the data object has changed since the particular date specified and the
code Infinite generator C# From the above python exercise here now a C# flavored version Code private static IEnumerable<int> InfiniteGenerator(string input) { var index = 0; var letters = input.ToCharArray(); while (true) { yield return letters[index % letters.Length]; index++; } } static public void Main() { var value = 0; foreach (var current in InfiniteGenerator("
code SQL Techniques - Third Normal Form (3NF) Relational databases are built on the concept of entities and their relationships to each other. From time to time the relationship between tables is a Table1 < N – N> Table2 or table 1 data relates to table2 data in a non unique form. In this case a bridging table
code Calculate change in coins various languages Given the prompt of some amount less than the smallest bill available calculate the remaining coins to distribute. This is also ok for bill amounts as well if you wanted to reuse it. This is also how you would do pagination as well as it is the first pass of
code Calculate moving average - SQL A moving average is a calculation using a subset of a larger set that is index centered and bounded by a N adjacent values. For example say you have the following values date_time stock_price 2023-08-08 13 2023-08-09 18 2023-08-10 10 2023-08-11 10 2023-08-12 8 2023-08-13 2 2023-08-14 6
code Calculate Factorial various languages C# * Classic recursive public static int CalculateFactorialRecursive(int number) { return number == 0 ? 1 : number * CalculateFactorialRecursive(number - 1); } * Iterative public static int CalculateFactorial(int number) { return number == 0 ? 1 : Enumerable.Range(1, number).Aggregate(1, (current, i) => current * i); } Python def calculate_factorial(input_number: int, recursive: bool = False)
code ParallelForEachAsync Need to make a ParallelForEachAsync that works independently and runs in C#, inspiration from JavaScript way to handle async/await is like so async function Promise1() { throw "Failure!"; } async function Promise2() { return "Success!"; } const [Promise1Result, Promise2Result] = await Promise.allSettled([Promise1(), Promise2()]); console.log(Promise1Result); // {status: "
code JavaScript Higher Order Functions, await and loops Passing functions as arguments to other JavaScript functions or creating higher order functions is something you may want to do or even be encouraged to do. JavaScript is notorious for callback hell, but I would like to demonstrate the situation with respect to async function parameter passing. Synchronous Steps Take
code Save to clipboard Push text into the clipboard. Use the following function async function copyToClipboard(text) { try { await navigator.clipboard.writeText(text); } catch (error) { console.error(error.message); } } copyToClipboard("Text injected to clipboard"); The embedded script will request permission to write to your clipboard like so You will need to allow
code The Document Object Model roots HTML was originally created to work from a distributed network with documents moving and editing across that network. This key concept slowly has evaporated from public consciousness that every view from the a HTML page has a Document Object Model underlying it. Key point to focus here is the Document
code Language Phenotypes: C#, Python - Part 6 Doing a convert a line of text into a 2 dimensional array choice. In this case I will show the answers in C# and Python Given the problem Convert this line input "5.0,100,5.5,99,6.0,101:L10;5.0,18,5.5,98,6.
code Scrape ld+json with cURL + htmlq Google Vacation Rentals has proposed a linked data JSON format to setup properties for search indexing across their various platforms: search engine, maps, etc. The details of the format are below Vacation Rental Schema Markup | Google Search Central | Documentation | Google for DevelopersVacation listing structured data can help people find your
personal Find computer last wake target In Windows when you put the computer to sleep, it is allowed to wake on input from certain elements. Sometimes this is annoying because certain USB devices connected that you are not aware of are waking the computer unexpectedly like a yubikey. Found this out by using the following command
code Advocating for new hardware for workflow improvement Wrote the following as an email (anonymized names) to Cornelius (supervisor) to advocate for Portia (worker in question) to get better hardware to perform her work tasks better and faster. She did get the improved hardware and was able to perform her work tasks with marked efficiency and improvement. Hello
code Postfix Notation Evaluator Function Suppose you are given the following string to parse out as a mathematical operation in postfix notation 3 4 + 5 6 + * to parse out That is in normal infix notation (3 + 4) * (5 + 6). Therefore the answer for both should be 77 To do this you should create a stack
code jq - Filter by properties and case insensitive Doing some zen like programming tasks by patching together utilities and pipes for a task of taking a GeoJSON dataset and finding all the elements of a particular county. Example data set format { "type": "FeatureCollection", "name": "Weather_Stations", "crs": { "
personal New shirts I got these shirts because it combines multiple layers of my personality. Skulls, atypical phrases, and early computer nostalgia
code Infinite generator - Cycle and Sum Working through a python example and presented with the problem Write a one-line Python generator or iterator expression that returns the infinite sequence of increasing integers generated by repeatedly adding the ascii values of each letter in the word “Close” to itself. 67, 175, 286, 401, 502, 569, 677, 788,
personal Unicode surprises Poking around in the Unicode libraries and stumbled across an unbelievably complicated glyph that is actually a single character. The character in question is a ligature of an Arabic character. This: ﷽ The above is a compressed single input character of the phrase باسم الله الرحمٰن الرَّحِيم which
code Scope creep doesn't exist The title is controversial, but if you think about it is true. Using a common refrain I have observed that a segment of software is experiencing scope creep, as in this is taking longer because what it means is not comprehensive or complete with respect to the end goal. Baseline
code JavaScript Recursive Flatten Ran into the need to recursively flatten a JavaScript object and came up with this function flatten(obj, prefix = '') { return Object.keys(obj).reduce((results, z) => { const currentPrefix = prefix.length ? prefix + '_' : ''; if (typeof obj[z] === 'object' && obj[z] !== null)
code Remove extraneous properties from JavaScript objects JavaScript objects can have numerous levels of properties that are set to null and posting them through fetch requests can lead to strange behavior if you are not checking for nulls. Why not clear out those fields? Function * Take the current object and check if is is coalesced loosely to
code MySql row_number() fix duplicates Trying to add a new unique key to a table and on of the fields allows nulls and there are already duplicate records that need to be adjusted now. This is the perfect case for using row_number to order the ids Here is an example table create table LocationApplicability
code Trim your Standup Time to expand on my previous post. If you are going to do synchronous standups, which you should think about what is this achieving that is not available from a written format and how will you differentiate it from a status meeting. I will summarize the original purpose of the
code Asynchronous Convergent Coding: A proposal What are the goals of code review? This is to me a subjective question. In my opinion they are the following. * Finding missing conceptual issues * Shared understanding of the system * Identification for future enhancements that will be documented or exist in the reviewer/reviewee common framework * A desirable goal is