Skip to content

Instantly share code, notes, and snippets.

View cristiandouce's full-sized avatar
⚙️
fix fix fix

Cristian Douce cristiandouce

⚙️
fix fix fix
  • Buenos Aires, Argentina
View GitHub Profile

Keybase proof

I hereby claim:

  • I am cristiandouce on github.
  • I am cristiandouce (https://keybase.io/cristiandouce) on keybase.
  • I have a public key whose fingerprint is DE5C 2DF4 9FF1 EE95 D153 3C99 D169 5000 8311 BE8A

To claim this, I am signing this object:

@cristiandouce
cristiandouce / browserify_for_webpack_users.markdown
Last active August 29, 2015 14:26
browserify for webpack users

browserify for webpack users

There's been a strange explosion in misinformation about browserify recently, particularly in comparisons to webpack.

Generally speaking, most of this confusion stems from how webpack is more willing to pull features into its core to ease discoverability while browserify is more likely to push features out to userland instead.

I think that longer-term, separability has more benefits from a maintenance and

var $ = require('NodObjC');
$.import('Cocoa');
var installNSBundleHook = function() {
var cls = $.NSBundle;
if (cls) {
var bundleIdentifier = cls.getInstanceMethod('bundleIdentifier');
bundleIdentifier.setImplementation(function(val) {
@cristiandouce
cristiandouce / twitterAccounts.js
Created May 13, 2013 21:04
Get twitter usernames from any text with links to twitter profiles.
var regex = /twitter.com\/([a-zA-Z0-9_]{1,15})/gi;
var arr = [];
var text = document.body.innerHTML;
while ( (arr = regex.exec(text)) ) {
console.log(arr);
}
console.log(arr)
@cristiandouce
cristiandouce / inspector.js
Last active December 16, 2015 23:49
Files inspector
var fs = require('fs')
, path = require('path')
, EventEmitter = require('events').EventEmitter;
function Inspector () {
var _self = this;
_self.on('dir', function(dir) {
fs.readdir(dir, function(err, files) {
if (err) {
@cristiandouce
cristiandouce / parse.js
Last active December 16, 2015 12:59
Parse page content
var text = document.lastChild.innerHTML;
var regexs = {
// enclosing
script: /<(?:script)[\d\D]*?>[\d\D]*?<\/(?:script)>/gi,
noscript: /<(?:noscript)[\d\D]*?>[\d\D]*?<\/(?:noscript)>/gi,
style: /<(?:style)[\d\D]*?>[\d\D]*?<\/(?:style)>/gi,
iframe: /<(?:iframe)[\d\D]*?>[\d\D]*?<\/(?:iframe)>/gi,
frame: /<(?:frame)[\d\D]*?>[\d\D]*?<\/(?:frame)>/gi,
object: /<(?:object)[\d\D]*?>[\d\D]*?<\/(?:object)>/gi,
Option.prototype.getOption = function(setting) {
var ref = this;
setting = setting.split('.');
while (setting.length) {
if(!(ref = ref[setting.shift()])) break;
}
return ref;
}

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:

/*jslint undef: true, nomen: true, eqeqeq: true, plusplus: true, newcap: true, immed: true, browser: true, devel: true, passfail: false */
/*global window: false, readConvertLinksToFootnotes: false, readStyle: false, readSize: false, readMargin: false, Typekit: false, ActiveXObject: false */
var dbg = (typeof console !== 'undefined') ? function(s) {
console.log("Readability: " + s);
} : function() {};
/*
* Readability. An Arc90 Lab Experiment.
* Website: http://lab.arc90.com/experiments/readability
config.json
reading-image.png