Get environmental variables in NextJs

NextJS has a built-in support for environmental variables. This is how they do it import { loadEnvConfig } from ‘@next/env’;const { API_URL } = loadEnvConfig(‘./’, true).combinedEnv This is useful for when you need to manually access what’s in those .env.* files.

How to restore database in a mssql docker container using .bak

Start the container and attach the local folder to the docker container docker run -v /Users/mac/data:/sqldata -e ‘ACCEPT_EULA=Y’ -e ‘MSSQL_SA_PASSWORD=<YourStrong!Passw0rd>’ -p 1433:1433 -d microsoft/mssql-server-linux:latest Run the restore database command sqlcmd -S localhost,1433 -U SA -P ‘<YourStrong!Passw0rd>’ -Q “USE [master] RESTORE DATABASE [mydatabase] FROM DISK = N’/sqldata/MyBackup.bak’ WITH FILE = 1, MOVE ‘MyBackup’ TO ‘/var/opt/mssql/data/MyBackup.mdf’, MOVE… Continue reading How to restore database in a mssql docker container using .bak

How to use SheetJS XLSX with Angular 4 Typescript in the browser

It took me a while to figure this out, so I’ll share my code here. You will need the `file-saver` and `xlsx` npm packages. There are two important parts: 1. Make sure you specify the `meta` section in systemjs or else it won’t load `XLSX.utils` 2. Use the correct `XLSX.write` parameters, otherwise you will get… Continue reading How to use SheetJS XLSX with Angular 4 Typescript in the browser

heroku npm install not updating because of cache

Wasted a frustrating hour trying to figure out why `npm install` and `npm install foobar` would not update my package. Finally found this: https://devcenter.heroku.com/articles/nodejs-support#cache-behavior Their caching is very rigid. Even if `npm install` runs and it tells you the package is updated, it won’t update. The cache will just replace itself. Even deleting the entire… Continue reading heroku npm install not updating because of cache

How to run angular 4 karma tests on circleci

Here is what I had to add to my circle.yml machine: node: version: 6.10.1 test: override: – npm run-script test:once 1) Setting node version is important on CircleCI otherwise you’ll get a bunch of peer dependencies errors. 2) Karma is set up to run tests continuously, which is not good on CircleCI.