Posts

Shrinking node_modules for AWS Lambda (My First “npm shock” and a Practical Fix)

Image
I’m a newbie in Node.js and not really familiar with the whole npm ecosystem. I honestly didn’t expect that a single npm install would explode into ~10MB spread across ~30 different folders. After a few minutes of staring at it, I realized what’s actually inside those folders: not just runtime code. What shocked me Inside node_modules you get everything: README files source files tests examples docs And then the next level of madness: modules inside modules . Duplicated dependencies nested multiple levels deep (e.g. inherits , core-util-is , tedious …), even if they already exist elsewhere in the project tree. Here’s a typical example: I’m in node_modules → package bl , and there’s another node_modules folder inside it, plus test , README and other “junk”… all for a ~10KB JS file. The obvious assumption (that turned out wrong) Once I accepted the chaos, I assumed there must be a “build for production” command that would “compile” depende...

Node.js / npm: Fixing “npm ERR! cb.apply is not a function” on Windows

Image
Lately I ran into this issue and I want to share the exact way I got out of it: C:\>npm i npm -g npm WARN npm npm does not support Node.js v14.17.0 npm WARN  npm  You should probably upgrade to a newer version of node as we npm WARN  npm  can't make any promises that npm will work with this version. npm WARN  npm  Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11. npm WARN  npm  You can find the latest version at https://nodejs.org/ npm ERR! cb.apply is not a function npm ERR! A complete log of this run can be found in: npm ERR!       %USERPROFILE% \AppData\Roaming\npm-cache\_logs\2021-05-30T14_58_58_367Z-debug.log It happened right after I installed a newer version of Node.js. But when I c...

AWS API Gateway + Lambda: How to Add a “Get By ID” Resource (Path Parameter)

Image
This thing is not trivial and I couldn’t find a simple explanation. Here is the exact sequence to add a Get By ID -style path parameter like /users/{userid} in API Gateway and wire it to Lambda. Goal Turn an existing resource like /users into: /users /users/{userid} (new resource) Step-by-step Select an existing resource (e.g. users ). Click Actions and select Create Resource . In Resource Name , put the parameter name in curly braces (e.g. {userid} ). In Resource Path , you should see read-only text like /users/ and a textbox for the parameter. Enter {userid} in the textbox and click Create Resource . You should now see a new branch in your API tree: /{userid} . Select it. Click Actions → Create Method and add ANY (or the specific method you need). ...

Automating DB Backup under SQL Server Express (Without SQL Agent)

SQL Server Express does not include SQL Server Agent. That means: No Jobs engine No Maintenance Plans (Management → Maintenance Plans does not exist) The same applies to many shared SQL Server environments. If you need automated backups, you must implement your own scheduling solution. The Solution Create a batch file and schedule it using Windows Task Scheduler . The script: Accepts database name as parameter Accepts backup folder as parameter Generates timestamped filename Executes BACKUP DATABASE via sqlcmd Batch File Script @echo off set databaseName=%1 echo %databaseName% set backupFolder=%2 echo %backupFolder% for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%" set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%...

Decimal number issue from server to client. Wow! Didn't expect this @_@

Image
Chapter 17   where a poor Decimal Number came from Server Side to JavaScript I worked on a page for days, adjusting the UI with CSS and HTML. Everything looked fine… until I started testing multi-lingual support. English — OK. Spanish — OK. Chinese — OK. Even right-to-left Hebrew (crooked and askew, but working). But Russian? Nope. In Russian the page stopped working completely: only static texts and images were visible. Nothing dynamic rendered. Of course it was a JavaScript error. Firefox DevTools showed this: That error led me to this JS code: I stared at those lines and saw nothing wrong — no missing variables, no typos, nothing obvious. I went to the original project code to find the exact non-rendered rows and noticed a server variable embedded into the client-side script: Which naturally led me to the server-side C# code responsible for generating that value: Nothing looked wrong there either. So I did what every developer does in ...

Configuring IIS to Allow CORS Requests (Fixing AJAX Calls to an API)

Image
The problem: sending AJAX requests from an HTML5 application running on my local machine to an API hosted under IIS (Google Cloud). The Setup Client: HTML/JS app on local machine Server: API under IIS (Google Cloud) The request looked like this: $.post({ url: apiEndpoint + "Init", contentType: "application/json; charset=utf-8", data: data, success: function (response) { logResponse("API response [Init]", response.d); }, error: function (xhr, status, error) { logResponse('Fail to call init API', data); } }); The error looked like this: Originally, there was crossDomain: true in the AJAX request, but it didn’t help. There were also crossdomain.xml and clientaccesspolicy.xml on the server — also useless for this case. What I Tried (And Why It Didn’t Help) I found many client-side “solutions” for AJAX, but they did not solve the issue....

TRIM Unwanted Characters from String in SQL (Quick Tip)

Small thing. Useful thing. I didn’t know that TRIM in SQL can remove specific characters — not only spaces. Example TRIM ( '.,! ' FROM '# test .' ) What It Does This removes any of the following characters from both sides of the string: Dot . Comma , Exclamation mark ! Space The result: '# test' Why It’s Useful Cleaning imported data Sanitizing user input Preparing text before comparison Normalizing values for indexing Short. Simple. Powerful.

Error Starting SQL Server 2017 Service – Error Code 3417 (Code Page 65001 Fix)

This was already the third time I had to uninstall and reinstall SQL Server 2017 Developer Edition on my local machine. Everything worked fine for a few days. Then suddenly the service refused to start with: Cannot recover the master database. SQL Server is unable to run. Restore master from a full backup, repair it, or rebuild it. For more information about how to rebuild the master database, see SQL Server Books Online. Error Code 3417 – The Symptom I tried everything: Checking permissions on master.mdf Security changes Service account verification Full uninstall and reinstall Nothing worked. Then I checked the SQL Server error log more carefully and noticed this line appearing before the main failure: Error: 2775, Severity: 17, State: 12. The code page 65001 is not supported by the server The Plot Twist I went to Google and found this article . The author basically talked with himself — logs, screenshots, assumptions, theories — debugging in public. ...

Please welcome our new application - ArtPlayBox!

Image
Hi all, Please welcome our first Android application ArtPlayBox ! It's designed for tablets but supports smartphones as well.  Reviews, stars and post shares will be very appreciated! :-) Thank you in advance!

Company Site Update

I make some changes in my site. The most of them is a prototype of universal content localization engine that can be applyed on web content without changes in DB or server-side code. It's a good start for Language Medium platform that is going to be easy and useful. NOTE: not all text content is localized to Russian right now - only menu, first section and few first Projects. It's becasue the engine is without BackOffice right now and all translations I'm adding  directly in DB:-) But don't worry - it will be soon B-) Also there are links to projects pages and some of them are real :-)

Remove Items From One List That Exist in Another List by ID in C#

Sometimes you need to remove elements from one collection if they already exist in another collection. The comparison is usually based on an identifier (ID). After testing several approaches, this turned out to be the cleanest and most readable solution using LINQ: lst1.RemoveAll(itemFromLst1 => lst2.Any(itemFromLst2 => itemFromLst2.ID == itemFromLst1.ID)); What This Code Does The logic can be read as: For each item in lst1 Check if any item in lst2 has the same ID If yes — remove it from lst1 In other words, this removes all elements from lst1 whose IDs already exist in lst2 . Why This Approach Works Well Concise and expressive No manual loops required No temporary collections needed Uses built-in List<T>.RemoveAll method The method RemoveAll modifies the list in place, which is often exactly what you want in filtering scenarios. Performance Consideration This solution uses Any() inside RemoveAll() , which means it performs a nest...

Pluralizing Words in C# (.NET) Using PluralizationService

Today I needed to generate a dynamic page title based on a category name. For example: My Playlists My Libraries My Categories The page receives a categoryID parameter, retrieves the corresponding category object, and then dynamically pluralizes the category name. Using PluralizationService in .NET .NET provides a built-in service for pluralization via System.Data.Entity.Design.PluralizationServices . using System.Data.Entity.Design.PluralizationServices; .... Category category = Category.GetByID(categoryID); PluralizationService ps = PluralizationService.CreateService( new System.Globalization.CultureInfo( "en-GB" )); Page.Title = $"My { ps.Pluralize( category .Name) }" ; ..... Important Note You must add a reference to System.Data.Entity.Design in your project. When to Use This This approach is useful when: Generating dynamic titles Building admin dashboards Creating REST endpoints with plural resource names Displaying catego...

MongoDB Atlas Cloud Cluster Test – Connecting to .NET Successfully

Today I performed an initial test of MongoDB Atlas , the managed MongoDB Cloud Cluster that can run on different cloud providers. The full setup — from cluster creation to a working connection — took roughly one hour. For a managed distributed database platform, that timing is impressive. Environment Setup The goal was simple: Create a MongoDB Atlas cluster Configure network access Create a database user Connect from a .NET application The cluster provisioning itself was straightforward. The UI is clear, and the workflow is linear: project → cluster → security → connection. Connecting MongoDB Atlas to a .NET Application I successfully connected the cluster to a .NET application using the official MongoDB driver. This was particularly satisfying because about half a year ago, in a previous company, we failed to make it work. At the time, the issue seemed complex. Now I know the root cause. It was only an incorrect connection string. No networking issue. No fir...

Information and methods to handle it

Image

Low Disk Space on Recovery Drive Windows 10 — The Saga (And the Real Fix)

Image
A few months after a major Windows 10 update, I started getting the most annoying notification ever: The message appeared randomly. No pattern. No clear cause. Just constant irritation. The Situation My system looked like this: Disk D: is removable. C: and E: live on the same HDD. Siblings. So my logical plan was simple: shrink C:, extend E:, silence the warning. Disk Management Reality I opened Disk Management and saw this: E: did not have the same options as other partitions. No “Extend Volume…” available. The “Smart” Attempt I shrank C: by 2GB using “Shrink Volume…”. Unallocated space appeared between C: and E:. Then began the classic “dance with tambourine around the campfire”: Move partition Merge attempt Allocate space Retry Nothing worked. Third-Party Tools Trial Search results pointed to third-party partition managers. I tested multiple vendors, including Paragon Hard Disk Manager and Macrium Reflect. None of th...

SQLite to MS SQL – Import Script Using Linked Server

This post continues the previous article about connecting SQLite to SQL Server using an ODBC driver and a Linked Server. The script below retrieves table metadata from the SQLite linked server into a table variable and prepares a cursor over the table names. This can be used as a base for further automation or dynamic import logic. Retrieve Table Metadata declare @temp table ( col1 varchar(255), col2 varchar(255), [name] varchar(255), [type] varchar(255), col3 varchar(255) ) insert @temp exec sp_tables_ex 'Your_LinkedServer_Name' select * from @temp Create a Cursor Over Table Names DECLARE lstTables CURSOR FOR select [name] from @temp Important Notes The Linked Server must already be configured using the MSDASQL provider. The ODBC DSN must be created as a System DSN , not a User DSN. Make sure the DSN name matches the one used when creating the Linked Server. Do not use spaces in the DSN name to avoid query issues in SQL Server. Summ...

How to Import SQLite Database into MS SQL Server Using ODBC (Step-by-Step Guide)

Image
This guide explains how to connect a SQLite database file to Microsoft SQL Server using an ODBC driver and Linked Server configuration. The same ODBC DSN can also be used to open the database in MS Access. Overview The core requirement is creating a System DSN using a SQLite ODBC driver. Once configured, SQL Server can access the SQLite file through a Linked Server. Step 1 — Install SQLite ODBC Driver Download and install the appropriate version (match SQL Server bitness): http://www.ch-werner.de/sqliteodbc/ Step 2 — Create a System DSN Open ODBC Data Source Administrator: 64-bit: C:\Windows\System32\odbcad32.exe 32-bit: C:\Windows\SysWOW64\odbcad32.exe Create a System DSN and select “SQLite3 ODBC Driver”. Important: Do NOT use spaces in the DSN name. SQL queries against Linked Servers may fail if spaces are used. Step 3 — Create a Linked Server in SQL Server Run the following in SQL Server Management Studio: EXEC sp_addlinkedserver @server = 'SQ...

AliExpress Extention

Image
This is a first finished and published project today! :-) AliExpress Order Extractor

FB page created!

Company branded page was created today. Take a look! https://www.facebook.com/OxymoronTech

The blog embedded to the site

Today I did insertion of blog feed into the company site. That's how it looks: http://oxymoron-tech.oxy.co.il/Blog.aspx