Skip to content

Instantly share code, notes, and snippets.

@barbietunnie
barbietunnie / cleanup_xcode.sh
Created August 1, 2025 10:41
Xcode Cleanup Script
#!/bin/bash
echo "=== Xcode Cleanup Script ==="
# 1. Clean old iOS DeviceSupport (keep latest 2)
echo "Cleaning old iOS DeviceSupport files..."
DEVICE_SUPPORT_DIR="$HOME/Library/Developer/Xcode/iOS DeviceSupport"
if [ -d "$DEVICE_SUPPORT_DIR" ]; then
cd "$DEVICE_SUPPORT_DIR" || exit
echo "Keeping latest 2 versions..."
@barbietunnie
barbietunnie / run-mongodb-on-apple-silicon-locally.md
Created December 31, 2024 18:39
Running MongoDB locally on Apple Silicion

Running MongoDB locally on Apple Silicion

Manually running as a background process

If your deployment does not use TLS connections

mongod --config /opt/homebrew/etc/mongod.conf --fork

# You can optionally specify the db path
@barbietunnie
barbietunnie / install-postures-16-ubuntu.md
Created December 15, 2024 12:49
How to Install Postgres 16 on Ubuntu

How to Install Postgres 16 on Ubuntu

To install PostgreSQL 16 on Ubuntu, follow these steps:

Step 1: Update the System

Before installing PostgreSQL, ensure that your system is up-to-date.

sudo apt update
@barbietunnie
barbietunnie / remote-file-size.md
Created December 15, 2024 11:26
Get human-friendly file size of a remote file

Get human-friendly file size of a remote file

To determine the size of a file at a remote URL without downloading it, you can use an HTTP HEAD request. This type of request retrieves only the HTTP headers, which often include the Content-Length header that indicates the file size in bytes.

curl -sI https://datasets-documentation.s3.eu-west-3.amazonaws.com/uk-house-prices/postgres/uk_prices.sql.tar.gz | awk '/Content-Length/ { 
    size=$2; 
 split("B KB MB GB TB", unit); 
@barbietunnie
barbietunnie / read-parquet-with-duckdb.md
Created November 15, 2024 12:39
How to read Parquet files with DuckDB

How to read Parquet files with DuckDB

  • Create a new DuckDB in-memory connection using DBeaver, specifying the path as :memory:

  • Create a new script to run your query with, using the connection created

    SELECT * FROM parquet_schema('/path/to/parquet/file.parquet');
    
    SELECT * FROM read_parquet('/path/to/parquet/file.parquet');
    
@barbietunnie
barbietunnie / apt_pkg_error_fix.md
Created September 1, 2024 19:23
Unable to install or update any libraries ModuleNotFoundError: No module named 'apt_pkg'

How to resolve the error "Unable to install or update any libraries ModuleNotFoundError: No module named 'apt_pkg'" on Ubuntu

The issue can be resolved by uninstalling and installing the python3-apt package

sudo apt remove python3-apt

sudo apt install python3-apt
@barbietunnie
barbietunnie / install-mysqlclient-ubuntu-22.md
Created July 17, 2024 11:56
Install `mysqlclient` with pip on Ubuntu 22

Install mysqlclient with pip on Ubuntu 22

Without installing pkg-config before attempting to install mysqlclient on Ubuntu 22 fails and subsequently breaks apt-pkg.

To install it without issues, run the following commands:

sudo apt install pkg-config
pip install mysqlclient
@barbietunnie
barbietunnie / redshift-notes.md
Last active September 23, 2024 10:41
Redshift Notes

Redshift Notes

1. Find dependent objects for a table or view in Postgresql or Redshift

SELECT dependent_ns.nspname as dependent_schema
, dependent_view.relname as dependent_view 
, source_ns.nspname as source_schema
, source_table.relname as source_table
, pg_attribute.attname as column_name
@barbietunnie
barbietunnie / postgres-privileges.md
Last active March 21, 2024 14:50
Granting privileges in Postgres

Granting privileges in Postgres

Steps

Below are some common ways to grant access to a PostgreSQL user:

  1. Grant CONNECT to the database:
GRANT CONNECT ON DATABASE database_name TO username;

Grouping results and removing unwanted ones

Here we want to scrape product name, price and rating from ebay product pages:

url = 'https://www.ebay.com/itm/Sony-PlayStation-4-PS4-Pro-1TB-4K-Console-Black/203084236670' 

wanted_list = ['Sony PlayStation 4 PS4 Pro 1TB 4K Console - Black', 'US $349.99', '4.8'] 

scraper.build(url, wanted_list)