Profile
Achievement
zingo's Recent Snippets
- All /
Cocoa provides NSTask to run subprocesses. It can be used to run shell scripts, but all this manual pipe and file handling is a bit cumbersome. Fortunately, for a simple script, we can use the trusty old system and redirect its result to a file.
0
1069
posted 13 years ago by zingo
Do you need you app to do something when it is first run on a certain computer? Do you need to know if it has been run before? Enter the following code into your Application Delegate.
This code creates a BOOL that is created when the app is run. T...
0
1105
posted 13 years ago by zingo
Get a list of providers for DTrace that OSX supports. (DTrace is a probe/profiling tool created by Sun that came with Mac OS X starting with Leopard.)
0
975
posted 13 years ago by zingo
Drawing scaled rectangles of arbitrary width and height that keeps the corner and sides properly scaled while growing the center.
1
1084
posted 14 years ago by zingo
List of breakpoints for debuging with gdb. Add them to your ~/.gdbinit.
0
980
posted 14 years ago by zingo
grep through all history from within a Subversion working directory, like:
$ svngrep SecItemCopyMatching *
0
897
posted 14 years ago by zingo
With 10.5 Apple deprecated the use of NSMailDelivery – without a replacement. So the questions comes up regulary – how does one send emails from Cocoa? Turns out there are couple of frameworks available that can also be used to do the job.
*...
0
1389
posted 14 years ago by zingo
Using SQL you can have your database return the distance between 2 sets of Lat and Long points, and using some math functions also take into account the curvature of the earth.
3
1184
posted 15 years ago by zingo
Put this into your ~/.bashrc script and you should see the Git/SVN status in your prompt if your working directory is a sandbox.
0
1066
posted 15 years ago by zingo
Substitute and update keywords like $HeadURL$, $Revision$, etc. in a file on every commit to subversion repos.
1. Set svn:keywords on repos:
$ svn propset --recursive svn:keywords 'HeadURL Revision LastChangedBy Date' /path/to/repo
2. Use this...
0
975
posted 16 years ago by zingo
Remove all the keys of the application’s preferences file from ~/Library/Preferences with Cocoa’s NSUserDefaults class.
2
1004
posted 16 years ago by zingo
Place this in your ~/.bash_profile then type tab in your terminal window to see some magic happen.
0
860
posted 16 years ago by zingo
Using a gcc predefined macro, __DATE__, the code can know for itself when it was compiled, and build in an expiration date based on that value.
The former code (http://snipplr.com/view/3448/kill-app-after-expire-date/) was not internationalised an...
5
1129
posted 16 years ago by zingo
Recursively SVN rename (move) all thtml-files to ctp-files . Fires this up in CakePHPs /views path.
0
1049
posted 16 years ago by zingo
You can store an IP address in an INT UNSIGNED (4 bytes) which is of course much more efficient and faster than a CHAR(15).
MySQL has two built-in functions: INET_ATON() and INET_NTOA(). These two functions are used allover the place in any TCP/IP s...
0
1084
posted 16 years ago by zingo
recover to normal speed with
/sbin/ipfw delete 100
/sbin/ipfw delete 200
... or reboot
0
965
posted 16 years ago by zingo