Skip to content

Instantly share code, notes, and snippets.

View dereckmezquita's full-sized avatar
🇺🇸

Dereck Mezquita dereckmezquita

🇺🇸
View GitHub Profile
@dereckmezquita
dereckmezquita / golden-fibonacci-spiral-canvas.html
Created December 15, 2024 01:05
Golden spiral (Fibonacci spiral) in JavaScript canvas
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Golden Spiral Demo</title>
<style>
body {
margin: 0;
padding: 0;
@dereckmezquita
dereckmezquita / 99-disk-usage.sh
Last active May 30, 2024 23:27
Messages of the day for Linux
#!/bin/bash
# /etc/update-motd.d/99-disk-usage.sh
# Define colors for pretty output
YELLOW="\e[33m"
RESET="\e[0m"
# Get the disk usage information with header
DISK_USAGE_HEADER=$(df -h --output=source,fstype,size,used,avail,pcent,target | head -n 1)
DISK_USAGE=$(df -h --output=source,fstype,size,used,avail,pcent,target | grep -E '^/dev' | grep -E '/$|/mnt|/media|/data|/nvme0|/nvme1')
@dereckmezquita
dereckmezquita / Dockerfile
Created March 28, 2024 17:49
Pass env vars to docker image on build, can be used to pass vars during github actions for building a prod vs dev image.
FROM ubuntu:20.04
WORKDIR /app
ARG DETECTED_BUILD
ENV BUILD=$DETECTED_BUILD
COPY . .
ENTRYPOINT [ "/bin/bash", "yeet.sh" ]
@dereckmezquita
dereckmezquita / debug-python-pytests.json
Last active August 13, 2024 15:19
How to interactive debug TypeScript in vscode.
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: pytest",
"type": "python",
"request": "launch",
"module": "pytest",
"args": [
"-v",
@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
@dereckmezquita
dereckmezquita / fouc-fix_document.tsx
Last active January 15, 2025 19:54
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 / 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
// ------------------------------------------------
// 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 / 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
@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