Skip to content

Instantly share code, notes, and snippets.

View CTimmerman's full-sized avatar

Cees Timmerman CTimmerman

View GitHub Profile
@CTimmerman
CTimmerman / display_tech_test.md
Last active February 21, 2024 17:32
Laptop display viewing angles suck.

Looks okay on a Dell Latitude D630 but not on a MacBook Air:

Spectrum

Reversed:

Saw back

Both displays use TN (Twisted Nematic) panels, which are cheaper, more efficient, and faster than IPS (In Plane Switching) panels used by iPhone 4 and up, but TN viewing angles are bad, explaining the same OK colors only at 135 degrees on a MacBook Air vs 90 on an Iiyama ProLite E2475HDS.

@CTimmerman
CTimmerman / FixRealtekPoppingSound.ps1
Created January 16, 2024 19:16 — forked from supermarsx/FixRealtekPoppingSound.ps1
Fix popping sound on some Realtek sound cards, realtek audio crackling patch
# Enable Realtek driver power management, this is the default value
REG ADD "HKCU\Software\Realtek\RAVCpl64\PowerMgnt" /v "Enabled" /t REG_DWORD /d 1 /f
# Disable Realtek driver power management, sometimes fixes realtek popping sound
REG ADD "HKCU\Software\Realtek\RAVCpl64\PowerMgnt" /v "Enabled" /t REG_DWORD /d 0 /f
# Replace XXXX with the corresponding key that has "Realtek" in the "DriverDesc", find using regedit
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4d36e96c-e325-11ce-bfc1-08002be10318}\XXXX\PowerSettings" /v "IdlePowerState" /t REG_BINARY /d "ffffffff" /f
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4d36e96c-e325-11ce-bfc1-08002be10318}\XXXX\PowerSettings" /v "PerformanceIdleTime" /t REG_BINARY /d "ffffffff" /f
# Example if class is in 0000
@CTimmerman
CTimmerman / MacOS_sucks.md
Last active January 3, 2024 13:23
MacOS sucks! Making MacOS less painful to use...

Fix horizontal scrolling in Chrome: defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool FALSE and restart Chrome. Fix autoscroll with AutoScroll.

  • Minimized windows don't even appear in Chrome's autocomplete!

Disable MacOS widget popover gesture via System Settings, "trackpad gestures", More Gestures, Notification Centre off.

Windows shortcut equivalents:

  • Alt+Enter or F11 = Cmd+Ctrl+F or Globe+F
  • Alt+Tab = Cmd+Tab (Switch app.) or Cmd+` (Switch app window.) No minimized windows. Witch is a bit slow but can cycle windows with Opt+Tab like Windows does, including the browser window you minimized to get to the one behind it, albeit without thumbnails. AltTab is better, also because it doesn't raise all w
@CTimmerman
CTimmerman / file_downloader.py
Last active December 1, 2023 08:06
Resume HTTP download
"""Download with automatic resume.
2018-06-28 v1.0 by Cees Timmerman
2018-07-09 v1.1 Added If-Unmodified-Since header for consistency."""
import os, shutil, sys, time
import requests # python -m pip install requests
def download_file(url, local_filename=None):
if not local_filename:
local_filename = url.split('/')[-1]
@CTimmerman
CTimmerman / index.html
Last active November 14, 2023 22:30
Hello world, React edition.
<html>
<!-- Thanks to https://medium.freecodecamp.org/learn-react-js-in-5-minutes-526472d292f4 -->
<head>
<script src="https://unpkg.com/react@15/dist/react.min.js">//React controllery stuff.</script>
<script src="https://unpkg.com/react-dom@15/dist/react-dom.min.js">//More React controllery stuff.</script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js">//Translates JSX to JS.</script>
</head>
<body>
<div id="root">Target node for our React code.</div>
<script type="text/babel">
@CTimmerman
CTimmerman / SICP_Scheme_sucks.py
Created September 13, 2017 12:06
Proving that simple for loops are faster for both man and machine.
""" SICP section 2.2.3, page 160.
We can rearrange the pieces and use them in computing the product of the squares of the odd integers in a sequence:
(define (product-of-squares-of-odd-elements sequence) (accumulate * 1 (map square (filter odd? sequence))))
(product-of-squares-of-odd-elements (list 1 2 3 4 5))
225
2017-09-13 v1.0 Translated & benchmarked by Cees Timmerman
"""
from __future__ import print_function # For Python 2.
@CTimmerman
CTimmerman / share_clipboard.py
Last active July 5, 2023 15:15
Share clipboard
# -*- coding: utf-8 -*-
"""
Share clipboard
by Cees Timmerman
01-12-2014 v0.1 Works fine except Tk.clipboard_append()
02-12-2014 v0.9 Nonblocking sockets (didn't help Tk) and clipboard module instead of tkinter.
02-12-2014 v0.99 Bidirectional clipboard sharing. clipboard/pyperclip fails on Unicode like “, though.
08-12-2014 v1.0 pyperclip 1.5.7 supports Unicode (with emoji: 📋) on Windows.
"""
import socket, struct, sys, threading
@CTimmerman
CTimmerman / keybindings.json
Last active June 28, 2023 13:22
Visual Studio Code settings
[
{
"key": "ctrl+f9",
"command": "editor.debug.action.goToNextBreakpoint"
},
{
"key": "ctrl+shift+f9",
"command": "editor.debug.action.goToPreviousBreakpoint"
},
{
@CTimmerman
CTimmerman / bookmarklets.js
Last active June 8, 2023 21:32
Bookmarklets / Favelets - Drag to bookmarks bar and rename, then click on page to affect.
// Speed up / slow down HTML5 videos! Just set as URLs of bookmark bar items:
javascript:(function(){v = []; for(x of document.querySelectorAll("audio, video")) v.push(x); try{v.push(window.frames[0].document.querySelector("audio, video"))}catch(ex){}; for(i of v) i.playbackRate += .4}())
javascript:(function(){v = []; for(x of document.querySelectorAll("audio, video")) v.push(x); try{v.push(window.frames[0].document.querySelector("audio, video"))}catch(ex){}; for(i of v) i.playbackRate -= .4}())
// Highlight new Facebook notifications.
javascript:(function(){var s = document.createElement('style'); s.appendChild(document.createTextNode(".jewelItemNew ._33e{background-color:lightgreen!important;}")); document.head.appendChild(s)}())
// Show videos from messy framework HTML, can't show toolbar in popup due to Chrome bug 82522.
javascript:(function(){var w=window.open();var d=w.document;d.title='Videos';d.body.style.backgroundColor='0';for(var v of document.getElementsByTagName('video')){v.style='';v.controls
@CTimmerman
CTimmerman / .prospector.yaml
Last active April 3, 2023 00:24
Out Of Memory (OOM) Killer to save your SSD and other processes.
pylint:
disable:
- line-too-long
- multiple-imports
- pointless-string-statement
- too-many-nested-blocks