Skip to content

Instantly share code, notes, and snippets.

View jjesusfilho's full-sized avatar
🏠
Working from home

José de Jesus Filho jjesusfilho

🏠
Working from home
View GitHub Profile
@FilBot3
FilBot3 / python-zeep-example.md
Last active October 27, 2023 15:17
Python Zeep SOAP Example Write Up

Python Zeep SOAP Client

First, we'll look at the SOAP URL and see what Prefixes, Global Elements, Global Types, Bindings, and Services are provided by the SOAP Service.

You can do this by running zeep as a CLI tool.

export WSDL_URL="http://www.dneonline.com/calculator.asmx?WSDL"
python -m zeep $WSDL_URL
@JakeRuss
JakeRuss / clean-up-pdftools.R
Created December 17, 2018 16:09
table-izing the output from pdftools 2.0
library(pdftools)
library(tidyverse)
library(janitor)
pdf_file <- "https://github.com/ropensci/tabulizer/raw/master/inst/examples/data.pdf"
df <- pdf_data(pdf_file)[[1]]
# Table-ize ----
@acarl005
acarl005 / matmul.sql
Last active January 31, 2023 01:10
Matrix multiplication using a Postgres Table
DROP TABLE IF EXISTS matrices;
CREATE TABLE matrices (
matrix_id int NOT NULL, -- unique identifier for each matrix
i int NOT NULL, -- row number
j int NOT NULL, -- column number
val decimal NOT NULL, -- the value in this cell
PRIMARY KEY (matrix_id, i, j)
);
-- insert sparse representation of
FROM node
RUN mkdir -p /usr/src/app
COPY index.js /usr/src/app
EXPOSE 8080
CMD [ "node", "/usr/src/app/index" ]
@RLesur
RLesur / case_when_factory.R
Last active October 31, 2023 23:48
How to create reusable dplyr::case_when() functions?
# case_when factory: ----------------------------------------------
create_case_when <- function(..., vars = "x") {
fun_fmls <- purrr::map(rlang::set_names(vars), ~ rlang::missing_arg())
fun_body <- substitute({
for (name in var) {
symb <- rlang::eval_bare(rlang::sym(name))
var <- rlang::eval_tidy(rlang::enquo(symb))
assign(name, var)
}
forms <- purrr::map(formulas, rlang::`f_env<-`, value = environment())
@jjesusfilho
jjesusfilho / classifytext.R
Created March 26, 2018 11:31 — forked from primaryobjects/classifytext.R
Simple example of classifying text in R with machine learning (text-mining library, caret, and bayesian generalized linear model). Classify. tfidf tdm term document matrix
library(caret)
library(tm)
# Training data.
data <- c('Cats like to chase mice.', 'Dogs like to eat big bones.')
corpus <- VCorpus(VectorSource(data))
# Create a document term matrix.
tdm <- DocumentTermMatrix(corpus, list(removePunctuation = TRUE, stopwords = TRUE, stemming = TRUE, removeNumbers = TRUE))
@hadley
hadley / shiny-oauth.r
Last active April 26, 2024 05:41
Sketch of shiny + oauth
library(shiny)
library(httr)
# OAuth setup --------------------------------------------------------
# Most OAuth applications require that you redirect to a fixed and known
# set of URLs. Many only allow you to redirect to a single URL: if this
# is the case for, you'll need to create an app for testing with a localhost
# url, and an app for your deployed app.
@Kartones
Kartones / postgres-cheatsheet.md
Last active April 30, 2024 19:47
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@Choens
Choens / RandomFlowerDay.R
Created November 8, 2010 21:19
Creates a vector of random dates. On these dates, you should buy someone flowers.
# ==============================================================================
# RandomFlowerDay.R
# Calculates 12 "random" days/year, to buy flowers for your special someone.
# Output is in mm/dd/yy
#
# Dependencies - Uses awk to pre-process system information. Should work on
# andy POSIX compatible system. Requires r-base only.
#
# Includes a set of tests. I'm still learning how to properly build Unit Tests
# in R. In the meantime, these will do the trick nicely.