Skip to content

Instantly share code, notes, and snippets.

View padpadpadpad's full-sized avatar
🙃

Daniel Padfield padpadpadpad

🙃
View GitHub Profile
ks.default <- function(rows) seq(2, max(3, rows %/% 4))
many_kmeans <- function(x, ks = ks.default(nrow(x)), ...) {
ldply(seq_along(ks), function(i) {
cl <- kmeans(x, centers = ks[i], ...)
data.frame(obs = seq_len(nrow(x)), i = i, k = ks[i], cluster = cl$cluster)
})
}
all_hclust <- function(x, ks = ks.default(nrow(x)), point.dist = "euclidean", cluster.dist = "ward") {
@mbostock
mbostock / .block
Last active July 30, 2024 03:51
The Gist to Clone All Gists
license: gpl-3.0
@wch
wch / lmgadget.R
Created January 20, 2016 18:17
Shiny Gadget example: lmGadget
library(shiny)
# Example usage:
# lmGadget(mtcars, "wt", "mpg")
#
# Returns a list with two items:
# $data: Data with excluded rows removed.
# $model: lm (model) object.
lmGadget <- function(data, xvar, yvar) {
library(miniUI)
@ramhiser
ramhiser / brms-nonlinear.r
Last active February 26, 2023 18:14
Adding fixed effects and random effects to a nonlinear Stan model via brms
# The data set and model are described in the *brms* vignette
library(brms)
url <- paste0("https://raw.githubusercontent.com/mages/diesunddas/master/Data/ClarkTriangle.csv")
loss <- read.csv(url)
set.seed(42)
# Generated a random continuous feature
loss$ramey <- runif(nrow(loss))
@mndrake
mndrake / shiny_leaflet_brushing.R
Created March 29, 2017 00:39
Interactive Polygon Brushing with Shiny and Leaflet
# originally from: http://stackoverflow.com/questions/42528400/plot-brushing-or-accessing-drawn-shape-geometry-for-spatial-subsets-in-shiny-lea
# uses https://github.com/bhaskarvk/leaflet.extras
library(shiny)
library(leaflet)
library(leaflet.extras)
library(sp)
cities <- structure(list(AccentCity = c("Saint Petersburg", "Harare", "Qingdao",
"Addis Abeba", "Xian", "Anshan", "Rongcheng", "Kinshasa", "New York",
@tinkertim
tinkertim / simple-egg-pasta.md
Last active December 30, 2023 10:13
Simple yet semi-foolproof egg pasta dough

Description

This is a simple egg pasta recipe that I've been refining over the years of making fresh pasta for my family. It's based on a recipe I picked up while I was a line cook at a family Italian place about 20 years ago that has long since gone out of business; I've put it back together and adjusted it so it scales down as easily as it does up. Originally, this was made in 10kg (20+ pound) batches.

This dough isn't suitable for extruders, it is intended for rolling and cutting. That means you can make pretty much any kind of noodle, or lasagna sheet out of it. If you want to make ravioli or other stuffed pasta, you want to use a recipe with quite a bit more egg in it, and more steps for drying. If you want to make shaped pasta, such as shells, you probably want a durum wheat & water (eggless) dough recipe instead.

Yield

@aymericbeaumet
aymericbeaumet / delete-likes-from-twitter.md
Last active November 18, 2024 15:06
[Recipe] Delete all your likes/favorites from Twitter

Ever wanted to delete all your likes/favorites from Twitter but only found broken/expensive tools? You are in the right place.

  1. Go to: https://twitter.com/{username}/likes
  2. Open the console and run the following JavaScript code:
setInterval(() => {
  for (const d of document.querySelectorAll('div[data-testid="unlike"]')) {
    d.click()
 }