Skip to content

Instantly share code, notes, and snippets.

@wojteklu
wojteklu / clean_code.md
Last active May 14, 2024 11:49
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@nh2
nh2 / tcp-nodelay.md
Last active May 14, 2024 11:42
Understanding TCP_NODELAY

I believe the following is the best way to work with Nagle's algorithm / TCP_NODELAY / TCP_CORK.

It is described in this RedHat manual and the verdict is:

  • Set TCP_NODELAY = 1, always.
  • If you can batch data for sending by creating a buffer manually, or using writev(), prefer that.
  • If you cannot (e.g. "when using different libraries that provides abstractions for layers" from the above manual):
    • Set TCP_CORK = 1, then write the data, then set TCP_CORK = 0.
  • This builds a packet in kernel space and then flushes it out.

Bible Bot Christian Companion AI Prompt

You can copy, translate, modify, and distribute this resource, without restriction, and without needing to ask permission.

Background

I'm not the first one to think about a Bible AI chatbot. Many, many people have done it. Few have done it well to keep the AI focused on the Truth of God and not hallucinate.

I am no prompt engineer and am newer to the AI space. However, I've used prompt injection techniques

@rmcdongit
rmcdongit / macOS_SytemPrefs.md
Last active May 14, 2024 11:42
Apple System Preferences URL Schemes

macOS 10.15 System Preference Panes

Below are a list of System Preference pane URLs and paths that can be accessed with scripting to assist users with enabling macOS security settings without having to walk them through launching System Preferences, finding panes, and scrolling to settings. Not all panes have an accessible anchor and some are OS specific.

To find the Pane ID of a specific pane, open the System Preferences app and select the desired Preference Pane. With the pane selected, open the ScriptEditor.app and run the following script to copy the current Pane ID to your clipboard and display any available anchors:

tell application "System Preferences"
	set CurrentPane to the id of the current pane
	set the clipboard to CurrentPane
@glombard
glombard / combine.py
Created November 24, 2014 00:22
Merging 4 images into one with Python and PIL/Pillow
# Combine multiple images into one.
#
# To install the Pillow module on Mac OS X:
#
# $ xcode-select --install
# $ brew install libtiff libjpeg webp little-cms2
# $ pip install Pillow
#
from __future__ import print_function
@davepcallan
davepcallan / StackOverflowCloneInsertData.sql
Created August 16, 2023 13:22
Create schema and insert dummy data into Stack Overflow clone
-- Create StackOverflow-like Database
CREATE DATABASE StackOverflowClone
GO
USE StackOverflowClone
GO
-- Users table
@rguiscard
rguiscard / uConsole.md
Last active May 14, 2024 11:37
uConsole tips and tricks

Installation with new image

Download image from uConsole github. Unzip with p7zip:

$> sudo apt-get install p7zip
$> p7zip -d uConsole_CM4_v1.3g_64bit.img.7z

Find the SD card, probably at /dev/sda. Write image with dd:

@selfawaresoup
selfawaresoup / uconsole.md
Last active May 14, 2024 11:36
Notes for Clockwork uConsole setup

uConsole Notes

Batteries

I use two XTAR 16850-3500 cells and I get about 8h of active usage out of them.

Get GNOME Shell and GDM3

sudo apt install gnome-shell gdm3
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active May 14, 2024 11:33
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'