Skip to content

Instantly share code, notes, and snippets.

@jesperorb
jesperorb / firebase_object_to_array.js
Created Jun 19, 2017
Firebase object to array: { key: '' , value: ''}
View firebase_object_to_array.js
let arr = Object.entries(obj).map(entry => Object.assign({value: entry[1]}, { key: entry[0] }));
View react_patterns.md
@jesperorb
jesperorb / sublime_projects.md
Last active Aug 9, 2022
Create Projects in Sublime Text 3
View sublime_projects.md

Sublime Projects 📁

You can create Projects which contains multiple folders and can have individual settings depending on the project. A project is a folder or a group of folders saved at a certain state that will be remembered everytime you close the project.

You can also quick switch between projects with CMD + CTRL + P or CTRL + ALT + P

If your are using Atom or vscode there is a plugin to add this behavior:

@jesperorb
jesperorb / git.md
Last active Nov 23, 2019
Git Stuff
View git.md

Git Commands

  • git clone /path/to/repository: Clone a repo
    • git clone https://github.com/jesperorb/json-server-heroku.git: basic clone
    • git clone https://github.com/jesperorb/json-server-heroku.git my-own-folder-name: with custom folder name (not the same as the repo name)
    • git clone git@github.com:jesperorb/json-server-heroku.git: only if you have manually set up SSH
  • git init: Initiate a new repo in current folder (without clone):
  • git add: Add files to staging area, must before commiting
    • git add .: adds all files
    • git add file-name another-file-name: adds one or more files
@jesperorb
jesperorb / heroku_deploy.md
Last active Nov 1, 2022
Instructions to deploy your app to Heroku
View heroku_deploy.md

Deploy to Heroku

Heroku

Heroku is a free hosting service for hosting small projects. Easy setup and deploy from the command line via git.

Pros
  • Easy setup
  • Free
@jesperorb
jesperorb / env_variables.md
Last active Sep 4, 2021
What the hell is env variables and how to add to path
View env_variables.md
@jesperorb
jesperorb / music_for_programming.md
Last active Apr 7, 2017
Music for Programming 💾 🔉
View music_for_programming.md
@jesperorb
jesperorb / cors.md
Last active Nov 10, 2022
Handle CORS Client-side
View cors.md

Handle CORS Client-side

Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources (e.g. fonts) on a web page to be requested from another domain outside the domain from which the first resource was served. This is set on the server-side and there is nothing you can do from the client-side to change that setting, that is up to the server/API. There are some ways to get around it tho.

Sources : MDN - HTTP Access Control | Wiki - CORS

CORS is set server-side by supplying each request with additional headers which allow requests to be requested outside of the own domain, for example to your localhost. This is primarily set by the header:

Access-Control-Allow-Origin