Skip to content

Instantly share code, notes, and snippets.

Mac Network Commands Cheat Sheet
After writing up the presentation for MacSysAdmin in Sweden, I decided to go ahead and throw these into a quick cheat sheet for anyone who’d like to have them all in one place. Good luck out there, and stay salty.
Get an ip address for en0:
ipconfig getifaddr en0
Same thing, but setting and echoing a variable:
@mattrco
mattrco / config.toml
Created June 29, 2014 12:18
Heka syslog -> file output
[LogstreamerInput]
log_directory = "/var/log"
file_match = 'syslog\.?(?P<Seq>\d*)'
priority = ["^Seq"]
[FileOutput]
message_matcher = "TRUE"
path = "/tmp/output"
@mattrco
mattrco / index.log
Created October 10, 2012 20:02
VDBE opcodes for adding an index to an integer column
sqlite> EXPLAIN CREATE INDEX IF NOT EXISTS exampleidx ON names (id);
addr opcode p1 p2 p3 p4 p5 comment
---- ------------- ---- ---- ---- ------------- -- -------------
0 Trace 0 0 0 00
1 Goto 0 34 0 00
2 CreateIndex 0 1 0 00
3 OpenWrite 0 1 0 5 00
4 NewRowid 0 2 0 00
5 String8 0 3 0 index 00
6 String8 0 4 0 exampleidx 00
@mattrco
mattrco / explain.log
Created October 10, 2012 19:52
SQLite Explain Insert
sqlite> EXPLAIN INSERT INTO names VALUES (1, 'Holly');
addr opcode p1 p2 p3 p4 p5 comment
---- ------------- ---- ---- ---- ------------- -- -------------
0 Trace 0 0 0 00
1 Goto 0 10 0 00 Jump to address P2 (line 10 here, so starts transaction)
2 OpenWrite 0 2 0 2 00 Open a read/write cursor (only one permitted)
3 NewRowid 0 1 0 00 Record number, in this case specified in our INSERT statement
4 Integer 1 2 0 00
5 String8 0 3 0 Holly 00
6 MakeRecord 2 2 4 dc 00 Convert P2 registers beginning from P1 into a database record
@mattrco
mattrco / insert.log
Created October 10, 2012 19:39
Example SQLite INSERT
sqlite> .schema names
CREATE TABLE names(id int, name string);
sqlite> INSERT INTO names VALUES (1, 'Holly');
sqlite> SELECT * FROM names;
1 | Holly
@mattrco
mattrco / VdbeIntExtract.h
Created October 10, 2012 19:33
Selected attributes of struct Vdbe from VdbeInt.h
struct Vdbe {
sqlite3 *db; /* The database connection that owns this statement */
Op *aOp; /* Space to hold the virtual machine's program */
Mem *aMem; /* The memory locations */
Mem **apArg; /* Arguments to currently executing user function */
Mem *aColName; /* Column names to return */
Mem *pResultSet; /* Pointer to an array of results */
int nMem; /* Number of memory locations currently allocated */
int nOp; /* Number of instructions in the program */
VdbeCursor **apCsr; /* One element of this array for each open cursor */