code JavaScript async/await warnings TLDR; NEVER EVER EVER USE map, filter, reduce with async/await Frustrated over why a segment of code was not working which looked like this Example const results = inputs.map(async z => { return { id: getId(z), result: await sendId(z) } }); The structure and formatting is correct and you would
code NPM node validate expected version Use package.json and add the lines { ... "scripts": { "start": "node index.js", "test": "lab tests/api.tests.js", "preinstall": "node checkNodeVersion" }, "engines": { "node": ">=20", "npm": "^10&
code Webhook debugging with ngrok There are several tools to reroute external webhook urls to local dev. Ngrok is one of the easier options and works with multiple host header files locally with some commands. There are alternatives like localtunnel * Sign up for a free ngrok account * Download the mechanism you wish to run ngrok
code Recursive CTE (Sqlite) for generate_series substitute In large modern databases you usually have a function available called generate_series that is useful for creating an inline series numbers, dates, etc Example SELECT * FROM generate_series(2,4); Produces the results of generate_series ----------------- 2 3 4 You can also combine this with dates and date
code Command line zip and submit to an API Expanding on automating sending data and getting results from the FastAPI I wrote here, that is deployed here. Tied some command line processing tools together to build out a nice script automation one liner (a long line, but still works) to achieve the goal of zip up a set of
code Deploy FastAPI to DigitalOcean App Platform Previously I developed a python FastAPI tool that I developed locally to ingest Google ARI XML messages and produce a price quote here. Now I want to publish this to get a deployed instance for public use Using Digital Ocean to turn the above FastAPI into a deployed instance Create
code FastAPI with PyDapper and Sqlite Google operates a free listing service for Hotels and Vacation Rentals to integrate with their maps and search engine. In theory the idea is that you supply Google with information about your listing and it will be verified and placed into their system at no cost to you. It is
code Filtering and find with jq Debugging a JavaScript Object Notation (JSON) response and wanted to filter and find a specific case and then convert the matches into a Comma Separated Values (CSV) response for others to work with in a spreadsheet. Need to quickly push this out with little or no work and well that
code HTTP Status Codes Reference Quick reference HTTP status code summarized groups * 1XX - Information * 2XX - Happiness * 3XX - Multiple choice * 4XX - My fault * 5XX - Your fault
code iTerm set Back/Forward word keys Not sure, but iTerm was not recognizing my backward/forward word keys which is annoying. The key combinations I am talking about are ALT - b for backwards one word on terminal and ALT -f for forwards one word on terminal. This seems odd as regular terminal works off of
code Dynamically insert iFrame I needed to insert an iFrame that operates off of the query string parameters like so /someplaceid12345/andthis?alsothis=93293 In the above situation I want to extract the someplaceid12345 and match it to another location to create a dynamic url source for the embedded iFrame First extract the id
code DOM node removed Needed to listen for the removal of a node from the Document Object Model (DOM). In this case a dynamic modal popup div that after closing should clear the cache. window.addEventListener("DOMNodeRemoved", e => { console.log(`${e.target} removed`); }); Hook the window event listener to handle the
code Find your IP Address Script Needed to find the outgoing true IP address for computer to provide for whitelisting to another proxy. Here I am using a third party website to get an IP result icanhazip.com Ideally I would create a client side call that is handled by the server and then queries the
code Enhancing the console.log Messing around with the console.log and in particular the %c stylized log and tried some experiments and you can enhance the log to render out images etc and in this case I am making a canvas element to hold text and styling it so that the log And here
code Detect PNG image header in data stream Byte check header for the PNG header in a data stream public static bool HasPngImageHeader(byte[] imageContents) { byte[] imageHeader = { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A }; return imageContents.Take(8).SequenceEqual(imageHeader); }
Hapijs + MapBox + Glitch Example Built out a MapBox test page for use and decided to use glitch.com because it is easy to get something live to test with and then embed and here is the code. Had to get back into the nodejs frameset and working with hapijs after a few years rust,
code Hapijs + Glitch Example Built out a Open API test page for use and decided to use glitch.com because it is easy to get something live to test with and then embed and here is the code. Had to get back into the nodejs frameset and working with hapijs after a few years
code Fixing Elementor Popups with JavaScript Elementor is a free WordPress plugin that enhances your website to allow graphical drag and drop editing of websites and it's free. It is full of nice and helpful snippets with an especially powerful one being the ability add in Popups. This can give your website focus areas
code JavaScript Onetime Script with Delay Needed to have some JavaScript to do a onetime execution process after content is in the Document Object Model (DOM) and created. Hook into the load event https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event Add an event listener to the window that is looking for the
code Chat GPT - ...Thoughts... I have some quick thoughts that about chat bots built on large language models. TLDR; They produce words in a reasonable pattern matched process, they do not understand or form any value or levels of truth to it and that is the stumbling block that is hitting people now and
code PHP cURL Request/Response JSON Debugging an integrators code that was written in PHP and came up with this test snippet. I'm using php cURL as it is the simplest to convert and compare with the command line interface of cURL <?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL
code Windows Features Open an administrator level PowerShell console Get-WindowsOptionalFeature -Online | where FeatureName -like 'IIS-*' | where State -eq "Enabled" Output FeatureName : IIS-WebServerRole State : Enabled FeatureName : IIS-WebServer State : Enabled FeatureName : IIS-CommonHttpFeatures State : Enabled FeatureName : IIS-HttpErrors State : Enabled FeatureName : IIS-ApplicationDevelopment State : Enabled FeatureName : IIS-Security State : Enabled FeatureName :
code Advent of Code - 2022 Can I complete Advent of Code 2022 in python this year? Last years entry and how far I got * 2022 - Python solutions I finished!! A little later than 25th, but I did catch Covid for the week of 18th - 25th.
personal Life and loss Thinking about life while on a run and thinking why can't I hit my previous running goals with the same effort. This is due to various factors, but the one that continuously hits me is injuries that show up that never did before and take extraordinarily (in my
code Windows Subsystem for Linux 2 I am running manticore search and redis within my Ubuntu 22 on top of Windows Subsystem for Linux 2 (WSL2) this allows me to connect my Windows development environment (Internet Information Services - IIS) to use linuxy development tools that don't change and match the Amazon Web Services