Skip to content

Instantly share code, notes, and snippets.

View ahouck's full-sized avatar

Adam Houck ahouck

  • Self
  • Washington D.C.
View GitHub Profile
" Don't try to be vi compatible
set nocompatible
" Helps force plugins to load correctly when it is turned back on below
filetype off
" TODO: Load plugins here (pathogen or vundle)
" Turn on syntax highlighting
syntax on

Object.setPrototypeOf()

This sets the prototype (i.e., the internal [[Prototype]] property) of a specified object to another object or null.

Generally considered the proper way to set the prototype of an object, vs. the more controversial Object.prototype.proto property.

@ahouck
ahouck / Object.is.md
Last active February 19, 2016 00:36
A intro to the new Object.is() feature in ES2015

Object.is() - A new comparator

This is not the same as being equal according to the == operator. The == operator applies various coercions to both sides (if they are not the same Type) before testing for equality (resulting in such behavior as "" == false being true), but Object.is doesn't coerce either value.

This is also not the same as being equal according to the === operator. The === operator (and the == operator as well) treats the number values -0 and +0 as equal and treats Number.NaN as not equal to NaN.

@ahouck
ahouck / gist:c7274ba28c5a1bcde188
Created February 8, 2015 03:09
Generic function to create HTTP Request for consuming REST interface using Java and Spring
//Utility for sending a HTTP request to an API interface regardless of parameters.
//Used this in a situation where a collection of different requests needed to be made and their result captured.
import org.springframework.http.HttpEntity;
import org.springframework.http.ResponseEntity;
import org.codehaus.jackson.map.ObjectMapper; //Can be used to map result to POJO
import org.json.JSONObject;
public void doRequest(ApiCall apiCall){
//ApiCall is just a custom wrapper class to hold all parameters for a specific API transaction that needs to occur.