Skip to content

Instantly share code, notes, and snippets.

View a0viedo's full-sized avatar
🌯
no burrito no code

Alejandro Oviedo a0viedo

🌯
no burrito no code
View GitHub Profile
fn time
"for-loop 2" 528.697396
"for-loop 2" 526.681913
"for-loop 2" 424.507615
"for-loop 2" 426.928886
"for-loop 2" 421.559243
"for-loop 2" 420.16468
"for-loop 2" 424.456973
"for-loop 2" 423.543922
"for-loop 2" 424.287752
@a0viedo
a0viedo / fn-name.js
Created November 7, 2016 20:05
yo what's my name
function foo(){ console.log(new Error().stack)}
Object.defineProperty(foo, "name", { writable: true });
foo.name = 'yo';
foo()
@a0viedo
a0viedo / README.md
Last active January 20, 2017 20:09
Utility wrapper of D3.js that favors configuration to increase code reuse and gain simplicity to create charts.

I wrote a bunch of utility helpers for graphing data with pie charts, bar charts, scatter plots and histograms.

It reutilices many examples from [d3.org][d3.org], so many that I lost track of them all. I have only tested on d3's v3.

  • Bar charts:
    • Properties like width, height, X and Y axis domains, X and Y axis transforms, tips and margins can be passed through a configuration object
    • tips
    • helper to update graph from new data through animations
    • opt-in interpolation
  • Pie charts:
var fs = require('fs');
var through2 = require('through2');
var csv2 = require('csv2');
var SALARIO_MINIMO = 6000;
var lines = 0;
var conformidadPromedio = 0;
var promedioRemoto = 0;
var cantRemoto = 0;
var salarioPromedio = 0;
var TodoController = createController();
TodoController.prototype.onClickCheckbox = function() {
this.getModel().toggleDone();
};
checkit.TodoController = TodoController;
var MongoClient = require('mongodb').MongoClient;
var mongoURL = (process.env.OPENSHIFT_MONGODB_DB_URL || 'mongodb://localhost:27017/') + 'departureTimes';
module.exports = {
connectToDB: function(callback) {
var self = this;
if (self.db) {
return process.nextTick(callback.bind(null, null, self.db));
}
MongoClient.connect(mongoURL, function(err, db) {
var elements = [
{path: 'emement 1', type: 'html'},
{path: 'element 2', type: 'js'},
{path: 'element 3', type: 'js'},
{path: 'element 4', type: 'js'},
{path: 'element 5', type: 'html'},
{path: 'element 6', type: 'js'},
{path: 'element 7', type: 'js'},
];
console.log(elements);
@a0viedo
a0viedo / proxy.js
Last active November 3, 2015 22:56
un ejemplo de proxy con request
var http = require('http');
var request = require('request');
var server = http.createServer(function(req, res){
var endRequest = request({
url: 'http://yourendpointhere',
method: req.method,
headers: req.headers
});
req.pipe(endRequest);
models.Metric.count({
include: [{
model: models.Event,
include: [{
model: models.Device,
where: {
floor: '1'
}
}],
where: {