Skip to content

Instantly share code, notes, and snippets.

@racecarparts
racecarparts / django_query_set_as_table.py
Last active July 26, 2024 19:19
Format django queryset as a table in the terminal
def query_set_as_table(queryset):
from decimal import Decimal
data = list(queryset.values())
# Check if data is empty
if not data:
print("No data to display.")
return
# Extract headers
headers = data[0].keys()
# Calculate initial column widths based on data
@racecarparts
racecarparts / fetch_github_org_prs.bash
Last active August 26, 2024 17:43
Script and config to display a list of Github org PRs.
#!/bin/bash
# Load configuration variables from ~/.github_config
CONFIG_FILE="$HOME/.github_org.cfg"
if [[ -f "$CONFIG_FILE" ]]; then
source "$CONFIG_FILE"
else
echo "Configuration file not found: $CONFIG_FILE"
exit 1
@racecarparts
racecarparts / arduino-blinkt.ino
Created October 4, 2023 19:17 — forked from emoryy/arduino-blinkt.ino
Arduino Blinkt!
#include <Adafruit_DotStar.h>
#include <SPI.h>
#define NUMPIXELS 8 // Number of LEDs in strip
// Here's how to control the LEDs from any two pins:
#define DATAPIN 4
#define CLOCKPIN 5
Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BGR);
@racecarparts
racecarparts / SYNC_GITHUB_FORK_INSTALL.txt
Last active May 10, 2022 23:26 — forked from fernandoaleman/INSTALL.txt
Shell script to sync remote branches from upstream and push them up to forked origin
1. Copy 'git-sync-fork' script code from gist
2. Create a file called 'git-sync-fork.sh' in any directory available to you
3. Paste script into this new file 'git-sync-fork.sh' and save
4. Source the file (in your bash profile script) `source /path/to/file/git-sync-fork.sh`
5. Call either function: `gh_sync_[master|develop|development]` (for auto confirmation) or `sync_upstream upstream origin`
Example:
gh_sync_master
gh_sync_develop
@racecarparts
racecarparts / HangoutLinkMaker.gs
Last active May 17, 2016 00:56
How to make Google Hangout links work with regular calendar apps.
function moveHangoutLinks() {
var calendarId = 'YOUR CALENDAR ID';
var now = new Date();
var events = Calendar.Events.list(calendarId, {
timeMin: now.toISOString(),
singleEvents: true,
orderBy: 'startTime',
maxResults: 10
});
if (events.items && events.items.length > 0) {