Skip to content

Instantly share code, notes, and snippets.

View kennedymwavu's full-sized avatar
🍀

Mwavu kennedymwavu

🍀
View GitHub Profile

Install Google Fonts

Download desired fonts

https://fonts.google.com/?selection.family=Open+Sans

Install Google Fonts on Ubuntu

cd /usr/share/fonts
sudo mkdir googlefonts
cd googlefonts
sudo unzip -d . ~/Downloads/Open_Sans.zip

@kennedymwavu
kennedymwavu / work-with-multiple-github-accounts.md
Created February 23, 2024 12:56 — forked from rahularity/work-with-multiple-github-accounts.md
How To Work With Multiple Github Accounts on your PC

How To Work With Multiple Github Accounts on a single Machine

Let suppose I have two github accounts, https://github.com/rahul-office and https://github.com/rahul-personal. Now i want to setup my mac to easily talk to both the github accounts.

NOTE: This logic can be extended to more than two accounts also. :)

The setup can be done in 5 easy steps:

Steps:

  • Step 1 : Create SSH keys for all accounts
  • Step 2 : Add SSH keys to SSH Agent
@kennedymwavu
kennedymwavu / Readme.md
Created January 21, 2024 12:43 — forked from cutiko/Readme.md
Git delete last commit

Removing the last commit

To remove the last commit from git, you can simply run git reset --hard HEAD^ If you are removing multiple commits from the top, you can run git reset --hard HEAD~2 to remove the last two commits. You can increase the number to remove even more commits.

If you want to "uncommit" the commits, but keep the changes around for reworking, remove the "--hard": git reset HEAD^ which will evict the commits from the branch and from the index, but leave the working tree around.

If you want to save the commits on a new branch name, then run git branch newbranchname before doing the git reset.

ORIGINAL did fork but search didn't helped me

@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) |>