This is a SCRIPT-8 cassette.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"math/rand" | |
"sort" | |
"testing" | |
) | |
func BenchmarkInsertSorted(b *testing.B) { | |
data := make([]int, b.N) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# update_timezones.py | |
# Aleksandr Pasechnik | |
# | |
# Goes through the Day One jounal and sets the Time Zone of each entry that | |
# doesn't already have one to the value of the *timezone* variable. Makes a | |
# backup copy of each entry it modified by adding a '.tzbak' to the filename. | |
# Ignores any entry that already has a '.tzbak' version. | |
# | |
# NOTE: base_dir may need to be adjusted to the correct Journal_dayone location | |
# NOTE: It is probably a good idea to have a full journal backup just in case |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function lat_lon(thing) { | |
return { | |
"lat": thing.lat || thing.latitude, | |
"lon": thing.lon || thing.longitude, | |
} | |
} | |
function distance(loc1, loc2) { | |
loc1 = lat_lon(loc1) | |
loc2 = lat_lon(loc2) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: pink; icon-glyph: kiwi-bird; | |
const home = await (new Request("https://chicken.photos")).loadString() | |
const chickenLine = home.split("\n").filter(x=>x.match(/<a href="\/\d+">/))[0] | |
const m = chickenLine.match(/a href="([^"]+)"><img .*src="([^"]+)"/) | |
const chickenUrl = "https://chicken.photos" + m[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pingcheck = hs.menubar.new() | |
function pingUpdate() | |
pingcheck:setTitle('⥌'..pingcheck:title()) | |
local p = hs.network.ping('example.com', 3) | |
hs.timer.doAfter(4, function() | |
p:cancel() | |
local avg = p:summary():match('%/(%d+)%.%d+%/') | |
if avg == nil or avg == '0' then | |
pingcheck:setTitle('∞') | |
else |
OlderNewer