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
// CORS Support in my Node.js web app written with Express | |
// http://stackoverflow.com/questions/7067966/how-to-allow-cors-in-express-nodejs | |
app.use(function(req, res, next) { | |
res.header("Access-Control-Allow-Origin", "*"); | |
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); | |
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD'); | |
next(); | |
}); |
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
export default class UUID { | |
constructor() { | |
var d = new Date().getTime(); | |
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { | |
var r = (d + Math.random() * 16) % 16 | 0; | |
d = Math.floor(d / 16); | |
return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16); | |
}); | |
return uuid; | |
} |
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 strict'; | |
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication | |
// http://creativecommons.org/publicdomain/zero/1.0/ | |
(function() { | |
// Update 'version' if you need to refresh the cache | |
var staticCacheName = 'static'; | |
var version = 'v1::'; |
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
var fs = require("fs"); | |
var data = fs.readFileSync("../images/html5logos/black.png", "utf8"); | |
console.log(new Buffer(data).toString('base64')); |
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
var browser = cordova.InAppBrowser.open('http://amazon.com?vitumob_session_id=13279njke12hjhuidhiush124hu', '_blank', 'location=no'); | |
browser.addEventListener('loadstart', function(event) { | |
alert('Began loading this page: ' + JSON.stringify(event)); | |
}); | |
// event fires when the InAppBrowser finishes loading a URL. | |
browser.addEventListener('loadstop', function(event) { | |
// event => {type: 'loadstop', url: 'URL navigated to'} | |
// alert('InAppBrowser Event: ' + JSON.stringify(event)); |
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
import collections | |
import re | |
class Parser(object): | |
Token = collections.namedtuple('Token', ['typ', 'value']) | |
def tokenize(self, statement): | |
token_specification = [ | |
('NUMBER', r'\d+(\.\d*)?'), # Integer or decimal number |
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
# To Freckle work time | |
function freckle() { | |
# Set the project ID here | |
ProjectID=378484 # change it to desired project ID (no spaces please) | |
adjust="1" | |
# if a third argument has been provided | |
if [ $3 ]; then | |
if [ "${#3}" -eq 6 ]; then |
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
var insert = function(array, rightIndex, value) { | |
for(var j = rightIndex; | |
j >= 0 && array[j] > value; | |
j--) { | |
array[j + 1] = array[j]; | |
} | |
array[j + 1] = value; | |
}; | |
var insertionSort = function(array) { |
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
var swap = function(array, firstIndex, secondIndex) { | |
var temp = array[firstIndex]; | |
array[firstIndex] = array[secondIndex]; | |
array[secondIndex] = temp; | |
}; | |
var indexOfMinimum = function(array, startIndex) { | |
var minValue = array[startIndex]; | |
var minIndex = startIndex; |
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
{% extends "layout.html" %} | |
{% block content %} | |
<!--Enter Name --> | |
<div class="enter-name"> | |
<div class="grid-100"> | |
<img src="/static/img/bear_avatar.svg" class="bear-avatar" /> | |
</div> | |
<div class="grid-100"> | |
<form action="{{ url_for('save') }}" method="POST"> | |
<label>Name your bear</label> |