Skip to content

Instantly share code, notes, and snippets.

View dereckmezquita's full-sized avatar
🇺🇸

Dereck Mezquita dereckmezquita

🇺🇸
View GitHub Profile
@dereckmezquita
dereckmezquita / pi.cpp
Last active November 13, 2021 23:32
Different methods in C++/Rcpp code for calculating the constant Pi: Gregory Leibniz, Nilakantha, and Monte Carlo. Plotting is done in R.
#include <Rcpp.h>
#include <iostream>
#include <random>
#include <chrono>
#include <math.h>
using namespace Rcpp;
// [[Rcpp::export]]
long double gregoryLeibnizCpp(int iterations) {
long double pi = 1;
@dereckmezquita
dereckmezquita / random-sampling-numbers.cpp
Created November 6, 2021 21:49
Code for randomly selecting random numbers between an integer and tallying up results. Reference for generating random numbers. R used for visualisation.
#include <Rcpp.h>
#include <iostream>
#include <random>
#include <chrono>
using namespace Rcpp;
std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// [[Rcpp::export]]
@dereckmezquita
dereckmezquita / gource.sh
Created November 7, 2021 03:21
Some bash code on running the gource utility for visualising GitHub repo contributions.
cd /Users/Dereck/Desktop/digibyte
gource \
-s .06 \
-1280x720 \
--auto-skip-seconds .1 \
--multi-sampling \
--stop-at-end \
--key \
--highlight-users \
--hide mouse,progress \
@dereckmezquita
dereckmezquita / vscode-settings.json
Last active November 7, 2021 07:16
Settings from VScode.
{
"security.workspace.trust.untrustedFiles": "open",
"editor.wordWrap": "on",
"files.exclude": {
"**/.git": false
},
"explorer.compactFolders": false,
"window.zoomLevel": 0.5,
"files.associations": {
"*.Rmd": "r"
@dereckmezquita
dereckmezquita / Makevars
Last active April 8, 2023 17:52
Makevars and instructions for installing installing data.table on an M1 Mac; note config also works for installing slam/syuzhet.
# if you downloaded llvm manually above, replace with your chosen NEW_PATH/clang
LLVM_LOC = /opt/homebrew/opt/llvm
CC=$(LLVM_LOC)/bin/clang -fopenmp
CXX=$(LLVM_LOC)/bin/clang++ -fopenmp
# -O3 should be faster than -O2 (default) level optimisation ..
CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
LDFLAGS=-L/opt/homebrew/opt/gettext/lib -L$(LLVM_LOC)/lib -Wl,-rpath,$(LLVM_LOC)/lib
CPPFLAGS=-I/opt/homebrew/opt/gettext/include -I$(LLVM_LOC)/include
@dereckmezquita
dereckmezquita / platformMap.txt
Created April 18, 2022 23:24 — forked from seandavi/platformMap.txt
Bioconductor/GEO platform mapping
"title" "gpl" "bioc_package" "manufacturer" "organism" "data_row_count"
"Illumina Sentrix Array Matrix (SAM) - GoldenGate Methylation Cancer Panel I" "GPL15380" "GGHumanMethCancerPanelv1" "Illumina" "Homo sapiens" 1536
"Illumina HumanMethylation27 BeadChip (HumanMethylation27_270596_v.1.2)" "GPL8490" "IlluminaHumanMethylation27k" "Illumina, Inc." "Homo sapiens" 27578
"Illumina HumanMethylation450 BeadChip (HumanMethylation450_15017482)" "GPL13534" "IlluminaHumanMethylation450k" "Illumina, Inc." "Homo sapiens" 485577
"GE Healthcare/Amersham Biosciences CodeLink™ ADME Rat 16-Assay Bioarray" "GPL2898" "adme16cod" "GE Healthcare" "Rattus norvegicus" 1280
"[AG] Affymetrix Arabidopsis Genome Array" "GPL71" "ag" "Affymetrix" "Arabidopsis thaliana" 8297
"[ATH1-121501] Affymetrix Arabidopsis ATH1 Genome Array" "GPL198" "ath1121501" "Affymetrix" "Arabidopsis thaliana" 22810
"[Bovine] Affymetrix Bovine Genome Array" "GPL2112" "bovine" "Affymetrix" "Bos taurus" 24128
"[Canine] Affymetrix Canine Genome 1.0 Array" "GPL39
// ------------------------------------------------
// Update elements of an object (key - value) by index number not name
const obj = {
student1: {
country: 'Chile',
name: 'Tom'
},
student2: {
country: 'Argentina',
name: 'Julia'
@dereckmezquita
dereckmezquita / check-build-install-R-package.sh
Created November 25, 2022 15:35
Replaces RStudio's buttons for building and installing an R package during development.
#!/usr/bin/env bash
# if $1 does not match either check or install
if [[ $1 != "check" ]] && [[ $1 != "install" ]] && [[ $1 != "check-install" ]]; then
echo "Usage: package-management.sh [check|install|check-install]"
fi
if [[ $1 == "check" ]]; then
Rscript -e "devtools::check()"
fi
@dereckmezquita
dereckmezquita / fouc-fix_document.tsx
Last active October 17, 2023 15:00
Fix FOUC in Nextjs/React using only styled-components; pre-render and inject css.
import Document from "next/document";
import { ServerStyleSheet } from "styled-components";
import { DocumentContext } from "next/document"; // Importing DocumentContext for TypeScript
export default class MyDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
const sheet = new ServerStyleSheet();
const originalRenderPage = ctx.renderPage;
try {
@dereckmezquita
dereckmezquita / build-install-R-package.sh
Created November 26, 2023 14:23
Build and install R package shell script.
#!/usr/bin/env bash
# if $1 does not match either check or install
if [[ $1 != "check" ]] && [[ $1 != "install" ]] && [[ $1 != "check-install" ]]; then
echo "Usage: package-management.sh [check|install|check-install]"
fi
if [[ $1 == "check" ]]; then
Rscript -e "devtools::check()"
fi