Skip to content

Instantly share code, notes, and snippets.

@dmertl
dmertl / readme.md
Created July 20, 2023 20:51
Character encoding tricks

If you see several weird characters in a row that look like incorrect character encoding there's a good chance it's UTF-8 interpreted as cp-1252. For example, “ in cp-1252 is 0xE2 0x80 0x9C. Those same 3 bytes in UTF-8, 0xE2809C is .

In MySQL you can do a quick conversion to check:

mysql> SELECT CONVERT(UNHEX(HEX(CONVERT("“" USING LATIN1))) USING utf8mb4);
+--------------------------------------------------------------------+
| CONVERT(UNHEX(HEX(CONVERT("“" USING LATIN1))) USING utf8mb4)     |
+--------------------------------------------------------------------+
| “ |
@dmertl
dmertl / Mac OS X Traktor Bluetooth Speaker
Last active February 3, 2024 16:44
Mac OS X Traktor Bluetooth Speaker
Plugin Z1
Connect to Bluetooth Speaker
Open Audio Midi Setup
Create new aggregate device
Select Z1 and Bluetooth Speaker
Add names to Bluetooth Speaker channels if they don't have any (little squares under subdevices)
Open / Restart Traktor
Select aggregate device as audio output
Set Z1 as main left/right
Set Bluetooth as monitor left/right
@dmertl
dmertl / Cassandra data type byte sizes.txt
Last active February 3, 2024 16:44
Cassandra data type byte sizes
uuid: 16 bytes
timeuuid: 16 bytes
timestamp: 8 bytes
bigint: 8 bytes
counter: 8 bytes
double: 8 bytes
time: 8 bytes
inet: 4 bytes (IPv4) or 16 bytes (IPV6)
date: 4 bytes
float: 4 bytes
@dmertl
dmertl / mac_os_x_cheatsheet.md
Last active November 28, 2024 05:55
Mac OS X Cheatsheet

Stop Slack/Teams from Copy Pasting with Formatting

The Paste command will paste with formatting, Paste and Match Style will not. Swap the keyboard shortcuts in System Settings - Keyboard Shortcuts - Keyboard Shortcuts... - App Shortcuts. Then add shortcuts for the specific app you want to change.

What is Preventing Sleep?

pmset -g

# sleep 1 (sleep prevented by iTunes, coreaudiod)
@dmertl
dmertl / Make AWS EC2 Attached EBS Volume Available on CentOS.md
Last active January 2, 2018 20:22
Make AWS EC2 Attached EBS Volume Available on CentOS

Assuming device /dev/xvdd being mounted to /data.

sudo mkfs -t ext4 /dev/xvdd
sudo mkdir /data
sudo mount /dev/xvdd /data

Add line to /etc/fstab to mount every boot:

sudo vi /etc/fstab

/dev/xvdd /data ext4 defaults,nofail 0 2

@dmertl
dmertl / gist:a9de8f8cb3129e1a2c5a
Created June 9, 2014 22:51
Concise Python Expressions
# Because searching for these is always a pain
# Conditional Assignment
setting = 'default' if param is None else param
Make database changes
The first step in creating a migration is to make any schema changes to the database. If the changes are to the data only you can skip this step.
Create migration file
Next we create a migration file with the differences between the current app/Config/Schema/schema.php file and the database. To do this execute the Console/cake Migrations.migration generate command with the following options:
Do you want compare the schema.php file to the database? - y
Do you want to preview the file before generation? - n
Please enter the descriptive name of the migration to generate: - Name of migration
Do you want update the schema.php file? - y
<html>
<head>
<style type="text/css">
#test-image {
border-radius: 10px;
box-shadow: 0 0 0 3px red;
}
#test-wrap {
display: inline-block;
border: solid 3px #F00;