Skip to content

Instantly share code, notes, and snippets.

View daattali's full-sized avatar

Dean Attali daattali

View GitHub Profile
@chrismccoy
chrismccoy / gitcheats.txt
Last active April 20, 2024 08:50
git cheats
# alias to edit commit messages without using rebase interactive
# example: git reword commithash message
reword = "!f() {\n GIT_SEQUENCE_EDITOR=\"sed -i 1s/^pick/reword/\" GIT_EDITOR=\"printf \\\"%s\\n\\\" \\\"$2\\\" >\" git rebase -i \"$1^\";\n git push -f;\n}; f"
# edit all commit messages
git rebase -i --root
# clone all your repos with gh cli tool
gh repo list --json name -q '.[].name' | xargs -n1 gh repo clone
@withr
withr / server.R
Last active April 3, 2024 19:55
Encrypt password with md5 for Shiny-app.
library(shiny)
library(datasets)
Logged = FALSE;
PASSWORD <- data.frame(Brukernavn = "withr", Passord = "25d55ad283aa400af464c76d713c07ad")
# Define server logic required to summarize and view the selected dataset
shinyServer(function(input, output) {
source("www/Login.R", local = TRUE)
observe({
if (USER$Logged == TRUE) {
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active April 20, 2024 16:52
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@lgatto
lgatto / colour-picker.R
Last active November 7, 2015 13:37
A simple interface to select colours
colour_picker <- function() {
n <- length(colours())
i <- ceiling(sqrt(n))
m <- matrix(c(1:n, rep(NA, i^2 - n)),
ncol = i, nrow = i)
## plotting
image(m, col = colours(),
xaxt = "n", yaxt = "n")
k <- seq(0, 1, length.out = i)
kk <- expand.grid(k, k)
@daattali
daattali / gmailr-text.R
Last active March 30, 2018 00:02
Send a text message via email from R
library(shiny)
library(gmailr)
ui <- fluidPage(
textInput("subj", "Subject", "Schedule change"),
textInput("text", "Message"),
actionButton("btn", "Send")
)
server <- function(input, output, session) {
@jimhester
jimhester / forks_n_commits.R
Created April 21, 2016 18:41
Programmatically determine forks of a repo with at least n commits. Does not try to disambiguate repeated force pushes.
# Q on @GitHub: does anyone now how to easily (ie automatically) list all forks
# of a repository that have more than N commits in the fork?
library(gh) # devtools::install_github("gaborcsardi/gh")
forks_n_commits <- function(owner, repo, n = 1) {
events <- gh("GET /networks/:owner/:repo/events", owner = owner, repo = repo, .limit = Inf)
fork_pushes <- Filter(function(x) x$type == "PushEvent" && x$repo$name != paste0(owner, "/", repo),
events)
#compare with https://gist.github.com/expersso/bb03efcab2a6c125da5ac22e1c33d070
url <- "https://github.com/daattali/addinslist/blob/master/README.md#list-of-addins"
get_html_table <- function(url){
xx <- xml2::read_html(url)
rvest::xml_node(rvest::xml_node(xx,"body"),"table")
}
tr_to_nms <- function(tbl){
@daattali
daattali / rselenium-taxonomer-1-upload.R
Last active June 24, 2019 09:00
Use RSelenium to automatically upload many FASTQ files, submit each to "full analysis" when it's ready, and download the analyzed file on Taxonomer.com
# This script uploads all the FAST files to the taxonomer server (only one file can be uploaded at a time)
# Assumes that you have RSelenium package installed and that you've got a simple selenium example to work
if (FALSE) {
fastq_files <- c(
list.files(# WHERE ARE THE FILES?, pattern = "fastq.gz$", full.names = TRUE)
)
login_password <- "" # what is my password???
library(RSelenium)
@jimhester
jimhester / 0.9.3.png
Last active July 11, 2018 11:18
Run R code with different versions of package dependencies, this will work in the same session as long as you don't run into issues unloading the namespaces
0.9.3.png
@calligross
calligross / app.R
Last active August 23, 2023 17:22
Shiny Cookie Based Authentication Example, please visit https://calligross.de/post/using-cookie-based-authentication-with-shiny/ for more information.
library(shiny)
library(shinyjs)
if (!dir.exists('www/')) {
dir.create('www')
}
download.file(
url = 'https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js',
destfile = 'www/js.cookie.js'