Skip to content

Instantly share code, notes, and snippets.

View rCarto's full-sized avatar
🛠️
...

Timothée Giraud rCarto

🛠️
...
View GitHub Profile
@camriddell
camriddell / collect_univariates.py
Last active March 8, 2024 20:56
A collection of univariate plots
from functools import partial
from textwrap import fill
from scipy.stats import norm, uniform, skewnorm, gaussian_kde, triang
from numpy import (
array, linspace, quantile, histogram, atleast_2d, mean, std, add
)
from numpy.lib.stride_tricks import sliding_window_view
from matplotlib.pyplot import subplots, show, rc
library(tidyverse)
library(sf)
library(sfnetworks)
library(cluster)
library(crsuggest)
library(tidygraph)
library(ggspatial)
# library(gganimate)
crsuggest::suggest_crs(roxel)
net <- roxel %>%
@fzenoni
fzenoni / ortho_view.R
Last active November 2, 2023 11:06
Preserve polygons in orthographic view
# Download earth data first
# https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_land.zip
library(sf)
library(lwgeom)
library(dplyr)
library(ggplot2)
library(mapview)
# Read the data
@etachov
etachov / nyt_style_buildings.R
Created October 14, 2018 16:23
Making NYT-style building maps with data from Microsoft
library(tidyverse)
library(sf)
library(tigris)
# start by picking a state from https://github.com/Microsoft/USBuildingFootprints
# WARNING: these files can be pretty big. using arizona for its copious subdivisions and reasoanable 83MB.
url_footprint <- "https://usbuildingdata.blob.core.windows.net/usbuildings-v1-1/Arizona.zip"
download.file(url_footprint, "Arizona.zip")
unzip("Arizona.zip")
@brodieG
brodieG / cran-check.R
Last active June 18, 2019 21:02
Check CRAN Results
# started with `foghorn`, but that comes with dependencies and
# slows down R startup. `browseURL` just barely slows startup,
# even if actual page is slow to load.
check_cran_old <- function(email) {
utils::browseURL(
sprintf(
"https://cran.r-project.org/web/checks/check_results_%s.html",
gsub("[^A-Za-z0-9_:.-]", "_", sub("@", "_at_", email))
) ) }
@nuest
nuest / sf-hexagon-with-sf.R
Created January 11, 2018 14:17
sf hexagon sticker with sf
library("sf")
library("dplyr")
library("hexbin")
# Linux libertine fint "sf", converted to path with Inkscape,
# added points between existing points 2 times, then turned all segments into straight lines.
# Saved as SVG with absolute coordinates (Preferences > SVG Output > Path Data).
# Loaded coords from SVG source code, remove letters from start and end, and replace " " with ","
coords_f <- c(218.1169,163.46992,215.56952,177.96334,213.51976,189.84421,211.82546,200.33884,210.34442,210.67351,208.24728,226.35176,205.51032,243.54066,201.92029,259.27223,197.26391,270.57846,195.45112,272.90665,193.28288,274.70167,190.97247,275.85687,188.73314,276.26564,187.03291,276.03164,185.79476,275.38887,184.84097,274.42619,183.99382,273.23248,182.45947,271.13533,180.24976,269.10927,177.54243,267.58084,174.51519,266.97658,171.25987,267.58973,169.08867,269.18036,167.87718,271.37526,167.501,273.8012,168.44294,277.0032,171.48203,279.79643,176.93817,281.77214,185.13126,282.52154,191.01986,281.80176,196.83737,279.60686,202.29944,
@nwithan8
nwithan8 / README.md
Last active April 4, 2023 17:58
Make a random song jukebox (using Google AIY Voice Kit)

Earlier this year, I was lucky enough to get my hands on one of the Google AIY Voice Kits for the Raspberry Pi 3. With the kit and some walk-through coding, the kit is a developer example of accessing the Google Assistant and turning a Raspberry Pi into a makeshift Google Home. The project was cool, but I already had a Google Home, so I decided to mess around with the hardware instead.

Eventually, I decided to turn the device into a small, offline jukebox as a gift for my mom, who is a big fan of 80s music. When you hit the button on the top, a random 80s song starts playing. A knob on the side allows for volume adjustment. (Unfortunately, once the song starts playing, it can't easily be stopped. The volume knob can also click in like a button, which I intended to use to stop the music by stopping the music script and immediately restarting it. However, when I was messing with the knob, the button got jammed in, and so I abandoned that idea. Instead, the user can just turn the volume down to zero.)

The hard

@nickoala
nickoala / 0_python_email.md
Last active February 21, 2024 14:20
Use Python to send and receive emails

Use Python to:

  • send a plain text email
  • send an email with attachment
  • receive and filter emails according to some criteria
@rCarto
rCarto / cartomix.R
Last active July 13, 2022 02:19
Script to build the cartomix figure
library(cartography)
library(sp)
library(sf)
# Load data
data(nuts2006)
# Save image
sizes <- getFigDim(x = nuts0.spdf, width = 700, mar = c(0,0,0,0), res = 100)
png('./img/map8.png', width = sizes[1], height = sizes[2], res = 100)
@thigm85
thigm85 / lda_vs_pca.R
Last active March 16, 2021 11:31
Visualize the difference between PCA and LDA on the iris dataset.
require(MASS)
require(ggplot2)
require(scales)
require(gridExtra)
pca <- prcomp(iris[,-5],
center = TRUE,
scale. = TRUE)
prop.pca = pca$sdev^2/sum(pca$sdev^2)