Skip to content

Instantly share code, notes, and snippets.

View kennedymwavu's full-sized avatar
🍀

Mwavu kennedymwavu

🍀
View GitHub Profile
@kennedymwavu
kennedymwavu / diamond-pattern.R
Created November 16, 2023 10:02
Create a diamond pattern
n <- 10
num_of_stars_per_row_upper_sequence <- seq(from = 1, by = 2, length.out = n)
row_length <- num_of_stars_per_row_upper_sequence[n]
num_of_stars_per_row_lower_sequence <- rev(num_of_stars_per_row_upper_sequence)[-1]
upper_and_lower_sequence <- c(num_of_stars_per_row_upper_sequence, num_of_stars_per_row_lower_sequence)
for (i in upper_and_lower_sequence) {
num_of_spaces <- (row_length - i) / 2
spaces <- rep(" ", times = num_of_spaces)
stars <- rep("*", times = i)
cat(spaces, stars, "\n", sep = "")
@kennedymwavu
kennedymwavu / ghpwithnamecheap.md
Created April 24, 2023 20:38 — forked from plembo/ghpwithnamecheap.md
GitHub Pages with Namecheap custom domain

Using GitHub Pages with a custom domain: Namecheap Edition

As often happens, I found the official documentation and forum answers to be "close, but no cigar", and so had to experiment a little to get things working.

The main problem for me was a lack of concrete configuration examples. That's not entirely GitHub's fault: having migrated from Google Domains to Namecheap in the middle of this project, I was once again reminded of how many different ways there are to do things in the name service universe [1].

Although you'd think the simplest setup would be to merely configure for the subdomain case (https://www.example.com), in my experience using the apex domain (https://example.com) instead resulted in fewer complications.

Procedure

So here's my recipe for using a custom domain with GitHub pages where Namecheap is the DNS provider:

@kennedymwavu
kennedymwavu / .Rprofile
Last active June 18, 2023 23:00
Customize R's startup msg on Rstudio
setHook("rstudio.sessionInit", function(newSession) {
cat('\f')
hour <- format(Sys.time(), format = '%H') |> as.numeric() |> as.character()
morning <- 0:11
afternoon <- 12:16
evening <- c(17:23)
day_hrs <- rep(
@kennedymwavu
kennedymwavu / rhandsontable.R
Last active July 4, 2022 16:54
Warning: Error in genColHeaders: Change no recognized:afterChange
# How to capture data from rhandsontable after column addition/deletion, since
# rhandsontable::hot_to_r() wouldn't work
# {rhandsontable} version ‘0.3.9’
# R version 4.2.0 (2022-04-22)
library(shiny)
library(rhandsontable)
library(data.table)
library(shinyjs)
@kennedymwavu
kennedymwavu / install.R
Created June 22, 2022 11:56
Selectively install packages. If it's already installed don't reinstall.
# Just copy paste your "library" statements here using {datapasta}:
packages <- c(
"library(shiny)", "library(bs4Dash)", "library(shinyjs)",
"library(shinyWidgets)", "library(firebase)", "library(glue)",
"library(DBI)", "library(RPostgres)", "library(lubridate)",
"library(htmlwidgets)", "library(shinybusy)"
)
# rm "library()" leaving bare pkg chars:
pkg_nms <- gsub(pattern = "library\\(", replacement = "", x = packages) |>