Skip to content

Instantly share code, notes, and snippets.

from difflib import SequenceMatcher
def get_similar_records(df, column, input_string, num_records):
# Create an empty list to store the similar records
similar_records = []
# Loop through the records in the column
for record in df[column]:
# Calculate the similarity between the input string and the record
similarity = SequenceMatcher(None, input_string, record).ratio()
@ddbs
ddbs / aestan.md
Last active December 15, 2022 21:38
aestan tray menu

aestan tray menu

could not execute menu item (internal error) [exception] could not perform service action: o servico nao foi iniciado

==> visual c++

aestan tray menu

@ddbs
ddbs / sanitize_text.py
Last active November 16, 2022 23:03
Sanitize text
import re
def sanitize_text(text):
# remove extra white space
text = ' '.join(text.split())
# remove white space at start/end of text
text = text.lstrip()
text = text.rstrip()
@ddbs
ddbs / alternative.py
Last active January 4, 2023 08:25
run bash script from python
import os
cmd = 'wget -O products.csv --user="xxx" --password="xxx" http://online.xxx.com/download_xxx_products.php'
os.system(cmd)
@ddbs
ddbs / python.sh
Created November 12, 2022 23:39
install python from bash file
#!/bin/bash
echo "Installing python3.10"
sudo apt update
sudo apt install software-properities-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.10
python3.10 --version
echo "python3.10 is installed"
echo "---------------------"
echo "---------------------"
@ddbs
ddbs / slice_export.r
Last active September 2, 2021 00:09
Export dataframe/datatable groups to individual excel files
library(data.table)
data <- rio::import("compensation1.xls")
data <- janitor::clean_names(data)
colnames(data)
filename <- tools::file_path_sans_ext(file) #get filename sans extension or path
getwd()
slicer <- c("manager_first_name")
prefix <- c("") #end with _
@ddbs
ddbs / two_reactive_buttons.R
Created May 13, 2020 12:54
shiny two reactive buttons on the same app
## Execute multiple buttons
foo <- function() {
message("one")
Sys.sleep(0.5)
message("two")
}
bar <- function() {
message("alpha")
@ddbs
ddbs / Recipes - Entity Extraction.ipynb
Created May 1, 2019 20:01 — forked from psychemedia/Recipes - Entity Extraction.ipynb
Examples of tagging and fuzzy matchings items in txt docs using python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ddbs
ddbs / update.R
Last active February 17, 2019 21:57
Update R
## Install old packages
## https://stackoverflow.com/questions/25721884/how-should-i-deal-with-package-xxx-is-not-available-for-r-version-x-y-z-wa
## update R in windows
library(installr)
updateR()
## update R in linux
#FIXME
@ddbs
ddbs / metaprogramming.R
Created April 17, 2018 09:47 — forked from wjhopper/metaprogramming.R
Metaprogramming in R
# Create a function programmatically by creating its constituents:
# an argument list, a function body of expressions, and an enclosing environment
args <- alist(x=,y=)
exps <- expression(z <- x^2 + y^2, z <- sqrt(z), return(z))
body <- as.call(c(as.name("{"), exps))
f <- as.function(x = c(args,body), envir = parent.frame())
f(x=1,y=1)