Skip to content

Instantly share code, notes, and snippets.

View dybxin's full-sized avatar

dybxin

  • shanghai
View GitHub Profile
@scottopolis
scottopolis / splice-object-array.js
Last active January 31, 2023 06:54
Remove object from array of objects in Javascript
// we have an array of objects, we want to remove one object using only the id property
const apps = [{id:34,name:'My App',another:'thing'},{id:37,name:'My New App',another:'things'}];
// get index of object with id of 37
const removeIndex = apps.findIndex( item => item.id === 37 );
// remove object
apps.splice( removeIndex, 1 );
@soheilhy
soheilhy / nginxproxy.md
Last active May 16, 2024 08:59
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@bencharb
bencharb / jsonmap2jsonobject.js
Last active September 29, 2021 07:04
JSON map to JSON object
/*
Credit: Tomalak on Stack Overflow
http://stackoverflow.com/a/11153997
Why?
Easier to pull data when the mapping is unknown or arbitrary.
Example:
the function nestedMapping() turns your data structure: