Skip to content

Instantly share code, notes, and snippets.

@PaquitoSoft
PaquitoSoft / googleanalytics_problem_1
Created September 29, 2012 14:46
Problem with googleanalytics nodejs module
var ga = require('googleanalytics'),
util = require('util');
var GA = new ga.GA();
GA.login(function(err, token) {
var options = {
'ids': 'ga:UA-29498666-1',
'start-date': '2012-09-01',
'end-date': '2012-09-30',
'dimensions': 'ga:pagePath',
@PaquitoSoft
PaquitoSoft / geddy_base_controller.js
Created October 17, 2012 09:44
Geddy base behaviour for controllers
/*
* Geddy JavaScript Web development framework
* Copyright 2112 Matthew Eernisse (mde@fleegix.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@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:

@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() {
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); });
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); });
@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

@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 / 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 {
<!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>