Skip to content

Instantly share code, notes, and snippets.

@jerblack
jerblack / 1. Detecting dark mode change in Windows 10.md
Last active February 22, 2024 06:01
Golang: Detect dark mode change in Windows 10

I wanted to be able to detect when Dark mode was turned on or off in my Go program so I can swap icons in my tray app on Windows so I wrote this.
When Dark Mode is turned on or off, it writes to a pair of registry keys, both of which Windows allows you to set independently in Settings > Personalization > Colors.

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize  

SystemUsesLightTheme  DWORD 0 or 1 // Changes the taskbar and system tray color  
AppsUseLightTheme     DWORD 0 or 1 // Changes app colors  

Mine is a tray app, so I am monitoring the first one. I did not want to just periodically poll the registry key and I wanted to be able to react immediately when the registry key is changed, so I am using the win32 function RegNotifyChangeKeyValue in advapi32.dll to tell the OS to notify my app so I can swap out the icon for a color-appropriate one.
I start the monitor function in main, which loads the RegNotifyChangeKeyValue function from advapi32 and starts a gorouti

local M = {}
-----
math.randomseed( os.time() )
math.random()
-----
local function num2bs(num)
local _mod = math.fmod or math.mod
local _floor = math.floor
--
local result = ""
#!/usr/bin/env ruby
require 'rest-client'
require 'time'
require 'json'
require 'bundler'
CHECK_GEMS_BEFORE = Time.parse("Feb 8, 2015")
def check_bundler
@SunboX
SunboX / fxos-fading-away.md
Created January 26, 2016 22:03
Why I care about Firefox OS fading away

Why I care about Firefox OS fading away

Now it's official, Firefox OS moves into the „Tier 3“ support category.

Tier-3 platforms have a maintainer or community which attempt to keep the platform working. These platforms may or may not work at any time, and often have little test coverage.

Quote from MDN — Supported build targets

… So this basically means there won't be any extended effort to make Firefox OS more stable, or to make it even more user friendly. Also, there won't be any new advertisements to get a wider user base.

@paton
paton / simple.js
Last active October 7, 2019 16:14
Super simple implementation of define() and require() used in Localize.js (https://localizejs.com)
var define, require;
(function() {
var modules = {};
require = function(name) {
return modules[name]();
};
define = function(name, fn) {
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')