Skip to content

Instantly share code, notes, and snippets.

@whitefoxx
whitefoxx / slots
Created August 4, 2026 13:43
localmd early-access slots taken
1
@whitefoxx
whitefoxx / README.md
Created August 2, 2026 05:07
claude-awake: keep your Mac awake (even lid-closed) while Claude Code is working — heartbeat hooks + pmset watchdog

claude-awake — Claude Code 跑长任务时不让 Mac 睡觉(合盖也行)

两个小脚本,让 MacBook 在 Claude Code 干活时保持清醒(合上盖子也继续跑),任务一结束就恢复正常睡眠,不空耗电池。

原理

心跳 + 看门狗,两个进程各司其职:

  • claude-awake-hook.sh(心跳):挂在 Claude Code 的 hooks 上。提交 prompt、每次工具调用后 touch 一个以 session_id 命名的状态文件;回合结束、会话退出时删掉。文件存在且新鲜 = 这个会话正在干活。多开几个 Claude 实例互不干扰,各管各的文件。
  • claude-awake-daemon.sh(看门狗):LaunchAgent 常驻,每 20 秒决策一次——只要有 ≥1 个「30 分钟内刷新过」的状态文件、且 CPU 没有过热降频,就 pmset -a disablesleep 1(合盖也不睡);否则翻回 0(正常睡眠)。
import time
import asyncio
import json
import aiohttp
import random
def output_result(r):
print(time.time(), r)
@whitefoxx
whitefoxx / webpack.config.js
Last active September 14, 2017 15:05
Sample webpack config
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
filename: 'build.js'
},
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/