Skip to content

Instantly share code, notes, and snippets.

@mathiasfls
mathiasfls / estados-cidades.json
Created November 2, 2018 22:54 — forked from letanure/estados-cidades.json
JSON estados cidades
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
import mysql.connector
from mysql.connector import Error
import tweepy
import json
from dateutil import parser
import time
import os
import subprocess
#importing file which sets env variable
# imports
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error, r2_score
# generate random data-set
np.random.seed(0)
x = np.random.rand(100, 1)
y = 2 + 3 * x + np.random.rand(100, 1)
@mathiasfls
mathiasfls / passive.R
Created August 19, 2019 21:55 — forked from almogsi/passive.R
This code snippet takes a vector of strings and calculates the percentage of passive voice in the input text. It uses Stanford NLP tool and coreNLP for R.
library(rJava)
library(coreNLP)
initCoreNLP()
#in this case, 'test' is a data frame with a col named 'text'
for (i in 1:dim(test)[1]) {
cat(paste0(i / dim(test)[1] * 100, '% completed'))
ann <- annotateString(paste(test$text[i]), format = c("obj"), outputFile = NA, includeXSL = FALSE)
gd <- getDependency(ann)
@mathiasfls
mathiasfls / passive.R
Created August 19, 2019 21:55 — forked from almogsi/passive.R
This code snippet takes a vector of strings and calculates the percentage of passive voice in the input text. It uses Stanford NLP tool and coreNLP for R.
library(rJava)
library(coreNLP)
initCoreNLP()
#in this case, 'test' is a data frame with a col named 'text'
for (i in 1:dim(test)[1]) {
cat(paste0(i / dim(test)[1] * 100, '% completed'))
ann <- annotateString(paste(test$text[i]), format = c("obj"), outputFile = NA, includeXSL = FALSE)
gd <- getDependency(ann)
@mathiasfls
mathiasfls / cheerio.R
Created April 11, 2020 00:59 — forked from jeroen/cheerio.R
V8 cheerio rvest example
# Proof of concept of using V8 to parse HTML in R
# Example taken from rvest readme
# Jeroen Ooms, 2015
library(V8)
stopifnot(packageVersion("V8") >= "0.4")
# Get Document
html <- paste(readLines("http://www.imdb.com/title/tt1490017/"), collapse="\n")
<!DOCTYPE qgis_style>
<qgis_style version="2">
<symbols>
<symbol name="qartoon" force_rhr="0" clip_to_extent="1" alpha="1" type="fill">
<layer class="SimpleFill" enabled="1" locked="0" pass="0">
<prop v="3x:0,0,0,0,0,0" k="border_width_map_unit_scale"/>
<prop v="0,0,0,255" k="color"/>
<prop v="round" k="joinstyle"/>
<prop v="1,1" k="offset"/>
<prop v="3x:0,0,0,0,0,0" k="offset_map_unit_scale"/>
@mathiasfls
mathiasfls / index.js
Created June 20, 2020 13:32 — forked from bcks/index.js
tableau-covid-scraping
const URL = 'https://public.tableau.com/views/PPV_15924847800480/ppv_db?%3Aembed=y&%3AshowVizHome=no&%3Adisplay_count=y&%3Adisplay_static_image=n&%3AbootstrapWhenNotified=true&%3Alanguage=en&:embed=y&:showVizHome=n&:apiID=host0';
const puppeteer = require('puppeteer');
// Below, largely cribbed from Thomas Dondorf at https://stackoverflow.com/questions/52969381/how-can-i-capture-all-network-requests-and-full-response-data-when-loading-a-pag
(async () => {
const browser = await puppeteer.launch();
const [page] = await browser.pages();
@mathiasfls
mathiasfls / webserver.py
Created November 18, 2020 11:50 — forked from jph00/webserver.py
Minimal web server demo in Python (requires fastcore: `pip install fastcore`)
from fastcore.utils import *
host = 8888,'localhost'
sock = start_server(*host)
print(f'Serving on {host}...')
while True:
conn,addr = sock.accept()
with conn:
data = conn.recv(1024)
print(data.decode())
@mathiasfls
mathiasfls / FacebookFromR.r
Created December 8, 2020 15:24 — forked from epijim/FacebookFromR.r
scrape facebook from R. Based off
###############################################################################################
## ##
## Setup ##
## ##
###############################################################################################
# install.packages("Rfacebook") # from CRAN
# install.packages("Rook") # from CRAN
# install.packages("igraph") # from CRAN