Skip to content

Instantly share code, notes, and snippets.

View andreasonny83's full-sized avatar
:octocat:
<Coding />

Andrea Z. andreasonny83

:octocat:
<Coding />
View GitHub Profile
@andreasonny83
andreasonny83 / .zshrc
Last active July 8, 2023 21:34
Auto switch Node Version with Nvm
find-nvmrc() {
local dir="$PWD"
while [[ "$dir" != "/" ]]; do
if [[ -f "$dir/.nvmrc" ]]; then
echo "$dir/.nvmrc"
return
fi
dir=$(dirname "$dir")
done
echo ""
@andreasonny83
andreasonny83 / README.md
Created July 20, 2019 13:07
Run node app in background

Run node app in background

Running a script in the background in linux can be done using nohup, using nohup we can run node application in the background

$ nohup node server.js > /dev/null 2>&1 &
  • nohup means: Do not terminate this process even when the stty is cut off
  • &gt; /dev/null means: stdout goes to /dev/null (which is a dummy device that does not record any output)
@andreasonny83
andreasonny83 / RELEASE-NOTES.md
Last active April 5, 2026 12:15
Release Notes Template

Release Notes Template

Based off https://palantir.quip.com/pzRwAVr1bpzf

Pro-tip: look through the github diff between the previous release to see what's changed. The commit titles should give an outline of what's happened.

Upgrade Steps

  • List out, as concretely as possible, any steps users have to take when they upgrade beyond just dumping the dependency.
  • Write pseudocode that highlights what code should change and how.
@andreasonny83
andreasonny83 / top.md
Last active January 21, 2020 12:58
Background processes

ps aux | grep node

run top find the process id (PID) ps -efl | grep 10399 kill -9 10399

@andreasonny83
andreasonny83 / class-facade.js
Created February 17, 2019 22:09
Facade pattern
/**
* The Facade pattern simplifies and hides the underlying complexity of a large abody of
* code by providing a cleaner and easy to use interface.
*/
class TaskService {
constructor(data){
this.name = data.name;
this.priority = data.priority;
this.project = data.project;
@andreasonny83
andreasonny83 / class-factory.js
Last active February 17, 2019 22:13
Factory Pattern
/**
* The factory pattern abstracts object creation by providing an interface, where we can specify the type of
* factory object to be created.
*
* The Factory pattern can be especially useful when applied to the following situations:
*
* - When our object or component setup involves a high level of complexity,
* e.g. if it strongly depends on dynamic factors or application configuration.
* - When we need to easily generate different instances of objects depending on the environment we are in
* - When we're working with many small objects or components that share the same properties
@andreasonny83
andreasonny83 / class-singleton.js
Last active February 17, 2019 22:15
Singleton Pattern
/**
* The singleton pattern is a pattern used to restrict an object to a single instance.
* A singleton creates an instance of an object if that object does not exist.
* If it exists it returns the existing instance.
*/
class Car {
constructor(model, year, miles) {
if(Car.exists){
return Car.instance
@andreasonny83
andreasonny83 / conditiona- value.js
Last active March 19, 2019 12:09
Conditional Object key
// Conditional value
const a = {
...(someCondition && {b: 5})
}
// Remove key from object
const postData = {
token: 'secret-token',
publicKey: 'public is safe',
{
"name": "package-name",
"version": "0.0.0",
"description": "package-name short description",
"main": "lib/cli/index.js",
"bin": {
"package-name": "./bin/index.js"
},
"scripts": {
"test": "jest --watchAll"
@andreasonny83
andreasonny83 / .gitignore
Last active December 15, 2025 18:31
Gitignore template for JavaScript projects
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# Runtime data
pids
*.pid