<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Brenda Codes]]></title><description><![CDATA[Thoughts, stories and ideas.]]></description><link>https://thehme.com/</link><image><url>https://thehme.com/favicon.png</url><title>Brenda Codes</title><link>https://thehme.com/</link></image><generator>Ghost 3.19</generator><lastBuildDate>Wed, 25 Feb 2026 03:56:17 GMT</lastBuildDate><atom:link href="https://thehme.com/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Angular NgZone Use Case]]></title><description><![CDATA[<p>I was recently working on a project that loaded an <code>iFrame</code> into an Angular component's template file. The source of this <code>iFrame</code> is generated by a third party who uses Chase to validate payment information, and I was integrating the third party tool into our web app. One key aspect</p>]]></description><link>https://thehme.com/angular-ngzone-use-case/</link><guid isPermaLink="false">5fadfc6cb698a25481363903</guid><dc:creator><![CDATA[Brenda Cortez Deverell]]></dc:creator><pubDate>Fri, 13 Nov 2020 04:17:55 GMT</pubDate><content:encoded><![CDATA[<p>I was recently working on a project that loaded an <code>iFrame</code> into an Angular component's template file. The source of this <code>iFrame</code> is generated by a third party who uses Chase to validate payment information, and I was integrating the third party tool into our web app. One key aspect of generating this <code>iFrame</code> required that we provide the url to a callback file (provided by the vendor), which their <code>iFrame</code> would use to control flow, like changing the look of the buttons on the <code>iFrame</code>, but calling functions in the callback file, that would need to trigger function we added on <code>window.top</code>. The problem seemed relative straight forward, until I started to work on the flow out of the <code>iFrame</code> and this is where NgZone comes in.</p><p><strong>Issues</strong></p><ul><li>One functionality of the <code>iFrame</code> is to validate that correct credit card (CC) information is entered, and upon failing to enter this data, we wanted to show a modal with the reasons for failure, but the modal was taking incredibly long to show up</li><li>Upon entering valid payment information, the <code>iFrame</code> logic would validate this through Chase and call a function the callback file to redirect back to the home page, but even though the redirect via <code>router.navigate</code> was working, the styles and loading of data in the home page would be painfully slow</li><li>Even after being rerouted back to the home page successfully, other options in the page, such as tabs, were not responsive, and if they did change pages, the data in those pages would be missing</li><li>If you just allows the page to sit, after a while the data would load and the styles would load, and the page would look normal, but it was too long</li></ul><p><strong>First solution</strong></p><p>Initially, it seemed like using <code>tick()</code> from <a href="https://angular.io/api/core/ApplicationRef">ApplicationRef</a> to "explicitly process change detection and its side-effects". This worked like a charm for the modals, and instead of them taking forever to load upon the <code>iFrame</code> submission detecting an error, it was as quick as expected. I thought I had won this war. However, when submitting the <code>iFrame</code> successfully and being redirected to the home page, I found that the slow loading issue continued! 🤯<br><br><strong>Second Solution</strong></p><p>This is when <a href="https://angular.io/api/core/NgZone">NgZone</a> came into play. Looking back, it makes sense that this is the Angular service I needed to use, because it is a "...service for executing work inside or outside of the Angular zone". In my case, when the <code>iFrame</code> made the call to Chase to validate the payment information, succeeded or failed, and returned to call a function in the vendor provider callback file, that callback file was living <strong>outside of the Angular world</strong>. The callback file lives in a publicly available location, e.g. <code>/assets/html</code> so that the Chase <code>iFrame</code> can access it. Therefore, when the <code>iFrame</code> calls a function this callback file, that file is outside of Angular and needs to be told to run inside. Here is how this works for my use case.</p><p>i. In my angular component, I imported <code>NgZone</code> in the constructor:</p><pre><code class="language-javascript">constructor(
    private zone: NgZone,
    @Inject('Window') private window: Window
){}</code></pre><p>ii. The functions that the callback file needed to execute, not only had to go on <code>window.top</code>, but needed to be wrapped the <code>NgZone</code>:</p><pre><code class="language-javascript">private setupWindowFunctions(){	(
	this.window as { [key: string]: any })['funct1'] = (res: VenRes) =&gt; {
		this.zone.run(() =&gt; {
		this.func1(res); 
	});
};</code></pre><p>Now, when the <code>iFrame</code> comes back with a successful validation or error, their callback file on our web app's public folder, triggers the <code>window.top</code> function, such as <code>func1</code>, and since this function lives within the <code>NgZone</code>, it is executed seamlessly, avoiding the slow data load that I was seeing before.</p><p>I think is is a nugget of knowledge that only experienced Angular developers might know of the top of their hear, so hopefully it helps someone out there, cause I certainly did not know this and own it to my awesome team to have figured it out.</p>]]></content:encoded></item><item><title><![CDATA[AWS CloudWatch Events]]></title><description><![CDATA[<p>Issues with cron settings:</p><p>Today I learned the hard way, and much later than the ideal case, that the <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/WhatIsCloudWatchEvents.html">AWS CloudWatch event</a> cron settings does not support advanced cron configurations!</p><p>I created an AWS Lambda with EFS and wanted to schedule it to run every other Monday. After trying different</p>]]></description><link>https://thehme.com/aws-cloudwatch-events/</link><guid isPermaLink="false">5f1b8b9bb698a2548136372f</guid><dc:creator><![CDATA[Brenda Cortez Deverell]]></dc:creator><pubDate>Sat, 25 Jul 2020 02:06:50 GMT</pubDate><content:encoded><![CDATA[<p>Issues with cron settings:</p><p>Today I learned the hard way, and much later than the ideal case, that the <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/WhatIsCloudWatchEvents.html">AWS CloudWatch event</a> cron settings does not support advanced cron configurations!</p><p>I created an AWS Lambda with EFS and wanted to schedule it to run every other Monday. After trying different solutions in the cron settings, the only config I could make work was one to run the lambda every Monday:</p><figure class="kg-card kg-code-card"><pre><code class="language-javascript">0 14 ? * 2 *</code></pre><figcaption>AWS cron settings for every Monday execution</figcaption></figure><p>If AWS supported more advanced syntax, then we I could have had two different jobs running the lambda, one on the first Monday and the second on the third Monday:</p><figure class="kg-card kg-code-card"><pre><code>0 14 * * 2#1 * - to run lambda on the first Monday of the month.
0 14 * * 2#3 * - to run lambda on the third Monday of the month.</code></pre><figcaption>advanced cron syntax - schedule for 1st and 3rd Monday executions</figcaption></figure><p>We can't have nice things, so this cannot be scheduled. Instead, the best I can do is, every 1,15 days in the month, which don't necessarily land on Mondays:</p><figure class="kg-card kg-code-card"><pre><code>0 14 1,15 * *</code></pre><figcaption>AWS cron job for every 1st and 15th day of the month execution</figcaption></figure><p>The next best thing will be to execute the lambda every Monday and in my lambda code, check if the Monday is the 1st or 3rd Monday of the month and then execute the lambda code only in these cases. </p><p> 🤷‍♀️<br><br>Will need to look into modifying my code, but it would be much easier if it could be done from the cron settings.</p>]]></content:encoded></item><item><title><![CDATA[AJV Schema Validation]]></title><description><![CDATA[<p>Apparently the <code>properties</code> property is required and is expected to be on the outmost section of the schema body.</p><p>If you want to validate the query string of a request, it does not work do to:</p><figure class="kg-card kg-code-card"><pre><code>export const mySchema = {
  $id: 'path/to/schema/file/mySchema.json',
  query: {
	properties: {
		url: {
          type:</code></pre></figure>]]></description><link>https://thehme.com/untitled-2/</link><guid isPermaLink="false">5f1a48e3b698a25481363701</guid><dc:creator><![CDATA[Brenda Cortez Deverell]]></dc:creator><pubDate>Fri, 24 Jul 2020 02:41:56 GMT</pubDate><content:encoded><![CDATA[<p>Apparently the <code>properties</code> property is required and is expected to be on the outmost section of the schema body.</p><p>If you want to validate the query string of a request, it does not work do to:</p><figure class="kg-card kg-code-card"><pre><code>export const mySchema = {
  $id: 'path/to/schema/file/mySchema.json',
  query: {
	properties: {
		url: {
          type: 'string',
          pattern: 'https?://.*',
	    },
	},
  },
  required: ['url'],
};</code></pre><figcaption>mySchema.ts</figcaption></figure><p>Instead, it has to be:</p><figure class="kg-card kg-code-card"><pre><code>export const mySchema = {
  $id: 'path/to/schema/file/mySchema.json',
  properties: {
    url: {
      type: 'string',
      pattern: 'https?://.*',
    },
  },
  required: ['url'],
};</code></pre><figcaption>mySchema.ts</figcaption></figure><p>I don't think this was clear in the documents, but seems like an important detail to keep in mind. </p><p>Also, the pattern, which is a regex, must be surrounded by quotes 🤷‍♀️</p>]]></content:encoded></item><item><title><![CDATA[Handy Knex Commands]]></title><description><![CDATA[<p>Using Knex for query building, PostgreSQL, and TS at work. </p><p>Commands I find useful:</p><!--kg-card-begin: markdown--><p><code>knex.raw(SELECT version())</code></p>
<!--kg-card-end: markdown-->]]></description><link>https://thehme.com/handy-knex-commands/</link><guid isPermaLink="false">5f14eed2b698a254813636e7</guid><dc:creator><![CDATA[Brenda Cortez Deverell]]></dc:creator><pubDate>Mon, 20 Jul 2020 01:12:59 GMT</pubDate><content:encoded><![CDATA[<p>Using Knex for query building, PostgreSQL, and TS at work. </p><p>Commands I find useful:</p><!--kg-card-begin: markdown--><p><code>knex.raw(SELECT version())</code></p>
<!--kg-card-end: markdown-->]]></content:encoded></item></channel></rss>