tag:blogger.com,1999:blog-1095592707686722762024-02-08T01:40:49.500-06:00Coding ArtBrandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.comBlogger21125tag:blogger.com,1999:blog-109559270768672276.post-31513541705281921002023-06-27T13:51:00.000-05:002023-06-27T13:51:10.083-05:00AI-assisted research using ChatGPTBrace yourselves! My recent journey with ChatGPT 3.5, and now 4.0, has been nothing short of a roller coaster ride. Now, I'm incredibly excited to share the incredible highlights of this adventure with you!Once upon a time, ChatGPT was just another tech term that had fluttered by my ears. I mean, who needs another AI chatbot when you've got kids to keep you on your toes, right? But then, a Brandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com0tag:blogger.com,1999:blog-109559270768672276.post-52521315720433645442021-03-12T16:09:00.007-06:002021-03-12T17:14:18.759-06:00How to test a NodeJS module and swap out its private dependent class with a fake TL;DRUse rewiremockCreate a FakeDep class with which to replace the real onerewiremock('../../../real/code/my-real-class').with(FakeDep);rewiremock.enable();DetailsWhen you're unit-testing a module, you want to isolate your testing to only that one piece. You presumably have other unit tests for the dependencies you have written.All day today I have been trying to swap out a private Brandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com0tag:blogger.com,1999:blog-109559270768672276.post-88967351658153239602021-02-18T16:35:00.001-06:002021-02-18T16:35:04.940-06:00AWS CloudFormation Multi-Region Failover using DynamoDB v2019 and LambdaTL;DRGo here.RantScouring the internet for a solution for multi-region failover using a DynamoDB Global Table (v2019) in CloudFormation resulted in basically nothing. Sure, I found some solutions using an antiquated version of DynamoDB Global Tables--and this sent me down a rabbit trail until I realized that it was out-of-date.One would think that AWS would have at least an example laying Brandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com0tag:blogger.com,1999:blog-109559270768672276.post-9298388272415070412020-03-09T10:51:00.001-05:002020-03-09T10:56:32.318-05:00How to share code between AWS Lambda functions using Serverless Application Model in Node.jsI'm writing this post because it turned out to be a lot more difficult that I think it should've been.
I mean, who doesn't have code that they want to share between lambda functions?
And who doesn't want to debug those functions or business logic inside of those functions quickly--that doesn't require firing up the whole lambda into the AWS environment?
We wanted to have a utility package that Brandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com0tag:blogger.com,1999:blog-109559270768672276.post-88953718456111553092018-12-14T14:04:00.001-06:002018-12-14T14:42:21.455-06:00Extending Newtonsoft JSON JToken to output only the text valuesI recently needed to take a big JSON payload and dump it to text just like you can do with an XML Document using InnerText/OuterText.
At first glance, it looked complicated and it just felt like something that should have come out-of-the-box.
Well, here is the Extension Method:
public static class ExtensionMethods {
public staticBrandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com0tag:blogger.com,1999:blog-109559270768672276.post-17846388937675536822016-07-06T13:49:00.000-05:002016-07-06T14:04:46.564-05:00Running Solr 6.1 as a Windows Service
Goal
Get Solr 6.1 running as a Windows Service and have it recover on OutOfMemory Exceptions.
Install Solr 6.1 as a Service
Download NSSM
Extract nssm.exe somewhere
Create solr_start_6.1.0.cmd (this is a Windows Command file that does all of my configuration--yours will definitely be different):C:\apache\solr-6.1.0\bin\solr start -f -h node3 -c -p 8983 -z "zk1:2181,zk2:2181,zk3:2181" -mBrandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com9tag:blogger.com,1999:blog-109559270768672276.post-68895836872410666692016-05-24T12:04:00.004-05:002016-05-24T12:04:37.021-05:00Apache Solr - RangeQuery
RangeQuery appears to be a range query that operates on strings. I'm not sure if it only works on strings or if the strings are a way for it to auto-determine what field type it's going to work with.
If you know how to properly use this, please leave a comment below. I'm stumped on this one.
Fields
fieldName (required in hierarchy here or a parent)
lowerTerm - string value
Brandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com0tag:blogger.com,1999:blog-109559270768672276.post-73130866299541745232016-05-24T11:28:00.002-05:002016-05-24T11:58:16.095-05:00Apache Solr - MatchAllDocsQueryMatchAllDocsQuery is probably the simplest query there is. All it does is quickly match all documents in an index.
Example
Simply paste the following into the q= field in the Admin UI.
{!xmlparser}
<MatchAllDocsQuery></MatchAllDocsQuery>
Or, using the standard lucene syntax: *:*
Brandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com1tag:blogger.com,1999:blog-109559270768672276.post-82451129196216526142016-05-24T11:16:00.000-05:002016-05-24T11:20:19.036-05:00Apache Solr - LegacyNumericRangeQuery
NumericRangeQuery was renamed to LegacyNumericRangeQuery about lucene 6.0.0 and marked deprecated. If you're on an older system, you will find it using NumericRangeQuery. Afterwards, LegacyNumericRangeQuery will be what you will want to use.
It looks like NumericRangeQuery has been replaced with PointRangeQuery.
Fields
fieldName (required here or in a parent node)
lowerTerm (Brandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com0tag:blogger.com,1999:blog-109559270768672276.post-20506899151536502572016-05-24T10:23:00.001-05:002016-05-24T11:06:58.755-05:00Apache Solr - PointRangeQueryPointRangeQuery is new as of about Apache Solr 6.0 and is meant to replace the, now deprecated, NumericRangeQuery (which got renamed to LegacyNumericRangeQuery).
NOTE: The following may be confusing, and here's why. The PointRangeQueryBuilder, used by XmlQueryParser, requires that lowerTerm and upperTerm are specified, which means that neither of them may default. However, in the Brandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com3tag:blogger.com,1999:blog-109559270768672276.post-70689961439436890182016-05-24T09:35:00.000-05:002016-05-24T09:35:43.947-05:00Apache Solr - TermsQueryTermsQuery is essentially a list of TermQuery with a couple of extra options.It allows you to specify a group of terms on a field and require a minimum number of matches.
Fields
fieldName (required here or in a parent node)
disableCoord (optional, default false)
more about coord-factor in scoring
If disabled, resulting score gets multiplied by 1.0
minimumNumberShouldMatch (optional, Brandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com1tag:blogger.com,1999:blog-109559270768672276.post-19711832632818439982016-05-23T15:34:00.002-05:002016-05-24T09:39:43.875-05:00Apache Solr - TermQueryTermQuery is a very simple query that matches documents containing a term.
A term represents a word found in a field. A term has a field property and a text property.
Fields
fieldName (required)
boost (optional, 1.0 default)
more about query-boost in scoring
Examples
Simply paste the following into the q= field in the Admin UI.
Query ParserSyntax
XmlQueryParser
{!Brandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com1tag:blogger.com,1999:blog-109559270768672276.post-50266733710763962312016-05-23T15:11:00.002-05:002016-05-24T12:05:36.681-05:00Apache Solr - XML Query Parser
Introduction
The XML Query Parser (XmlQueryParser) supports a very wide range of available Apache Solr
search queries--more so than any other query parser that ships with it.
This article will attempt to examine the breadth of that influence released with Solr 6.0.0.
I will be adding separate articles (and linking to them) for the different types of queries so that
more detail mayBrandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com0tag:blogger.com,1999:blog-109559270768672276.post-77449674076741770432016-05-23T14:20:00.000-05:002016-05-23T14:46:08.064-05:00Important Apache Solr 6+ Commands for WindowsSometimes what we really need is a quick reference to common commands we use on a somewhat-daily basis.
We are a Windows shop and sometimes Windows doesn't receive the same love as the *nix world in Solr.
Note that most of these commands are to be executed from the root directory of your Apache Solr installation (or solr-src\solr directory if you compiled from source). This article willBrandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com1tag:blogger.com,1999:blog-109559270768672276.post-62356154607230308262016-05-18T13:39:00.001-05:002016-05-26T09:52:03.139-05:00How to write a Custom Solr Query Parser for Solr 6
Introduction
Solr comes pre-installed with a bunch of great query parsers, so if you're starting out, there's a push to learn and use that syntax. However, many times we are not starting out without a historical query language--and converting to a new query language is not an option. This article is meant to assist those embarking on this voyage.
Solr advertises the fact that it Brandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com5tag:blogger.com,1999:blog-109559270768672276.post-7469374635643589092016-05-18T10:55:00.004-05:002016-05-18T11:30:39.308-05:00How to Download and Compile Solr 6 in Eclipse
Overview
Download and install the Oracle Java SE JDK
Download and Install Eclipse
Download and Install Apache Ant
Download Solr source code
Prepare Solr source code for Eclipse environment
Importing and compiling Solr source in Eclipse
Using the Build.xml files in the Project
Download and install the Oracle Java SE JDK
For Solr 6.0.0, you need at least Java SE 8
I chose to Brandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com6tag:blogger.com,1999:blog-109559270768672276.post-68043549593832343602016-05-18T08:12:00.001-05:002016-05-18T14:18:27.104-05:00Compiling and Running Apache Solr 6 from Source on Windows
To get started, I'm going to quickly outline a bunch of little, specific steps to get us where we want to be.
Download and install the Oracle Java SE JDK
For Solr 6.0.0, you need at least Java SE 8
I chose to install the Windows x64 product
Make sure that java is accessible from the command line
Open a new command window
type: java -version
You should see something like:java version "1.8.0_91Brandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com7tag:blogger.com,1999:blog-109559270768672276.post-24283298366988933062016-05-09T10:49:00.000-05:002016-05-09T14:04:15.313-05:00Replacing dtSearch with Solr: Using Solr's XMLQueryParser to process Search Queries
The Problem
Sometimes you need a query that supports nesting--and when you do, it can be quite frustrating in Solr. The company I work for must support deep-nesting proximity queries--some of which have five or six or more levels of nesting. Try doing that with the standard Lucene syntax of "word1 word2"~3! Yeah, you can't. Not only that, but it doesn't support "word1 must Brandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com3tag:blogger.com,1999:blog-109559270768672276.post-28359594844850995812015-11-20T08:52:00.003-06:002015-11-20T20:51:32.943-06:00jQuery: How to select DOM elements with multiple classes, etc. using the intersection set operatorToday I needed a way to select items that had a combination of classes employing a simple intersection set operation. I think it took entirely too long to find it, so I'm writing this blog post to provide easier access to this answer. I couldn't even find it on w3schools.com's CSS Selector list or jQuery's Category Selectors page.
Thank you, Stack Overflow! Here's the link Brandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com0tag:blogger.com,1999:blog-109559270768672276.post-50486181434730585022014-05-26T23:47:00.003-05:002014-05-26T23:47:25.902-05:00Today's Noah's Ark
I invite everyone here to receive the Gospel of Jesus Christ.
The whole Bible makes Jesus look GORGEOUS! Why do I say this? The biggest thing by far that is against us is the wrath of God. Yes, there's the curse that creation received when Adam sinned in the garden, but that is NOTHING compared to the infinite, awesome wrath of God! We were given instructions as to what sin is so that when we doBrandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com0tag:blogger.com,1999:blog-109559270768672276.post-17271071329271564272013-12-19T12:01:00.001-06:002015-11-20T20:50:45.937-06:00TSQL - How to use OUTER JOINs in a recursive CTERecently I was bummed out by SQL Server telling me that outer joins are strictly prohibited inside of a recursive CTE!
Outer join is not allowed in the recursive part of a recursive common table expression 'children'.
Bummer!
What's a developer to do?
I really need that non-inner join!
Do I really have to do this thing manually?!
But the recursive CTE expression is so neat and concise!
In your Brandon Millerhttp://www.blogger.com/profile/07671277250070853501noreply@blogger.com1