This file contains 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
function toUserTimeZone(utc_date, offset){ | |
if (utc_date.slice(-3) !== "UTC") { | |
utc_date += " UTC"; | |
} | |
var local_date = new Date(utc_date); | |
var local_offset = local_date.getTimezoneOffset() * 60000; | |
var utc_time = local_date.getTime() + local_offset; | |
return new Date(utc_time + (3600000 * offset)); | |
} |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>React Tutorial</title> | |
<link rel="stylesheet" href="css/base.css" /> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.16/browser.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script> |
This file contains 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
/* Creates a new queue. A queue is a first-in-first-out (FIFO) data structure - | |
* items are added to the end of the queue and removed from the front. | |
*/ | |
function Queue(){ | |
// initialise the queue and offset | |
var queue = []; | |
var offset = 0; | |
// Returns the length of the queue. |
This file contains 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
function leftpad (str, len, ch) { | |
str = String(str); | |
var i = -1; | |
if (!ch && ch !== 0) ch = ' '; | |
len = len - str.length; | |
while (++i < len) { | |
str = ch + str; | |
} | |
return str; | |
} |
This file contains 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
<!-- Learn about this code on MDN: https://developer.mozilla.org/en-US/docs/Web/API/notification --> | |
<script src="notify.js"></script> | |
<button onclick="notifyMe()">Notify me!</button> |
This file contains 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
git fetch --all | |
git reset --hard origin/master | |
git pull origin master |
This file contains 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains 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
Step 1: Upgrade Packages | |
# yum update | |
# yum -ygroupinstall "Development Tools" | |
Step 2: Installing Recommended Packages | |
# yum -y install gcc-c++ patch readline readline-devel zlib zlib-devel | |
# yum -y install libyaml-devel libffi-devel openssl-devel make | |
# yum -y install bzip2 autoconf automake libtool bison iconv-devel | |
Step 3: Install RVM ( Ruby Version Manager ) |
This file contains 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
function CalculateDistance(lat1, long1, lat2, long2) { | |
// Translate to a distance | |
var distance = | |
Math.sin(lat1 * Math.PI) * Math.sin(lat2 * Math.PI) + | |
Math.cos(lat1 * Math.PI) * Math.cos(lat2 * Math.PI) * Math.cos(Math.abs(long1 - long2) * Math.PI); | |
// Return the distance in miles | |
//return Math.acos(distance) * 3958.754; | |
// Return the distance in meters |
This file contains 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
function getUserDetail(username) { | |
if (userCache[username]) { | |
return Promise.resolve(userCache[username]); | |
} | |
// Use the fetch API to get the information | |
return fetch('users/' + username + '.json') | |
.then(function(result) { | |
userCache[username] = result; | |
return result; |