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

Adaptive Image Element

Author:

Mat Marquis

Status of this Document

This is an unofficial draft spec, not formally endorsed by the WHATWG. It is suitable only for reviewing the details of the proposed element.

Table of Contents

(function($){
function dragEnter(e) {
$(e.target).addClass("dragOver");
e.stopPropagation();
e.preventDefault();
return false;
};
function dragOver(e) {
e.originalEvent.dataTransfer.dropEffect = "copy";
@cristiandouce
cristiandouce / gist:4237824
Created December 8, 2012 00:35 — forked from betzerra/gist:4236646
Curl commands
#GET
curl -HAccept:text/plain http://example.com/base
#PUT
curl -XPUT -HContent-type:text/plain --data "stuff:morestuff" http://example.com/base?param=val
#DELETE
curl -XDELETE http://example.com/base/user/123
#POST
config.json
reading-image.png
config.json
reading-image.png
/*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

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:

Option.prototype.getOption = function(setting) {
var ref = this;
setting = setting.split('.');
while (setting.length) {
if(!(ref = ref[setting.shift()])) break;
}
return ref;
}
@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,
@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) {