Skip to content

Instantly share code, notes, and snippets.

@lulingar
lulingar / download_google_drive_folder.py
Last active April 13, 2025 15:47 — forked from star0202/download_google_drive_folder.py
Downloads a Google Drive folder recursively, including contained shortcuts to other Drive folders.
from argparse import ArgumentParser
from os import mkdir, remove
from os.path import exists
from pathlib import Path
from urllib.parse import urlparse
from google.auth.transport.requests import Request
from google.auth.external_account_authorized_user import (
Credentials as ExternalAccountCredentials,
)
@lulingar
lulingar / .cargo_config.toml
Created July 21, 2024 19:21
Not-so-simple Hello World of Embassy on ESP32S3
[target.xtensa-esp32s3-none-elf]
runner = "espflash flash --monitor"
[env]
ESP_LOGLEVEL="INFO"
[build]
rustflags = [
"-C", "link-arg=-nostartfiles",
@lulingar
lulingar / Makefile
Last active October 11, 2025 14:24
A re-entrant alternative to GNU Make's $(shell ...) that makes the target fail on errors
# References:
# https://stackoverflow.com/a/48613561/706031 definition of SHELL_CHECKED
# https://stackoverflow.com/a/74742720/706031 usage of $(eval) to mimmick local variables
# This function works almost exactly like the builtin shell command, except it
# stops everything with an error if the shell command given as its argument
# returns non-zero when executed. The other difference is that the output
# is passed through the strip make function (the shell function strips only
# the last trailing newline). In practice this doesn't matter much since
# the output is usually collapsed by the surrounding make context to the
@lulingar
lulingar / README.md
Created April 22, 2022 20:42
Test behavior of $0 in POSIX for sourcing and execution

Motivation

While trying to make a script that provides a set of functions, I saw it convenient to define the following behavior depending on how the script was being invoked, whether by sourcing or by execution:

  • When sourcing: Simply define the functions
  • When executing: Run one of the functions (as a sort of "default") with arguments passed from $@

The way I thought for discriminating among both ways was by leveraging $0. The main constraint was that this should work in a fully POSIX-compliant shell, or as close as possible otherwise.

@lulingar
lulingar / index.html
Created January 5, 2014 14:23
Attempt at creating a multi-series stacked bar chart by mimicking dc.js's seriesChart class
<!DOCTYPE html>
<html lang="en">
<head>
<title>dc.js multi-bar chart attempt</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="http://nickqizhu.github.io/dc.js/css/dc.css"/>
<link rel="stylesheet" type="text/css" href="http://nickqizhu.github.io/dc.js/css/bootstrap.min.css"/>