Skip to content

Instantly share code, notes, and snippets.

View benslv's full-sized avatar

Ben Silverman benslv

View GitHub Profile
@GeorgeGkas
GeorgeGkas / index.js
Created July 29, 2018 09:43
Deep copy/clone a class instance in Javascript
/**
* @function
* @description Deep clone a class instance.
* @param {object} instance The class instance you want to clone.
* @returns {object} A new cloned instance.
*/
function clone(instance) {
return Object.assign(
Object.create(
// Set the prototype of the new object to the prototype of the instance.
@jhermann
jhermann / git-commit-emojis.md
Last active September 23, 2023 07:09
Useful emoji for git commit messages

Useful emoji for git commit messages

If you add emoji to your commit messages for a GitHub repo, they become less boring, and you can convey the kind of change you're adding. See the full set of GitHub supported emoji here (also useful for easy copy&paste via a simple click).

Example commit message

The following is a possible scheme to use:

@balupton
balupton / cors.js
Created September 11, 2012 05:21
Acheiving CORS via a Node HTTP Server
// Create our server
var server;
server = http.createServer(function(req,res){
// Set CORS headers
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Request-Method', '*');
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET');
res.setHeader('Access-Control-Allow-Headers', '*');
if ( req.method === 'OPTIONS' ) {
res.writeHead(200);