Skip to content

Instantly share code, notes, and snippets.

@uPaymeiFixit
uPaymeiFixit / fake-lscpu.sh
Last active December 19, 2023 21:18
Fake lscpu output
#!/usr/bin/env bash
set -e
# Usage: Run this command from anywhere. It will back up the original lscpu
# command, and replace it with a new command that outputs hard-coded CPU
# information.
program="lscpu"
program_path="$(which "$program")"
program_backup_path="$program_path.bak"
@uPaymeiFixit
uPaymeiFixit / replace-and-log.sh
Last active December 19, 2023 21:18
Replace dd with a command that logs when dd was run and with which parameters
#!/usr/bin/env bash
set -e
# This script backs up the specified program in the current path, and creates a
# new one in its place. (this will only be done if the backup does not already
# exist) The new (fake) specified program will forward all arguments to the
# backed up dd command and log the output of the backed up dd command. It will
# also log when the dd command was run and with which arguments to
# /var/log/{SPECIFIED_PROGRAM}-calls.log
#
@uPaymeiFixit
uPaymeiFixit / google-spreadsheet-example.mjs
Created April 12, 2023 00:10
Basic example / boilerplate for connecting to a Google Spreadsheet using the google-spreadsheet NPM module
import { GoogleSpreadsheet } from "google-spreadsheet";
import * as dotenv from "dotenv";
dotenv.config();
// Follow these instructions to download the json: https://theoephraim.github.io/node-google-spreadsheet/#/getting-started/authentication?id=service-account
import serviceAccountCredentials from "./paciolan-test-transactions-cac2ff699254.json" assert { type: "json" };
// Set up and connect to spreadsheet
const doc = new GoogleSpreadsheet(process.env.SPREADSHEET_ID);
await doc.useServiceAccountAuth(serviceAccountCredentials);
@uPaymeiFixit
uPaymeiFixit / wsl2-setup-guide.sh
Last active January 30, 2023 14:48
WSL2 Setup Guide (Squid, SSH, and Fish)
################################################
# Guide to configure WSL2 Squid, SSH, and Fish #
################################################
### Run all of this inside an Ubuntu WSL instance (must enable WSL2 and install Ubuntu WSL first)
# Allow us to start ssh and squid without a password
# echo "%sudo ALL=(ALL) NOPASSWD: /etc/init.d/ssh" | sudo tee -a /etc/sudoers.d/password-inits.conf
# echo "%sudo ALL=(ALL) NOPASSWD: /etc/init.d/squid" | sudo tee -a /etc/sudoers.d/password-inits.conf
echo "$(whoami) ALL = (ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/passwordless-sudo

Keybase proof

I hereby claim:

  • I am upaymeifixit on github.
  • I am upaymeifixit (https://keybase.io/upaymeifixit) on keybase.
  • I have a public key ASCL88ABTDCru4ljMXfgoPRSCw_JQTFvYyscKt69zCjiGQo

To claim this, I am signing this object:

@uPaymeiFixit
uPaymeiFixit / timelapse_pip.js
Last active March 26, 2018 17:47
Timelapse with PIP and timestamp overlay
const Jimp = require("jimp");
const async = require("async");
const leftPad = require('left-pad');
const fs = require('fs');
const promisify = require('util').promisify;
const moment = require('moment');
const readdir = promisify(fs.readdir);
const stat = promisify(fs.stat);
@uPaymeiFixit
uPaymeiFixit / ICA15_2.java
Last active March 8, 2017 16:22
ICA Ch. 15-2
/**
* @author: Joshua Gibbs
* @title: ICA Ch. 15-2
* @date: 3/8/2017
* @file: ICA15_2.java
* @class: CS 141 – Programming and Problem Solving
* @purpose:
* Given a string, return recursively a "cleaned" string.
* You cleaned string will have adjacent chars that are the same have been reduced to a single char.
* So "yyzzza" yields "yza".
@uPaymeiFixit
uPaymeiFixit / ICA15_1b.java
Created March 6, 2017 16:23
ICA Ch. 15-1b
/**
* @author: Joshua Gibbs
* @title: ICA Ch. 15-1b
* @date: 3/6/2017
* @file: ICA15_1b.java
* @class: CS 141 – Programming and Problem Solving
* @purpose:
* Given a string, compute recursively (no loops) a new string.
* The new string will replace all appearances of "pi" with "3.14".
* (You must use a method which calls itself for a recursive solution)
@uPaymeiFixit
uPaymeiFixit / ICA15_1a.java
Created March 3, 2017 16:34
ICA Ch. 15-1a
/**
* @author: Joshua Gibbs
* @title: ICA Ch. 11-2b
* @date: 3/3/2017
* @file: ICA15_1a.java
* @class: CS 141 – Programming and Problem Solving
* @purpose:
* Given a non-negative int n, compute recursively (no loops) the count of the
* occurrences of 8 as a digit. (Except that an 8 with another 8 immediately to
* its left counts double, so 8818 yields 4.) Note that mod (%) by 10 yields the
@uPaymeiFixit
uPaymeiFixit / ICA11_2b.java
Created March 1, 2017 16:23
ICA Ch. 11-2b
/**
* @author: Joshua Gibbs
* @title: ICA Ch. 11-2b
* @date: 3/1/2017
* @file: ICA11_2b.java
* @class: CS 141 – Programming and Problem Solving
* @purpose:
* The file "datafile" provided to you on Blackboard begins with a single long.
* The long tells you the offset to reach a single int piece of data from within the same file.
* Using the RandomAccessFile class, write a program that retrieves the int piece of data.