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 http = require('http'); | |
var fs = require('fs'); | |
var download = function(url, dest, cb) { | |
var file = fs.createWriteStream(dest); | |
var request = http.get(url, function(response) { | |
response.pipe(file); | |
file.on('finish', function() { | |
file.close(cb); // close() is async, call cb after close completes. | |
}); |
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
const someReallyUsefullFunction = async (text) => { | |
// Break in parts small enough to be handle by Polly API | |
const parts = divideTextEnoughToBeHandleByPolly(text) | |
// Concat AudioStreams in one Buffer | |
const audioStreams = audios.map(a => a.AudioStream) | |
const buffer = Buffer.concat(audioStreams, audioStreams.reduce((len, a) => len + a.length, 0)) | |
... | |
} |
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
// Load the SDK | |
const AWS = require('aws-sdk') | |
const Fs = require('fs') | |
// Create an Polly client | |
const Polly = new AWS.Polly({ | |
signatureVersion: 'v4', | |
region: 'us-east-1' | |
}) |
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 ImageCache from './image-cache.js' | |
var imageCache = new ImageCache(); | |
var img = $(el).find('img'); | |
imageCache.loadImage(img[0], img.attr('src')); |
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 count = function(txt, rank) { | |
var wordFreq = {}; | |
var words = txt.split(' '); | |
for (i = 0; i < words.length; i++) { | |
var current = words[i]; | |
var last = current.length - 1; | |
current = noPunc(current); | |
if (notInArray(current, particle) && !wordFreq[current]) { | |
wordFreq[current] = 1; | |
} |
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-Module -Name D:\Temp\ACME-posh\ACMEPowerShell.psd1 | |
$domain = "mydomain.com" | |
$certificiatePassword = "abcd1234" | |
$email = "letsencrypt@mydomain.com" | |
$vault = "D:\Vault\{0}\{1}" -f $domain, [guid]::NewGuid() | |
mkdir $vault | |
cd $vault | |
Initialize-ACMEVault -BaseURI https://acme-v01.api.letsencrypt.org/ | |
New-ACMERegistration -Contacts mailto:$email |
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 util = require('util'); | |
var request = require('request'); | |
var clientId = 'test-app'; // Can be anything | |
var clientSecret = 'f6f0bfec08274b8790520a9079b808af'; // API key from Azure marketplace | |
var str = 'This is a cool demo to call Microsoft text to speach service in Node.js.'; | |
console.log('Converting from text -> speech -> text.'); |
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
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback | |
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB; | |
// Open (or create) the database | |
var open = indexedDB.open("MyDatabase", 1); | |
// Create the schema | |
open.onupgradeneeded = function() { | |
var db = open.result; | |
var store = db.createObjectStore("MyObjectStore", {keyPath: "id"}); |
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
// <img id="myimage" src="http://placecage/1280/720"> | |
var image = document.getElementById('myimage'); | |
var mc = new Hammer.Manager(image); | |
var pinch = new Hammer.Pinch(); | |
var pan = new Hammer.Pan(); | |
pinch.recognizeWith(pan); |
NewerOlder