Skip to content

Instantly share code, notes, and snippets.

View warborn's full-sized avatar

Iván Munguía warborn

View GitHub Profile
@warborn
warborn / dashboards_spec.md
Last active October 22, 2018 18:31
A first approach to the development of the Dasboard's feature

Dashboards Spec

Elasticsearch Index

In order to have a flexible schema that will be easy to maintain, the proposed approach is to save a Dashboard as a String that stores a JSON document that can be parsed by GraphQL and at the end by our frontend.

The index representation is the following one:

curl -k -XPUT --silent "http://localhost:9200/dashboards_v1?pretty" -H 'Content-Type: application/json' -d '

Introduction to Functional Programming in JavaScript

  1. Benefits of Functional Programming
  2. Pure Functions & Side-Effects
  3. Point-Free style
  4. Function Composition

Benefits of functional programming

  • Useful patterns tested and proven along the years
  • "Code that you don't understand is code that you cannot trust"

Insights Builder

Insights Builder is a module that allows to query different source of data in order to extract information and transform it in a format which can be used to generate dynamic charts.

Summary

In order to extract the information, the following steps are followed by the module:

  1. Set configuration
  2. Build query

Chart Builder

Use Cases

1. Getting the number of homicides and thefts in Guerrero over a period of time.

Schema
Filters:
    - crime_category => [homicide, theft]
@warborn
warborn / random_hour.py
Created May 8, 2018 17:56
Random Hour Generator
def random_hour(start, end, hour_format="%H:%M"):
start_date = datetime.strptime(
'2018-01-01 {}'.format(start), '%Y-%m-%d %I:%M %p'
)
end_date = datetime.strptime(
'2018-01-01 {}'.format(end), '%Y-%m-%d %I:%M %p'
)
delta = end_date - start_date
int_delta = (delta.days * 24 * 60 * 60) + delta.seconds
@warborn
warborn / wikipedia_webcrawler.py
Created March 7, 2018 22:04
Webcrawler that visits the first link in an article
import time
import urllib
import requests
from bs4 import BeautifulSoup
start_url = "https://en.wikipedia.org/wiki/Special:Random"
target_url = "https://en.wikipedia.org/wiki/Philosophy"
def continue_crawl(search_history, target_url, max_steps = 25):
current_url = search_history[-1]
@warborn
warborn / changes.md
Last active December 20, 2017 22:56
Duckr Updates

Duckr App

Changes to work with the lastest version of React (v15.6) and React Router (v4.1) when building the Duckr application from the Redux course

You can find the my current version of the app here

Optional

  • I used BrowserRouter as router and used BrowserHistory instead of hashHistory, changes needs to be made in the routes.js file