React.js: The Front End Framework of the Future
youtube.com3 pointsby granttimmerman0 comments
// SETTINGS
var input = "rsa ecde srgu yhgr bv rsa ecde srgu yhgr bv hybtg ser erv";
input += " hybtg iii r hybtg ser erv tvr rrr rvgres rrr rvg rrr rvgres ";
input += "ggg rgh grs sxebbe cuuuhbgres grs sxebbe cbbbgvrsai";
var TIME_INTERVAL = 300;
// Add jquery
var script = document.createElement('script');
script.src = 'http://code.jquery.com/jquery-1.11.0.min.js';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);
function play () {
// Sound array setup
var soundArray = [];
var down = $.Event("keydown");
var up = $.Event("keyup");
input = ' ' + input; // hack
for (var i = 0; i < input.length; ++i) {
soundArray.push(input.toUpperCase().charCodeAt(i));
}
// Start sound
var index = 0;
function playSound () {
up.which = soundArray[index];
$("body").trigger(up);
++index;
down.which = soundArray[index];
$("body").trigger(down);
// // is there another?
if (index < soundArray.length) {
setTimeout(playSound, TIME_INTERVAL);
}
}
playSound();
}
(function loadjQuery () {
if (typeof jQuery === 'undefined') {
setTimeout(loadjQuery, 100);
} else {
play();
}
})(); function action(){
var opacity1 = $('#color-1')[0].getContext('2d').getImageData(0,0,1,1).data[3];
var opacity2 = $('#color-2')[0].getContext('2d').getImageData(0,0,1,1).data[3];
if(opacity1 > opacity2){
$('#color-1').trigger('click');
}else{
$('#color-2').trigger('click');
}
};
setInterval('action()', 100);
With Google Cloud Functions, you can run your function locally using the Function Framework libraries (available in all Cloud Function languages) [0]. These libraries are used in production Cloud Functions, so you're not emulating the runtime. The feedback loop / devX is pretty simple with just 1 command to run the function locally like a library for every language.
We have some guides on local development here [1]. Our samples have system tests that use the FF.
You also can bundle your function in a container after building it with `pack build` [2]. This provides an exact container environment with things like environment variables and system packages.
We're working on improving eventing devX, but we have some `curl` examples here [3]. Connecting multiple functions together eloquently is still something to be desired though.
[0] https://github.com/GoogleCloudPlatform/functions-framework [1] https://cloud.google.com/functions/docs/running/overview [2] https://cloud.google.com/functions/docs/building/pack [3] https://cloud.google.com/functions/docs/running/calling