Skip to content

Instantly share code, notes, and snippets.

@mkearney
mkearney / keynote.R
Last active November 16, 2019 17:40 — forked from dkiesow/keynote.R
R script used with rtweet and Keynote rTweet AppleScript to automate tweets from Mac Keynote
#!/usr/bin/env Rscript
##keynote.R v1.0 Damon Kiesow @dkiesow
##Use with the Keynote rTweet AppleScript app to automate threaded tweeting during Keynote presentations
##
## load rtweet package
library(rtweet)
me <- rtweet:::home_user()
## Pull parameters from command line (first_status will be "yes" or "no" and provided from the AppleScript)
args <- commandArgs(trailingOnly = TRUE)
@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)
import random
def non_random_choice(list):
return random.choice(list)
def programar(algo):
tecnicas = ['algoritmos', 'IA', 'um chatbot', 'um framework', ' alguma tecnologia']
print(f'* TODO * Resolver {algo} com {non_random_choice(tecnicas)}')
def usar_ferramenta_para_resolver(algo):
library(tidyverse)
# Distribuição de contribuintes previdenciários
# ref http://dados.gov.br/dataset/estatisticas-contrib-pessoas-fisicas-por-uf/resource/6b498c82-dbd9-42b4-8a7e-d04967c6cff1
# manual das colunas http://www.previdencia.gov.br/dados-abertos/aeps-2007-anuario-estatistico-da-previdencia-social-2007/anuario-estatistico-da-previdencia-social-2007-contribuintes-da-previdencia-social/
d <- read.csv("CTB21.csv", header = T, fileEncoding = "ISO-8859-1", dec = ",")
ufs_abrev <- c("Acre", "Alagoas", "Amazonas", "Amapá", "Bahia", "Ceará", "Distrito Federal", "Espírito Santo", "Goiás", "Maranhão", "Mato Grosso", "Mato Grosso do Sul", "Minas Gerais", "Pará", "Paraíba", "Paraná", "Pernambuco", "Piauí", "Rio de Janeiro", "Rio Grande do Norte", "Rondônia", "Rio Grande do Sul", "Roraima", "Santa Catarina", "Sergipe", "São Paulo", "Tocantins")
ufs_siglas <- c("AC", "AL", "AM", "AP", "BA", "CE", "DF", "ES", "GO", "MA", "MT", "MS", "MG", "PA", "PB", "PR", "PE", "PI", "RJ", "RN", "RO", "RS", "RR", "SC", "SE", "S
#' Conditionally apply expressions on a data object
#'
#' @param .data Input data
#' @param condition A logical value to determine whether to use .if or .else
#' @param .if Formula or function to apply to intput data when condition is TRUE
#' @param .else Formula or function to apply to intput data when condition is FALSE
#' @return Output of appropriate .if/.else call
#' @export
#' @importFrom rlang as_closure
do_if_else <- function(.data, condition, .if, .else = identity) {
library(tidyverse)
library(sf)
library(lubridate)
chicago_neighborhoods <- read_sf("chi_community_shapefiles") %>%
mutate(community_area = as.integer(area_numbe))
chicago_potholes <- read_csv("chicago_potholes.csv") %>%
janitor::clean_names() %>%
mutate_at(vars(creation_date, completion_date), mdy) %>%
mutate(time_to_fill = difftime(completion_date, creation_date))
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
library(tidyverse)
regs_tossups <- read_tsv("tossups.tsv")
regs_games_played <- regs_tossups %>%
filter(!is.na(team), packet != "S", !is.na(buzz_location_pct)) %>%
distinct(team, packet) %>%
count(team)
# Change based on set categories
updatemenus=list([
# drop-down 1: map styles menu
# buttons containes as many dictionaries as many alternative map styles I want to offer
dict(
buttons=list([
dict(
args=['mapbox.style', 'dark'],
label='Dark',
method='relayout'
),
layout = dict(
height = 800,
# top, bottom, left and right margins
margin = dict(t = 0, b = 0, l = 0, r = 0),
font = dict(color = '#FFFFFF', size = 11),
paper_bgcolor = '#000000',
mapbox = dict(
# here you need the token from Mapbox
accesstoken = mapbox_access_token,
bearing = 0,