Skip to content

Instantly share code, notes, and snippets.

View copley's full-sized avatar

Max Copley. SWEN Graduate from VUW (Wellington, NZ) copley

View GitHub Profile
@copley
copley / gist:59474acbd60e08657e3a7655e6079255
Created September 26, 2024 07:21
find ~ -maxdepth 3 -type f -name "*.py" -print0 | xargs -0 ls -lt | head -n 10
find ~ -maxdepth 3 -type f -name "*.py" -print0 | xargs -0 ls -lt | head -n 10
@copley
copley / Treasury of Thought
Created September 13, 2024 06:01
Treasury of Thought
This file has been truncated, but you can view the full file.
TREASURY OF THOUGHT.
An Encyclopedia of Quotations
FROM
ANCIENT AND MODERN AUTHORS.
BY
MATURIN M. BALLOU.
@copley
copley / command
Created September 12, 2024 06:49
command
source ~/myenv/bin/activate
@copley
copley / password_time_capsule.py
Created September 7, 2024 09:08
Password Time Capsule python3 app
import time
from datetime import datetime, timedelta
from tinydb import TinyDB, Query
from cryptography.fernet import Fernet
import base64
import os
# Generate a key for encryption
def generate_key():
return base64.urlsafe_b64encode(os.urandom(32))
@copley
copley / etc.hosts2
Created August 25, 2024 11:27
etc/hosts2
To allow all privileges for Account B on your macOS laptop while preventing Account B from modifying the /etc/hosts file, you need to modify the file permissions specifically for the /etc/hosts file. This way, Account B will have administrative privileges on the system, except for modifying this specific file.
Here's how you can do this:
Step-by-Step Guide
Log in as Admin Account A: Make sure you are logged in as Admin Account A, which will be the primary administrator.
Change Ownership of the /etc/hosts File: You need to change the ownership and permissions of the /etc/hosts file so that only Admin Account A (and not Admin Account B) can modify it. Open Terminal and run the following commands:
bash
@copley
copley / etc.hosts
Created August 25, 2024 11:23
/etc/hosts
If changes to the /etc/hosts file on your macOS are not working as expected, here are some common troubleshooting steps to help resolve the issue:
1. Check File Format and Syntax
Make sure there are no syntax errors in the /etc/hosts file.
Each entry should be on a new line with the IP address followed by one or more hostnames, separated by spaces or tabs. For example:
Copy code
127.0.0.1 localhost
192.168.1.1 example.com
Avoid using special characters and ensure there is no trailing whitespace after the entries.
2. Flush DNS Cache
@copley
copley / gist:43f4440e02061181ad5ab6dbf4eb59eb
Created August 25, 2024 09:46
password protect etc hosts file
https://apple.stackexchange.com/questions/282339/protect-hosts-file
@copley
copley / Locked Host File
Created December 3, 2023 20:47
Locked Host File
For reasons only you know, you have locked the hosts file, as well as adding an inappropriate ACL to the etc directory. I'll limit myself to fixing the hosts file. Enter the following command in the same way as before -- NO TYPING:
sudo chflags nouchg /etc/hosts
You'll be prompted for your password, which won't be displayed when you type it. Type nothing in the window except your password. Then quit Terminal.
@copley
copley / Java Snippets
Created May 23, 2020 02:57
Java Snippets
package snippets;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
@copley
copley / SQL vs MySQL: What's the Difference?
Created May 15, 2020 05:25
SQL vs MySQL: What's the Difference?
What is SQL?
SQL is a language which is used to operate your database. SQL is the basic language used for all the databases. There are minor syntax changes amongst different databases, but the basic SQL syntax remains largely the same. SQL is a short abbreviation of Structured Query Language. According to ANSI (American National Standards Institute), SQL is the standard language to operate a relational database management system.
SQL is used in the accessing, updating, and manipulation of data in a database. Its design allows for the management of data in an RDBMS, such as MYSQL. SQL language also used for controlling data access and for creation and modification of Database schemas.
What is MYSQL?
Developed in the mid-90s., MySQL was one of the first open-source database available in the market. Today there are many alternatives variants of MySQL,. However, the differences between the variants are not significant as they use the same syntax, and basic functionality also remains same.