Skip to content

Instantly share code, notes, and snippets.

View dereckmezquita's full-sized avatar
🇺🇸

Dereck Mezquita dereckmezquita

🇺🇸
View GitHub Profile
@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 / yt-dlp-with-state.sh
Created March 30, 2024 23:24
Download videos in mp4 with yt-dlp and track state from links.txt
#!/usr/bin/env bash
# Input file containing links
inputFile="$1"
# Output state file
stateFile="state.csv"
# Function to handle script interruption
cleanup_and_exit() {
@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 / scrape-vk-album.ts
Last active February 1, 2024 22:49
Scripts for scraping photos and videos from VK with error tracking.
import puppeteer from 'puppeteer';
import fs from 'fs';
import path from 'path';
/*
// scroll and scrape links manually from album page
const rows = document.querySelectorAll('.photos_row[aria-label="Photo"] a');
const hrefs = Array.from(rows).map(row => row.href);
hrefs.forEach((e) => {
@dereckmezquita
dereckmezquita / debug-typescript-launch.json
Created December 2, 2023 14:23
How to interactive debug TypeScript in vscode.
// https://yewtu.be/watch?v=f3i9b3uK00U
// npm install --save-dev ts-node tsconfig-paths
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug TypeScript",
"skipFiles": [
@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 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 / 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