Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <setjmp.h>
#include <unistd.h>
#include <stdlib.h>
sigjmp_buf jmp_env1;
sigjmp_buf jmp_env2;
void testjmp() {
printf("first run\n");
@thekoc
thekoc / pmset.log
Last active December 13, 2017 03:22
2017-12-13 01:02:02 +0800 Assertions PID 195(mDNSResponder) Created MaintenanceWake "mDNSResponder:maintenance" 00:00:00 id:0x0xd000085f4 [System: No Assertions]
2017-12-13 01:02:02 +0800 Assertions PID 412(cloudphotosd) Released BackgroundTask "com.apple.cloudphotosd.darkwake.sync" 00:09:56 id:0x0xb000085e5 [System: No Assertions]
2017-12-13 01:02:02 +0800 Assertions PID 195(mDNSResponder) Released MaintenanceWake "mDNSResponder:maintenance" 00:00:00 id:0x0xd000085f4 [System: No Assertions]
2017-12-13 01:02:14 +0800 Assertions PID 63(powerd) Created InternalPreventSleep "Network wake delay proxy assertion" 00:00:00 id:0x0xd000085f8 [System: No Assertions]
2017-12-13 01:02:14 +0800 DarkWake DarkWake from Normal Sleep [CDN] due to ARPT/Network: Using BATT (Charge:73%) 30 secs
2017-12-13 01:02:14 +0800 WakeDetails DriverReason:WiFi.TCPTimeout - DriverDetails:
2017-12-13 01:02:14 +0800 HibernateStats hibmode=3 standbydelay=10800
@thekoc
thekoc / 沉默的大多数节选.txt
Created September 9, 2017 03:58
我的师承――《青铜时代序》
我终于有了勇气来谈谈我在文学上的师承。小时候,有一次我哥哥给我念过查良铮先生译的《青铜骑士》:
我爱你,彼得建造的大城
我爱你庄严、匀整的面容
涅瓦河的流水多么庄严
大理石平铺在它的两岸……
@thekoc
thekoc / init.lua
Created July 10, 2017 05:16
Hammerspoon configuration file backup
local function hasValue(value, list)
for i, e in ipairs(list) do
if value == e then
return true
end
end
return false
end
local function applicationWatcher(appName, eventType, appObject)
@thekoc
thekoc / db.py
Last active January 16, 2021 02:59
import sqlite3
import Queue as queue
def singleton(cls):
instances = {}
def _singleton(*args, **kw):
if cls not in instances:
instances[cls] = cls(*args, **kw)
//: Playground - noun: a place where people can play
import Cocoa
import CoreFoundation
//import PlaygroundSupport
//PlaygroundPage.current.needsIndefiniteExecution = true
class CurrencyConverter {
function callAlfred()
if (hs.window.focusedWindow():application():name() ~= "Alfred 3") then
hs.osascript.applescript('tell application "Alfred 3" to search')
hs.keycodes.setLayout("ABC")
else
hs.eventtap.keyStroke({}, "escape")
end
end
hs.hotkey.bind({"alt"}, "space", callAlfred)
emacs_env = hs.hotkey.modal.new('', nil)
emacs_env:bind('alt', 'F', function() hs.eventtap.keyStroke({"alt"}, "right") end)
emacs_env:bind('alt', 'B', function() hs.eventtap.keyStroke({"alt"}, "left") end)
emacs_env:bind('alt', 'D', function() hs.eventtap.keyStroke({"alt"}, "forwarddelete") end)
emacs_env:bind('ctrl', 'N', function() hs.eventtap.keyStroke({}, 'down') end)
emacs_env:bind('ctrl', 'P', function() hs.eventtap.keyStroke({}, 'up') end)
emacs_env:bind('ctrl', 'U', function () hs.eventtap.keyStroke({'cmd'}, 'delete') end)
emacs_env:bind('ctrl', 'W', function () hs.eventtap.keyStroke({'alt'}, 'delete') end)
emacs_env:enter()
# encoding=utf8
from __future__ import print_function
import multiprocessing
def heat():
print("I'm so hot")
while True:
pass
lines = """I am happy to join with you today in what will go down in history as the greatest demonstration for freedom in the history of our nation.
Five score years ago, a great American, in whose symbolic shadow we stand today, signed the Emancipation Proclamation. This momentous decree came as a great beacon light of hope to millions of Negro slaves who had been seared in the flames of withering injustice. It came as a joyous daybreak to end the long night of their captivity."""
def wrap_line(tokens):
if len(' '.join(tokens)) <= 80:
return ' '.join(tokens)
for i in range(len(tokens)):
if len(' '.join(tokens[:i+1])) > 80:
return ' '.join(tokens[:i]) + '\n' + wrap_line(tokens[i:])