[categories] [index] [all (419)] [latest]
$ lsof -i -a -p 99340
Delete recursively starting from current directory.
$ find . -name .DS_Store -ls -exec rm {} ;
To be used through an alias such as rmDS, for instance.
If you don't need to print the delete file names:
$ find . -name ".DS_Store" -delete
$ codesign -dvvvv --extract-certificates /Applications/Mail.app
The certificates are saved in DER format, named codesign0, codesign1, ...
They can be displayed with OpenSSL :
$ openssl x509 -inform DER -in codesign0 -text
fileinput reads lines sequentially, but doesn't keep them in memory.
import fileinput
for line in fileinput.input(['path']):
print line
$ kill -STOP <PID>
$ kill -CONT <PID>
Set the 4th byte of /tmp/test to 0xFF:
$ printf '\xFF' | dd bs=1 seek=4 conv=notrunc of=/tmp/test
>>> dict((k, []) for k in ['a', 'b', 'c'])
{'a': [], 'c': [], 'b': []}
from datetime import datetime
from dateutil.parser import parse
print parse("Tue, 22 Jul 2008 08:17:41 +0200")
2008-07-22 08:17:41+02:00
or
from dateutil.parser import parse
print parse("Tue, 22 Jul 2008 08:17:41 +0200")
2008-07-22 08:17:41+02:00
import DictionaryServices
s = "love"
print DictionaryServices.DCSCopyTextDefinition(None, s, (0,len(s)))
love |lʌv| noun 1 a strong feeling of affection: ...
Thread safe code to be run only once with all other thread waiting at the barrier:
static dispatch_once_t onceToken;
dispatch_once (&onceToken, ^{
// ...
});
$ /System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Resources/jsc
> 1+1
2
$ sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'select LSQuarantineDataURLString from LSQuarantineEvent'
you can delete the table with:
$ sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'
Let the profiler execute the code
import hotshot
prof = hotshot.Profile("hotshot_stats.prof")
prof.runcall(my_function)
prof.close()
Display results
from hotshot import stats
s = stats.load("hotshot_stats.prof")
s.strip_dirs()
s.sort_stats('time', 'calls')
s.print_stats(20)
// $ gcc -m32 -fasm-blocks asm.c -o asm
#include <stdio.h>
int main (int argc, char *argv[]) {
int espValue;
_asm {
mov [espValue], esp;
}
printf("espValue: %u\n", espValue);
return 0;
}
(gdb) inf files
Symbols from "/private/tmp/hello".
Mac OS X executable:
/private/tmp/hello, file type mach-o-le.
Entry point: 0x000000f4
0x00000000 - 0x00000042 is LC_SEGMENT.__TEXT in /private/tmp/hello
0x000000e8 - 0x00000128 is LC_SEGMENT.__TEXT.__text in /private/tmp/hello