Skip to content

Instantly share code, notes, and snippets.

View czeildi's full-sized avatar
🎲

Ildikó Czeller czeildi

🎲
View GitHub Profile
@czeildi
czeildi / acyclic_graph.cpp
Created January 14, 2021 20:35
acyclic_graph
class node{
public:
int id;
short visited; // 0: not visited, 1: reached but not fully processed, 2: fully processed
int parent;
node(int idx) : id(idx), visited(0) {}
};
bool comp(const node & p, const node & q) {
return (p.exit_time > q.exit_time);
}
@czeildi
czeildi / shiny_is_server.R
Created April 14, 2018 08:18
get whether you are on a shiny server or locally in a shiny app
nzchar(Sys.getenv("SHINY_PORT"))
@czeildi
czeildi / cum_unique_n.sql
Created February 13, 2018 13:05
cumulative unique n in bigquery sql
SELECT
customer_id
, launch_at
, count(is_first_occurence) over (ORDER BY launch_at) preceeding_customer_count
FROM
(
SELECT
customer_id
, launch_at
, (CASE WHEN row_number() over ( PARTITION BY customer_id ORDER BY launch_at) = 1 THEN 1 ELSE NULL END) AS is_first_occurence
@czeildi
czeildi / gzip_data.R
Created December 11, 2017 14:15
gzip all csv files in given folder
gzipData <- function(target_folder = "repo-name/data") {
purrr::walk(
list.files(target_folder, "\\.csv$"),
~ system(glue::glue("gzip {target_folder}/{.x}"))
)
}
@czeildi
czeildi / weekday_labeller.R
Created December 11, 2017 14:14
weekday labeller for ggplot2 axis labels
convertNumToWeekdayName <- function(weekday_num) {
c(
"Sunday",
"Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday"
) %>%
.[weekday_num + 1]
}
@czeildi
czeildi / pre-push
Last active October 27, 2017 16:17
CI suitable test running for R project which is not a package
# do not forget to set the executable bit on .git/hooks/pre-push
Rscript test-runner.R
@czeildi
czeildi / keybase.md
Created October 27, 2017 06:32
keybase.md

Keybase proof

I hereby claim:

  • I am czeildi on github.
  • I am czeildi (https://keybase.io/czeildi) on keybase.
  • I have a public key ASCYxwcV2iEWpdNSGFWAmMdau7FkXpkDsh-UbzGmGmnIQQo

To claim this, I am signing this object:

@czeildi
czeildi / ggplot_theme.R
Created October 2, 2017 15:14
custom ggplot2 theme code for BURN meetup
# setup: example data
library(ggplot2)
library(data.table)
dt <- data.table(
period = c("before", "after", "before", "after"),
segment = c("treatment", "treatment", "control", "control"),
revenue = c(80, 85, 78, 79)
)
@czeildi
czeildi / cs_check.R
Created September 17, 2017 16:16
codeship basic check
check_results <- devtools::check()
print(check_results)
if (length(check_results$errors) + length(check_results$warnings) + length(check_results$notes) >= 1) {
stop('error, warning or note found')
}
@czeildi
czeildi / download_tutorial.md
Last active September 1, 2017 17:42
fájlok letöltése githubról git nélkül

Ha nincs git (verziókövető rendszer) a számítógépeden, de mégis szeretnél fájlokat letölteni egy github repositoryból, a következő lehetőségeid vannak:

A legegyszerűbb talán a kezdőoldalon zip-ként az egész projektet letölteni, majd ezt a gépeden kicsomagolni. Így garantált, hogy megmarad a mappastruktúra, és minden fájl típusa.

Fontos, hogy egy-egy fájl vagy mappa linkjére jobb klikk, mentés esetén nem a fájl, hanem az egész weboldal fog letöltődni, ami tipikusan nem az, amit szeretnénk.

Ha egyesével szeretnél fájlokat letölteni, fájltípustól függően kicsit más felülettel fogsz találkozni, miután rákattintottál a fájl linkjére. Ha nem szöveg alapú fájlról van szó (md, csv, R, js etc) akkor egyszerűbb a dolgod, fogsz látni egy download gombot.