Skip to content

Instantly share code, notes, and snippets.

@lkatney
lkatney / google-analytics-server.js
Last active July 28, 2018 20:43
Server-Server integration between NodeJS and Google APIs to get page views on pages and top viewed pages on your website
var {google} = require('googleapis'), // official https://github.com/google/google-api-nodejs-client npm module
analyticsreporting = google.analyticsreporting('v4'),
key = require('./private.json');// Secure server key file(in JSON) dowloaded from Google
/********************** GET PAGE VIEWS *******************/
app.get('/analytics/report', cors(corsOptions), function(req,res){
//passed parameter
var url = req.query.url;
@lkatney
lkatney / middleware.js
Created July 14, 2018 14:48
Open Ghost 0.X to expose Post GET API Publically
// ### Authenticate Middleware
// authentication has to be done for /ghost/* routes with
// exceptions for signin, signout, signup, forgotten, reset only
// api and frontend use different authentication mechanisms atm
authenticate: function (req, res, next) {
var path,
subPath,
scope;
// SubPath is the url path starting after any default subdirectories
@lkatney
lkatney / file.directive.js
Last active July 22, 2018 22:55
Angular1 directive/component 'FilePicker' to handle file selection(taking pictures, choosing photos and files) from device
//file.directive.js
(function() {
'use strict';
angular
.module('starter.services')
.directive("file",function(){
return {
scope: {
onFilesSelection: '&',
@lkatney
lkatney / crud.operations.js
Last active July 28, 2018 21:43
Wrapper code for Postgres queries to do crud operations in Salesforce Tables to sync with Heroku Connect - pg 6.0.1
var pgClient;
exports.setConnection = function(client){
pgClient = client;
}
/*************************************************************************
*************************** CRUD OPERTIONS ***************************
************************************************************************/
exports.getRecords = function(objectApiName, config, callback){
@lkatney
lkatney / Usage.html
Last active February 24, 2021 03:45
Directive to handle number field scenarios on input[type=text]
<!-- Use attributes to configure input accordingly -->
<input type="text" placeholder="Enter number" numbers-only max-number="10" allow-decimals="true" set-decimal-places="3"/>