Skip to content

Instantly share code, notes, and snippets.

@layik
layik / cldr-sort.R
Created October 3, 2022 10:34
CLDR Kurdish word lists
w = readLines("https://raw.githubusercontent.com/layik/kurdi/master/corpus/kurdi_words.txt")
length(unique(w)) == length(w)
c = length(w)
c == 1668692
ku_v = readLines("https://raw.githubusercontent.com/layik/kurdi/master/corpus/letters_lines.txt")
message("Kurdish alphabet: ", length(ku_v), " letters.")
letters_used = sapply(ku_v, function(x){
length(grep(x, w))
})
head(letters_used)
library(stats19)
n = c("caNotINac","veNotINac","acNotINca", "acNotINve")
check = function(year = 2019) {
if(is.null(year) || is.na(year)) stop("Year is required")
ac = get_stats19(year = year, type = "ac")
ca = get_stats19(year = year, type = "ca")
ve = get_stats19(year = year, type = "ve")
# all(ca$accident_index %in% ac$accident_index)
# all(ve$accident_index %in% ac$accident_index)
library(httr)
r <- GET("localhost:27017")
if(r$status_code != "200") {
stop("Is Mongo running?")
}
devtools::load_all(".")
library(geocoder)
#!/bin/bash
apt update
# install on Ubuntu
apt-get install postgresql postgresql-contrib -y
# there is now a postgres user in /etc/passwd
# easy way to start it
service postgresql start
packages <- c("rtweet", "stringr", "ggplot2", "tmap",
"dplyr", "textdata", "tm", "tidytext",
"sentimentr", "wordcloud")
if (length(setdiff(packages, rownames(installed.packages()))) > 0) {
install.packages(setdiff(packages, rownames(installed.packages())),repos='http://cran.us.r-project.org')
}
lapply(packages, library, character.only = TRUE)
# ??
@layik
layik / trends-bars.R
Last active October 13, 2019 10:26
Few lines to generate a bar chart for country trends of a particular phrase/term on Google Trends
<!DOCTYPE html>
<!--Thanks to https://github.com/PaulLeCam/react-leaflet/blob/master/example/umd.html-->
<html>
<head>
<meta charset="utf-8" />
<title>Geoplumber front stand alone example</title>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css"
/>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Geoplumber exported React app</title>
</head>
<body>
<!-- We will put our React component inside this div. -->
<div id="geoplumber"></div>