Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am anders on github.
  • I am andersman (https://keybase.io/andersman) on keybase.
  • I have a public key ASCaFkdoO8GLMgCbAoW5N7LpFbe9iz-I9R-t1xPANdhC7wo

To claim this, I am signing this object:

@anders
anders / gist:af01c4bbc995935d492dd55d2fb060c8
Created November 4, 2018 16:00
strace linux (working)
21186 execve("./test", ["./test"], [/* 29 vars */]) = 0
21186 arch_prctl(ARCH_SET_FS, 0x55f5d0) = 0
21186 sched_getaffinity(0, 8192, [0]) = 64
21186 mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc9f4f58000
21186 mmap(0xc000000000, 67108864, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc000000000
21186 mmap(0xc000000000, 67108864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xc000000000
21186 mmap(NULL, 33554432, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc9f2f58000
21186 mmap(NULL, 2162688, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc9f2d48000
21186 mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc9f2d38000
21186 mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc9f2d28000
@anders
anders / gist:b46917a0adc49a39c380e57a4847d2d6
Last active November 4, 2018 15:58
pty test strace wsl
4902 execve("./test", ["./test"], 0x7fffd3b0a338 /* 23 vars */) = 0
4902 arch_prctl(ARCH_SET_FS, 0x5605d0) = 0
4902 sched_getaffinity(0, 8192, [0, 1, 2, 3]) = 64
4902 mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f09977f0000
4902 mmap(0xc000000000, 67108864, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc000000000
4902 mmap(0xc000000000, 67108864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xc000000000
4902 mmap(NULL, 33554432, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f09957f0000
4902 mmap(NULL, 2162688, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f09955e0000
4902 mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f09955d0000
4902 clock_gettime(CLOCK_MONOTONIC, {tv_sec=10123, tv_nsec=347148300}) = 0
@anders
anders / throttle.py
Last active August 29, 2015 13:57 — forked from ChrisTM/throttle.py
class throttle(object):
"""
Decorator that prevents a function from being called more than once every
time period.
To create a function that cannot be called more than once a minute:
@throttle(minutes=1)
def my_fun():
pass
#!/usr/bin/env luajit
-- Original source code at:
-- http://www.opensource.apple.com/source/DarwinTools/DarwinTools-1/sw_vers.c
local ffi = require 'ffi'
local CF = require 'CoreFoundation'
ffi.cdef[[
CFDictionaryRef _CFCopyServerVersionDictionary(void);
CFDictionaryRef _CFCopySystemVersionDictionary(void);
@anders
anders / fork.txt
Created February 24, 2013 12:05
fork
CAVEATS
There are limits to what you can do in the child process. To be totally
safe you should restrict yourself to only executing async-signal safe
operations until such time as one of the exec functions is called. All
APIs, including global data symbols, in any framework or library should
be assumed to be unsafe after a fork() unless explicitly documented to be
safe or async-signal safe. If you need to use these frameworks in the
child process, you must exec. In this situation it is reasonable to exec
yourself.
@anders
anders / monthly-playlist.applescript
Last active October 5, 2015 10:27
monthly-playlist.applescript
set month_list to {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"}
set current_date to current date
set current_month to 1 * (month of current_date)
set current_year to (year of (current date))
set playlist_name to "" & current_year & "-" & (item current_month of month_list)
tell application "iTunes"
try
set pl_monthly to playlist playlist_name
on error
@anders
anders / recovery-gpt.txt
Created May 26, 2012 09:58
Mac GPT layout
$ gpt -r show disk0
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 6
40 409600 1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
409640 1951845952 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
1952255592 1269536 3 GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
1953525128 7
@anders
anders / lion-duid.txt
Created May 26, 2012 09:57
Mac OS X 10.7 DUID
$ ipconfig getv6packet en1
DHCPv6 REPLY (7) Transaction ID 0x55156a Length 84
Options[3] = {
CLIENTID (1) Length 14 DUID ... Addr 3c:07:54:26:99:ee <<<
SERVERID (2) Length 14 DUID ... Addr 54:e6:fc:e5:76:25
IA_NA (3) Length 40 IA_NA ... Options[1] = {
IAADDR (5) Length 24 IAADDR 2001:db8::1 ... 86400 Valid=86400
}
}
@anders
anders / removeduplicates.applescript
Last active October 5, 2015 10:27
RemoveDuplicates
--
-- RemoveDuplicates - remove duplicate tracks in an iTunes playlist
-- Anders Bergh <anders1@gmail.com>, May 2012
-- Public Domain
--
tell application "iTunes"
set fi to fixed indexing
set fixed indexing to true