RSSAmplifier

Blog

Sammaye's Blog

Bow Chicka Bow Wow

sammaye.wordpress.comRSS feed ↗10 posts

Latest posts

Vibe coding lost my database

So today I was awoken to the fact that my database had mysteriously lost data after putting out a new feature. This a MongoDB database whereby, via the driver, you can replace documents. After some digging I found that despite calling a function “updateEmployer” GitHub Co-Pilot had actually written the body of a function called […]

Fix random white space under react native AvoidKeyboardView after closing keyboard

https://github.com/facebook/react-native/issues/29614#issuecomment-3069870022 this worked best for me: const [behaviour, setBehaviour] = useState(‘height’); useEffect(() => { const showListener = Keyboard.addListener(‘keyboardDidShow’, () => { setBehaviour(‘height’); }); const hideListener = Keyboard.addListener(‘keyboardDidHide’, () => { setBehaviour(undefined); }); return () => {…

Non legacy rate-limit-mongo

'use strict'; const MongoClient = require('mongodb').MongoClient; const _ = require('lodash'); /** * @typedef IMongoStoreDocument * @extends import('mongodb').Document * @property {import('mongodb').ObjectId} _id * @property {number} counter * @property {Date} expirationDate * @property {string} [key] */ class MongoStore { /** @type {import('mongodb').MongoClient} */ client; /** @type {{uri:…

What Priority Does JS load At?

https://addyosmani.com/blog/script-priorities/

GitHub Actions Angular Testing

Using this https://bojnansky.com/running-angular-tests-with-github-actions/ as a guide I made GitHub actions for angular testing, I used this action: With the npm command in the link:

Angular PWA serve one page allowing iframe embedding on Cloudfront

function handler(event) { const request = event.request; const response = event.response; const headers = response.headers; let original_uri = ''; if (request.headers.hasOwnProperty('x-original-uri')) { original_uri = request.headers['x-original-uri'].value; } let referer = ''; if (request.headers.hasOwnProperty('referer')) { referer = request.headers['referer'].value; } if ( ( // Super important!…

NodejS unit testing

A good env: A good env setup: jest.config.js jest-mongodb-config.js A global file for running predictable tests: setup-jest.js I also tend to add some helper components, namely a base record creator like so: BaseFixture.js UserFixture.js So an example unit test making use of these would be:

Run only one test with ng test

ng test –include=’**/sign-in.component.spec.ts’

AWS Network ACL not working on port 80 and 443

This is because NACL is used for internal routing as well so you need to add the ephemeral ports, i.e. https://docs.aws.amazon.com/vpc/latest/userguide/vpc-network-acls.html#nacl-ephemeral-ports most commonly 1024-65535, all AWS services use these ports to communicate

Log slow requests with express.js

You can do this with response-time plugin but I wanted something a bit more flexible and can easily be used on select routes as middleware, so I made: in my base expressjs route file, now I can easily log certain routes by doing: