This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Return true/false if key is found in Object (one level) | |
* @param {object} object where to try find key | |
* @param {string} key - string to find in object | |
* @return {boolean} true/false if key is found | |
*/ | |
var foundInObject = function (object, key) { | |
var keyFound = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require("http"), | |
url = require("url"), | |
path = require("path"), | |
fs = require("fs") | |
port = process.argv[2] || 8888; | |
http.createServer(function(request, response) { | |
var uri = url.parse(request.url).pathname | |
, filename = path.join(process.cwd(), uri); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/a/18368720 | |
// http://codepen.io/mrmoje/pen/lkLez | |
// HTML | |
<div contentEditable=true data-placeholder="My Placeholder String"></div> | |
// CSS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var React = require('react'); | |
var Medium = require("medium.js"); | |
function setupEditable(self) { | |
var editable = self.props.editable; | |
var extraOptions = self.props.extraOptions; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arrayData = [...]; | |
var arrayOfItems = arrayData.map(function(item, i) { | |
return ( | |
<item key={i}>{item}</item> | |
); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- http://joakimbeng.eu01.aws.af.cm/a-javascript-router-in-20-lines/ --> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Building a router</title> | |
<script> | |
// Put John's template engine code here... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var copyProperties = require('react/lib/copyProperties'), | |
Dispatcher = require('flux').Dispatcher, | |
util = require('util'); | |
function AppDispatcher() { | |
Dispatcher.call(this); | |
this._queue = []; | |
} | |
util.inherits(AppDispatcher, Dispatcher); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://davidwalsh.name/javascript-clone | |
function clone(src) { | |
function mixin(dest, source, copyFunc) { | |
var name, s, i, empty = {}; | |
for(name in source){ | |
// the (!(name in empty) || empty[name] !== s) condition avoids copying properties in "source" | |
// inherited from Object.prototype. For example, if dest has a custom toString() method, | |
// don't overwrite it with the toString() method that source inherited from Object.prototype | |
s = source[name]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get array of sorted Object's keys | |
* @param {object} Object which keys do you want to sort | |
* @param {boolen} byValue - false/null if you want to sort Object keys by Object's keys | |
* @param {boolen} byValue - true if you want to sort Object keys by Object's properties value | |
* @param {string} byValue - string if you want to sort Object keys by value inside each Object's property | |
* @return {array} Array of sorted keys (strings) | |
*/ | |
var getSortedObjKeys = function(obj, byValue) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://stackoverflow.com/questions/2862590/how-to-replace-master-branch-in-git-entirely-from-another-branch | |
You should be able to use the "ours" merge strategy to overwrite master with AnotherBranch like this: | |
git checkout AnotherBranch | |
git merge -s ours master | |
git checkout master | |
git merge AnotherBranch | |
The result should be your master is now essentially AnotherBranch. |