Skip to content

Instantly share code, notes, and snippets.

View danielwangksu's full-sized avatar

Daniel Wang danielwangksu

  • San Francisco Bay Area, CA
View GitHub Profile
@natelandau
natelandau / .bash_profile
Last active June 23, 2025 21:53
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
Wow. I've now read the whole book and much of the supporting code. I'm not a fan, and recommend against relying on it. Here's a laundry list of concerns:
* The teaching method the book uses is badly flawed. The book's strategy is to start simple and build to complexity, which makes sense if you're teaching algebra but not if you're teaching heart surgery. The result is that each chapter culminates with the implementation of a system that is grievously insecure. Little warning is given of this, apart from allusions to future chapters improving the system. For instance, Chapter 2 closes with a chat system that uses AES-CBC without an authenticator.
* The book is full of idiosyncratic recommendations. For instance, AES-CBC requires a padding scheme. There is a standard padding scheme. The book purports to present it, but instead of PKCS7, it presents 80h+00h..00h.
* At one point about 1/3rd of the way through the book, it suggests using a SHA256 hash of the plaintext as an authenticator for a message. This r
@preshing
preshing / build_cross_gcc
Last active May 29, 2025 18:21
A shell script to download packages for, configure, build and install a GCC cross-compiler.
#! /bin/bash
set -e
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG
trap 'echo FAILED COMMAND: $previous_command' EXIT
#-------------------------------------------------------------------------------------------
# This script will download packages for, configure, build and install a GCC cross-compiler.
# Customize the variables (INSTALL_PATH, TARGET, etc.) to your liking before running.
# If you get an error and need to resume the script from some point in the middle,
# just delete/comment the preceding lines before running it again.
@gene1wood
gene1wood / batch-delete-gmail-emails.js
Last active June 10, 2025 16:22
A Google Apps Script script to bulk delete large amounts of email in Gmail while avoiding the error #793 which Gmail encounters normally
/*
This script, when used with Google Apps Scripts, will delete 400 emails and
can be triggered to run every few minutes without user interaction enabling you
to bulk delete email in Gmail without getting the #793 error from Gmail.
Google returns a maximum of 500 email threads in a single API call.
This script fetches 400 threads in case 500 threads is causing timeouts
Configure the search query in the code below to match the type of emails
you want to delete
@denji
denji / golang-tls.md
Last active June 28, 2025 04:34 — forked from spikebike/client.go
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@gubatron
gubatron / compiling_building_c_cpp_notes.md
Last active May 23, 2025 19:16
Things to remember when compiling and linking C/C++ programs

Things to remember when compiling/linking C/C++ software

by Angel Leon. March 17, 2015;

Last update on December 14, 2023

Updated on February 27, 2023

Updated August 29, 2019.

@pfigue
pfigue / clock_gettime.c
Created April 23, 2015 07:54
Example of using libC clock_gettime() and clock_getres() functions.
#include <stdio.h>
#include <time.h>
int main(int argc, char **argv)
{
int result;
struct timespec tp;
clockid_t clk_id;
@zzl0
zzl0 / coders.txt
Last active August 8, 2018 20:45
Name Description
Peter Norvig Director of Research at Google and author of the standard text on AI.
Alan Kay Inventor of Smalltalk. Coined the term "object-oriented programming".
Guy Steele Co-inventor of Scheme and part of the Common Lisp Gang of Five. Currently working on Fortress.
Donald Knuth Author of The Art of Computer Programming and TeX
Gerald Jay Sussman Co-creator of Scheme and co-author of The Structure And Interpretation of Computer Programs.
John McCarthy Invented Lisp
John Carmack Founder of id Software; lead programmer of Doom, Quake, and others.
Dennis Ritchie Invented C and contributed to development of UNIX
Joe Armstrong Inventor of Erlang
@somdoron
somdoron / example.c
Last active May 31, 2017 16:29
polling on multiple sockets
void* ctx = zmq_ctx_new();
void* client = zmq_socket(ctx, ZMQ_CLIENT);
// creating new pollfd, pollfd is per thread.
void* pollfd = zmq_pollfd_new();
// associate pollfd with client, you can associate multiple pollfd with one socket for multi threading
zmq_add_pollfd(client, pollfd);
zmq_pollitem_t items[] {
@socantre
socantre / CMakeLists.txt
Last active May 6, 2025 17:34
Example of using add_custom_command and add_custom_target together in CMake to handle custom build steps with minimal rebuilding: This example untars library headers for an INTERFACE library target
set(LIBFOO_TAR_HEADERS
"${CMAKE_CURRENT_BINARY_DIR}/include/foo/foo.h"
"${CMAKE_CURRENT_BINARY_DIR}/include/foo/foo_utils.h"
)
add_custom_command(OUTPUT ${LIBFOO_TAR_HEADERS}
COMMAND ${CMAKE_COMMAND} -E tar xzf "${CMAKE_CURRENT_SOURCE_DIR}/libfoo/foo.tar"
COMMAND ${CMAKE_COMMAND} -E touch ${LIBFOO_TAR_HEADERS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include/foo"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/libfoo/foo.tar"