page = sigpipe 13
url = https://sigpipe.macromates.com
As a general solution I created the every command available here .
This will run command every number time it’s invoked. For example to send an email the third, sixth, ninth, etc. time we call it, use:
The command uses a guard file written to $XDG_DATA_HOME/every . If XDG_DATA_HOME is unset then it defaults to $HOME/.local/share .
The name of the guard file is derived from the arguments passed to every (using sha1) and the content of the guard file is a counter to keep track of how many times we have been called. As a convenience we also write the command to the guard file.
Once the counter reaches the value given via -n then every will remove the guard file and exec your command.
If the external guard file is undesired or readability is not a concern, then an alternative approach is to use modular arithmetic with the UNIX epoch returned by date +%s . For an example see this post .
If you upgraded to Mountain Lion and often want to cd into ~/Library/Application Support you might be a little annoyed by the new Application Scripts directory that makes the normal ~/Library/Ap⇥ stop at ~/Library/Application S‸ to have you disambiguate the path.
To avoid this you can set the FIGNORE variable. From man bash :
Some other useful variables you can set in ~/.inputrc that (IMHO) improve the default behavior of filename completion:
The ignore case allows you to type ~/l⇥ and still get ~/Library/ .
Marking symlinked directories is useful for /tmp , /etc , and /var .
The binary installed is named g++-mp-4.5 and you must use the -std=c++0x argument to enable the new features.
This was executed on a 2 × 2.8 GHz Quad Core Mac Pro where PBZip2 (correctly) auto-detected 8 cores.
I am running PBZip2 version 1.1.0 from MacPorts ( sudo port install pbzip2 ).
Update: Added test with LZip (an LZMA based compresser). There is a multi-threaded implementation of this ( plzip ) but a quick ./configure && make did not cut it.
I just learned this neat thing about the cd shell command:
The variable CDPATH defines the search path for the directory containing «dir» . Alternative directory names in CDPATH are separated by a colon ( : ). A null directory name is the same as the current directory. If «dir» begins with a slash ( / ), then CDPATH is not used.
This works with tab completion (using bash 4.1.2) so regardless of the current directory, I can generally do cd Av⇥↩ to reach ~/Source/Avian .
This is part 2 of what I think will end up as four parts. This might be a bit of a rehash of the first part , but I skimmed lightly over why it actually is that I am so fond of make compared to most other build systems, so I will elaborate with some examples.
This post is a “getting started with make ”. I plan to follow up with a part 2 about how to handle auto-generated self-updating Makefiles.
I host two blogs, a wiki, and a ticket system, all targets for spam, so I have since generalized the system by using mod_rewrite to redirect all POSTs without a cookie to a page which uses JavaScript to set this cookie and resubmit the request (which is then no longer catched by mod_rewrite due to the cookie being set). This means “blocking” spam doesn’t require a plug-in written specifically for the particular web application.
It is sometimes useful to have a script check the OS version, for example the way to get the user’s full name was previously done using niutil but Apple removed that command in Leopard (it can now be done using dscl ).
One of my path functions is normalize . It removes (redundant) slashes and references to directory meta entries (current and parent directory).
A lot of other path functions use or rely on normalize , for example my version of dirname() is simply: return normalize(path + "/.."); .
I was recently tasked with rewriting normalize to be more efficient and it proved to be a bit of a challenge, so I’ll share what I came up with.
Each time you add a rectangle you get back an identifier for this rectangle which can’t be stored in an NSArray as-is since it is of the primitive type NSTrackingRectTag (an integer).
If you use Objective-C++ then you can use a std::vector<NSTrackingRectTag> to avoid having to box/unbox your identifiers but if you have tried to put non-POD in the interface declaration of your Objective-C class you have probably seen that gcc does not like that.
Well, starting with 10.4 (so actually, some time ago) Apple added a switch to gcc which allows C++ objects as part of the instance data, and it will call both constructor and destructor for your C++ objects when allocating/deallocating the Objective-C object.
The flag you need to set is -fobjc-call-cxx-cdtors .
Occasionally it is convenient to pass a C++ object to an Objective-C method. For example I have an NSString initializer that takes a std::string as argument.
This works as long as you pass the object as a reference (i.e. pass a pointer), but you can use the “reference of” operator in the method signature rather than at the call-site. By using a const reference it will work for temporary/implicit objects.
Two very nice shell commands that Apple has given us are the pbcopy and pbpaste commands. These allow stdin to go to the clipboard and the clipboard to be written to stdout.
There’s just one source, it compiles to a command which works as pbcopy , when called under that name, otherwise pbpaste .
What I’ve done is place the command in ~/bin and added a symbolic link from pbpaste to pbcopy , like this:
And in addition ensured that my PATH contains ~/bin before anything else, i.e. by placing the following in my ~/.bash_profile (well, actually ~/.zshrc ):