Skip to content

Instantly share code, notes, and snippets.

const Router = {
setup({ mountingElement, routingConfig, loadingCallback }) {
this.rootElement = mountingElement;
this.routingConfig = routingConfig;
this.loadingCallback = loadingCallback;
// Listen to click events in the document
// If an A tag was clicked, client-side navigate
// to its link url
import routingConfig from './config/routing.js';
import Router from './components/shared/router/router.js';
const app = document.createElement('div');
app.innerHTML = `
<div class="header clearfix">
<h3 class="text-muted">
<a href="/">Podcaster</a>
<div class="spinner hidden">
<!DOCTYPE>
<html>
<head>
<meta charset="utf-8">
<title>Podcaster VanillaJS Components</title>
<link rel="stylesheet" href="./src/styles/bootstrap.min.css">
<link rel="stylesheet" href="./src/styles/app.css">
</head>
<body>
@PaquitoSoft
PaquitoSoft / ajax.js
Created August 23, 2015 10:27
A JS plugin to handle AJAX request (ES2015)
import lscache from 'lscache';
let _xmlParser = new DOMParser(),
jsonpCallbackId = 0,
jsonpTimeoutHandler = function(){};
function checkResponseStatus(res) {
if (res.status < 400) {
return res;
} else {
@PaquitoSoft
PaquitoSoft / basic-model-routes.js
Last active August 29, 2015 14:20
Mongoose model basic express routes
'use strict';
/*
Credits to Jakob Mattsson
Link: https://vimeo.com/51736205
*/
function _createModelRoutes(modelName, app) {
var Model = models[modelName],
// http://stackoverflow.com/questions/8955533/javascript-jquery-split-camelcase-string-and-add-hyphen-rather-than-space
@PaquitoSoft
PaquitoSoft / gist:6751898
Last active December 24, 2015 05:39
Mantenimiento fotovoltaicas

MANTENIMIENTO DE INSTALACIONES FOTOVOLTAICAS CONECTADAS A RED

Al igual que, en instalaciones fotovoltaicas autónomas, con el objeto de garantizar una alta productividad de la instalación fotovoltaica conectada a red, no basta con diseñar, montar y verificar correctamente los compoenntes y el sistema, evitar sombras, etc, sino que también es necesario reducir los periodos de parada por avería o mal funcionamiento. Por tanto, es necesario ralizar labores tanto de mantenimiento preventivo como de mantenimiento correctivo.

Estas operaciones, en algunas ocasiones, podrán ser efectuadas por el propio usuario del sistema. En troas, será necesaria la asistencia de un servicio técnico.

Por la morfología de las propias instalaciones fotovoltaicas conectadas a red, en general, precisan muy poco mantenimiento preventivo siendo, en raros casos, los mantenimientos correctivos.

MANTENIMIENTO PREVENTIVO

var step = 0;
async.waterfall([
function (next){
step = 1;
getJson('/user', function(user) { next(null, user); });
},
function (user, next){
step = 2;
getJson('/twitter_profile', user.twitterId, function(twitterProfile) { next(null, user, twitterProfile); });
var step = 0;
async.series([
function (next){
step = 1;
getJson('/country', function(data) { next(null, data); });
},
function (country, next){
step = 2;
getJson('/weather', function(data) { next(null, data); });
@PaquitoSoft
PaquitoSoft / jasmine.basic.reporter.js
Created January 20, 2013 23:00
This is a simplistic reporter Blanket.js (http://migrii.github.com/blanket/) which adds a summary coverage statistic to Jasmine (http://pivotal.github.com/jasmine/) top bar. If you enable branch coverage in blanket, this reporter will highlight the files with warnings and it also change the summary statistic color.
/*
Place this file in your Jasmine tests root folder and tell blanket to use it.
Example:
<script src="lib/blanket_jasmine.js" data-cover-reporter="lib/jasmine.basic.reporter.js"></script>
If you want to catch branch coverage warning, you must enable it:
<script src="lib/blanket_jasmine.js" data-cover-flags="branchTracking" data-cover-reporter="lib/jasmine.basic.reporter.js"></script>
*/
define([], function JasmineBasicReporter() {
@PaquitoSoft
PaquitoSoft / g_analytics_oauth_nodejs.md
Last active February 18, 2020 21:19
Article describing the process of accessing Google Analytics data from a nodejs application using a service account.

Consuming Google Analytics data from a NodeJs application using a service account

I didn't have a great time trying to implement a simple feature involving Google Analytics in one of my projects (nodejs web application).

My humble requirement was to collect some data (events) I was pushing to Google Analytics in order to create a simple report for my users. Since it isn't a critical report, my idea was to get the data once a day and cache it.

So, as simple as it seems, it has been a tough trip for me and I want to share the whole process with the community. I hope anyone trying to achive something similar gets to this article and find it helpful.

These are the main steps I had to take: