Skip to content

Instantly share code, notes, and snippets.

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@ctlllll
ctlllll / longest_chinese_tokens_gpt4o.py
Created May 13, 2024 19:53
Longest Chinese tokens in gpt4o
import tiktoken
import langdetect
T = tiktoken.get_encoding("o200k_base")
length_dict = {}
for i in range(T.n_vocab):
try:
length_dict[i] = len(T.decode([i]))
except:

Pip is a package manager of python. You can download Python libraries from some Python repositories like PyPI. You can also download libraries from a git repository. This is gonna be the issue to be explained in this article.

I don't like to memorize things all the time. So, I guess, I couldn't be working without internet :). Whenever I need to install some python libraries from a git repositories, I see a lot of way to do it. It is really confusing. This should be the reason why I can't memorize it. I can see how a very simple requirement is handled with to many confusing way. There shouldn't be to many way. Some of them is not working neither. At last, I decided to blog it.

As you may know, you can use two protocols which are http and ssh to do something on git repositories. Using protocol ssh instead of http may provide some ease of use. Because of nature of ssh, you can do something with your primary/public keys. So, you don't have to input your credentials all the time. But I'll be

@ogrrd
ogrrd / dnsmasq OS X.md
Last active May 14, 2024 08:39
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.

Requirements

Install

{
"name": "MyToken",
"address": "0xd9145CCE52D386f254917e481eB44e9943F39138",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
@ovelny
ovelny / timeshift-archlinux-fix.md
Last active May 14, 2024 08:34
Fix for scheduled backups with Timeshift and Arch Linux

Issue

If you installed Timeshift from the AUR package (https://aur.archlinux.org/packages/timeshift/), you'll find that scheduled backups may not work. This is due to cronie being disabled by default.

Fix

Check if cronie is present first:

systemctl list-unit-files | grep cronie
# convert_materials_to_cycles.py
#
# Copyright (C) 5-mar-2012, Silvio Falcinelli. Fixes by others.
#
# special thanks to user blenderartists.org cmomoney
#
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@anildigital
anildigital / cleanup_swap.md
Last active May 14, 2024 08:28
Cleanup swap space on macOS

To see current swap usage

sysctl -a | grep swap

Use only when when your system is in a very bad shape

$ sudo pkill -HUP -u _windowserver 
@xarinatan
xarinatan / networked pulseaudio.md
Last active May 14, 2024 08:25
How to set up PulseAudio over Network

How to set up PulseAudio over Network

PulseAudio actually has great networking capabilities. Especially when combined with Avahi/Zeroconf it is especially easy to set up, though technically it should also be possible without.

Setting up the server

  • Open /etc/pulseaudio/default.pa
  • At the end of the file, add load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.254.0/24 auth-anonymous=1 to activate networked audio from 192.168.254.0-255 without needing authentication.
  • Kill pulseaudio, it should be auto-restarted, or restart your login session to activate the changes. You should now be able to set PULSE_SERVER=192.168.254.XXX and have the remote audio working! If not check the firewall settings, PulseAudio seems to open a random port by default.

Setting up automatic configuration and discovery

  • On both the server and client, install pulseaudio-module-zeroconf and avahi, then after installing make sure Avahi always runs by running systemctl enable --now avahi-daemon