Skip to main content

Posts

Use NVM to handle Angular-Node.js incompatibility (e.g., Uncaught SyntaxError: Unexpected token 'export')

Overview If you are a fullstack developer, the chances are that you will be creating multiple frontend or Node.js projects along the way. When you are creating new projects using the newest version of the cli (command-line interface) of a particular framework, you might be asked to install the most updated version of Node.js in order to utilize the newest feature. This might involve upgrading your Node.js version, which might not be compatible with other existing projects (e.g., using Angular) you have created before. A potential solution is to use nvm (Node Version Manager) to install multiple versions of Node.js and use a particular version of the Node.js to install the proper version of the cli (e.g., Angular-CLI) that can be used to manage a particular project. Here I will use a problem I run into to explain how to solve it. Problem There is a compatibility issue between Node.js and angular.js. For instance, I run into an error when I was using an incompatible version of Node.js ...
Recent posts

ngrok, a service to help you get a public URL for your local webserver

If you are looking for options to test your web app hosted on your own machine (e.g., laptop) remotely with someone, I recommend using a service called ngrok. https://ngrok.com/ It has many usages, but in the context of testing an app hosted on your own machine, the most important part is giving you a public URL that will redirect all the requests to your local webserver (e.g., Apache, Nginx, or whatever server you are running). You can give this URL to a testing participant without the need to host the app on a remote server. For instance, if you are testing your app using a sever on your machine, typically you can access your app in a URL like:  http://localhost:3000/?study=11 Using ngrok, you will have a dynamically generated URL like the following: https://3ebe3c019867.ngrok.io/ The service will redirect requests to https://3ebe3c019867.ngrok.io to http://localhost:3000 You can then share the following link with your testing participant for the participant to use your app. http...

Brackets: a free editor/environment for web development

 There are a lot of options, and VS Code is one of the top contenders. I am a VS Code fan, but if you are looking for an alternative, Brackets is another option that I find appealing. It was built for web development, using HTML/CSS/Javascript. I think it is especially helpful for people who just start learning HTML/CSS (and maybe Javascript). http://brackets.io/ Brackets has some built-in features that are pretty convenient. 1. auto-complete for CSS property and value. 2. Live preview the webpage to reflect the changes being made. You can make changes in code and see the result instantly. 3. In-place editing of CSS rules (you can select an element/class name in HTML and press the short keys to edit the corresponding CSS rules directly). 4. Code to browser mapping: you can select/edit an element in HTML or a rule in CSS, and the corresponding user interface elements or those that will be affected by the CSS rule will be highlighted in the browser. See this video for an overview. Th...

Prevent Endless Reboot after Updating your Apple Laptop's macOS, especially the macOS High Sierra 10.13 Supplemental Update

If you have a MacBook pro and you want to do the latest update (the small one after high sierra, or "macOS High Sierra 10.13 Supplemental Update"), you should probably 1. backup (e.g., time machine), 2. (important!) connect your laptop with ethernet, and 3. connect to a power source. My MacBook pro time-jumped to some time in 2016 after the update and it forced itself into a power-cord only endless reboot mode. No kidding! Endless reboot,  like you never hear the reboot sound effect so many times. After the update, it wouldn't start unless it was connected to a power source, but it would reboot a few seconds after that Apple loading progress bar reached around 60% or 90%. My current working hypothesis is that it has to be connected to the internet before it reaches that point. Otherwise, it restarts again before you could quickly choose a WiFi access point and enter the password. After a few hours trying all the special hotkey combinations suggested on the inter...

Basic tmux commands

Here are several basic commands for tmux , a terminal multiplexer. tmux list -> list all the session tmux attach -> attach the last session In session (or any window): Ctrl + b, c -> create window Ctrl + b, n -> next window Ctrl + b, p -> previous window Ctrl + b, l -> last window Ctrl + b, d -> detach session Ctrl + b, :rename-window New_Name_FOR_WINDOW -> rename current window In a window exit -> exist a window Reference Cheatsheet

Using Pandoc for Doing Citation and Bibliography in Markdown

Markdown is a simple formatting syntax that allows you to do common formatting with ease. Pandoc is a feature rich interpreter that helps you convert documents from one format to anther. If you are writing homework, research papers, or anything that needs citation and a bibliography, you can totally use Markdown and Pandoc to achieve that. Below is a set of instructions that you can follow to generate a document with in-text citation and bibliography. First, install Pandoc and the extension for creating citation ( pandoc-citeproc ).  There are several ways to install Pandoc, you can choose one of them recommended on the official website . On Mac, one way is to install Homebrew , a package manager, and then use Homebrew to install Pandoc and the extension. For Windows users, please refer the official website on how to install Pandooc and extension. Here I will show how to install Pandoc and the extension for citation through Homebrew. After installing homebrew, you can ...

How to update multiple fields in an SQL update statement

Syntax: /* the correct way of putting multiple fields together, using comma */ UPDATE `stories` SET `content`='Once upon a time ...', `update_time`=now() WHERE id=1; Note: there is no 'and' between the fields you are trying to update. You should use comma between each pair of the fields you are trying to update. Otherwise, you will likely get an '0' as the result value in the 'content' field without getting any error message. If you do the following, you will likely get an '0' in the 'content' field, without any error message /* the wrong way of putting multiple fields together, using 'and' */ UPDATE `stories` SET `content`='My Story' and `update_time`=now() WHERE id=1; See also:  http://stackoverflow.com/a/7375371