code Local browser translation Google AI capabilities are working to be embedded in your local browser soonish and if you look into the preview builds you can see the capabilities and switch them on for experimentation as follows Translate on Device Locally https://developer.chrome.com/docs/ai/translate-on-device API Details https://developer.chrome.
code Git Cherry Pick Sometimes you make a commit to a branch that you meant to put on another one and you want to quickly fix it by popping that commit over to the correct branch. Example situation Current branch is great-new-stuff, you have been working in this branch for awhile and then you
code PowerShell Measure-Command Working on some PowerShell scripting timing issues and documentation of how long things are taking and what they are doing while this is happening was needed. In this case put Measure-Command commands throughout the scripts to determine the timings. Example usage In this example I am using a oneline batch
code TFS Version Control to git TFVC you say. Yes Team Foundation Version Control or the terminal case of Visual Source Safe that Microsoft realized was battle no longer worth fighting git with and was one of many reasons to buy GitHub. Well had to dig out old code that was buried in this old system
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)