MacOSX Guru Sitehttp://www.macosxguru.net
Information, tips and tricks, FAQ for Mac OS X developersen-gbProblem with num keypad in vi(m) ?http://www.macosxguru.net/article.php?story=20151231121619781
You connect to your Linux box thru PuTTY or Mac's Terminal application and numeric keypad doesn't work as you expected, entering meta key instead of the expected values (0,1,… ,+,-, …) ?Here is the solution…
create or edit if it already exists a .vimrc file in the user account and insert the following lines:<pre><code>imap &lt;Esc&gt;Oq 1imap &lt;Esc&gt;Or 2imap &lt;Esc&gt;Os 3imap &lt;Esc&gt;Ot 4imap &lt;Esc&gt;Ou 5imap &lt;Esc&gt;Ov 6imap &lt;Esc&gt;Ow 7imap &lt;Esc&gt;Ox 8imap &lt;Esc&gt;Oy 9imap &lt;Esc&gt;Op 0imap &lt;Esc&gt;On .imap &lt;Esc&gt;OR *imap &lt;Esc&gt;OQ /imap &lt;Esc&gt;Ol +imap &lt;Esc&gt;OS -nmap &lt;Esc&gt;Oq 1nmap &lt;Esc&gt;Or 2nmap &lt;Esc&gt;Os 3nmap &lt;Esc&gt;Ot 4nmap &lt;Esc&gt;Ou 5nmap &lt;Esc&gt;Ov 6nmap &lt;Esc&gt;Ow 7nmap &lt;Esc&gt;Ox 8nmap &lt;Esc&gt;Oy 9nmap &lt;Esc&gt;Op 0nmap &lt;Esc&gt;On .nmap &lt;Esc&gt;OR *nmap &lt;Esc&gt;OQ /nmap &lt;Esc&gt;Ol +nmap &lt;Esc&gt;OS -smap &lt;Esc&gt;Oq 1smap &lt;Esc&gt;Or 2smap &lt;Esc&gt;Os 3smap &lt;Esc&gt;Ot 4smap &lt;Esc&gt;Ou 5smap &lt;Esc&gt;Ov 6smap &lt;Esc&gt;Ow 7smap &lt;Esc&gt;Ox 8smap &lt;Esc&gt;Oy 9smap &lt;Esc&gt;Op 0smap &lt;Esc&gt;On .smap &lt;Esc&gt;OR *smap &lt;Esc&gt;OQ /smap &lt;Esc&gt;Ol +smap &lt;Esc&gt;OS -cmap &lt;Esc&gt;Oq 1cmap &lt;Esc&gt;Or 2cmap &lt;Esc&gt;Os 3cmap &lt;Esc&gt;Ot 4cmap &lt;Esc&gt;Ou 5cmap &lt;Esc&gt;Ov 6cmap &lt;Esc&gt;Ow 7cmap &lt;Esc&gt;Ox 8cmap &lt;Esc&gt;Oy 9cmap &lt;Esc&gt;Op 0cmap &lt;Esc&gt;On .cmap &lt;Esc&gt;OR *cmap &lt;Esc&gt;OQ /cmap &lt;Esc&gt;Ol +cmap &lt;Esc&gt;OS -</code></pre>MacPort ncurses install problem ?http://www.macosxguru.net/article.php?story=20151115075133545
You got some error similar to:<pre><code>Error: org.macports.activate for port ncurses returned: Image error: /opt/local/bin/captoinfo is being used by the active ncursesw port. Please deactivate this port first, or use 'port -f activate ncurses' to force the activation.</code></pre>here is a solution...
<pre><code>&#36; sudo port selfupdate&#36; sudo port upgrade outdated&#36; sudo port -f activate ncurses @6.0_0</code></pre>adapt to the library/version cause of your problem...Yes, we too want a New MacProhttp://www.macosxguru.net/article.php?story=20120525082830626
If you have a FB account don't hesitate: <a href="http://www.facebook.com/MacProsPlease"> "sign"</a> the petition!
But more than a new MacPro, we want a full new Apple subsidiary - like FileMaker Inc was created some time ago - to take charge of the Pro business needs outside of the turbulences generated by the "i-something" strategy.<br />A real new company in charge of developing the products - hard and soft - the Pro market requires !<br />NOW ! <br />JPA @Lob and PostgreSQLhttp://www.macosxguru.net/article.php?story=20120116143052547
Lot of discussions with contradictory information on the Net about the problematic, here a quick resume of the "how to"
<pre><code>SQL JavaTEXT @Lob @Type(type = "org.hibernate.type.TextType") Stringoid @Lob java.sql.Blob bytea @Lob @Type(type = "org.hibernate.type.PrimitiveByteArrayBlobType") byte&#91;&#93;</code></pre>and in a file named "hibernate.properties" available at the root of the classpath:<pre><code>hibernate.jdbc.use_streams_for_binary=truehibernate.dialect=org.hibernate.dialect.PostgreSQLDialect</code></pre>(and "hibernate.jdbc.use_streams_for_binary" should not be a "property" in persitence.xml as you may find on many sites: this doesn't work, look at the source code of the Hibernate properties loader if you don't believe us !)How to allow QMail to support more connections per IPhttp://www.macosxguru.net/article.php?story=20120108122408686
If you have a large number of web domains on a single Web server and want to read mails in account every of these domains from the same mail client, you may have random connection failures…
If your Web server uses QMail as mail agent, the problem is due to the fact that QMail has a parameter fixing the max number of connections per IP:<br />in files: <pre><code>/etc/courier-imap/pop3d/etc/courier-imap/imapd</code></pre>edit the MAXPERIP parameter which is by default fixed to 4 and increase it to your taste.restart the daemon afterwards:<pre><code>sudo /etc/init.d/courier-imap restart</code></pre>Dynamic libraries on iOShttp://www.macosxguru.net/article.php?story=20110712175443515
Yes, we know, "you can't" Apple says…
Ok, submitting an application to the AppStore using dlopen() to load you own plug-ins will likely result into rejection, <br />you may still do it for the fun, on a j******d iOS device, on your own developer device, for in-house app…<br /><br />But how ?<br /><br />Dynamic linking for iOS is not supported by Xcode templates and if there is a way to patch the Xcode templates <br />(see <a href="http://sumgroup.wikispaces.com/iPhone_Dynamic_Library">here</a>), the main drawback is that you have to patch files supplied with Xcode that may likely be overwritten at next iOS SDK update.<br /><br />Another method, more in the Xcode way of doing things, is to go the bundle way.<br />You know a bundle is just a wrapper around a dynamic library but what you may not know (since there is no template to create bundle in the iOS section of the "New project" window),is that in fact the iOS build system allows for the creation of bundles.<br /><br />So start with the bundle Cocoa template and then switch the SDK for the iOS one, and change the other settings you may need to.<br />You then will be able to compile a bundle that you will be able to include in your main application. You may of course build both device and simulator versions.<br /><br />The best way then to use it in your application project is to add your "bundle" project as a subproject of your application one.<br /> And add the product of this project (the wanted bundle) to a Copy Resource phase.<br />By doing so, the biggest advantage will be to benefit of the automatic selection of the right version to copy in the application bundle when you run for the Simulator or on the iOS device.<br />Calling you code is then just a matter of using CFBundle resource in case your plug-in is just made of pure C functions<pre><code> CFBundleRef mainBundle = CFBundleGetMainBundle() ; CFURLRef bundleURL = CFBundleCopyResourceURL ( mainBundle, CFSTR("MY_BUNDLE_NAME"), CFSTR("bundle"), NULL) ; CFBundleRef pluginBndlRef = CFBundleCreate(kCFAllocatorDefault, bundleURL) ; if (pluginBndlRef) { MyEntryPointFuncPtrType funcPtr = CFBundleGetFunctionPointerForName(pluginBndlRef, CFSTR("MY_ENTRY_POINT_NAME")) ; if (funcPtr) { } }</code></pre><br />or you may use NSBundle if your plug-in is made of Objective-C classes.AMQP Cocoa Clienthttp://www.macosxguru.net/article.php?story=20110711133153403
Or how to connect with Objective-C to a RabbitMQ broker…
Here is a demo <a href="downloads/AMQP.mov">video</a> of a little <a href="AMQP-TestPublic.zip">application</a> including an AMQP framework.<br />Another <a href="downloads/AMQP-iOS.m4v">video</a> demonstrating the use of the same library on iOS.<br />Contact <a href="p3c@p3-consulting.net">us</a> for more information about using it in your own applications.Tracking NSBrowser selectionhttp://www.macosxguru.net/article.php?story=20110615112914355
Before 10.6, it was not easy to do, subclassing the browser cell was one way to do it, but since 10.6 it's easier, here is how to…
Introduced in 10.6:<pre><code>- (NSIndexSet *)browser:(NSBrowser *)browser selectionIndexesForProposedSelection:(NSIndexSet *)proposedSelectionIndexes inColumn:(NSInteger)column</code></pre>By implementing this method in your delegate/datasource, you can test if the selection will be empty after the processing of the proposed index will be done:<pre><code>BOOL willGoNoSelection = (column == 0) &amp;&amp; (&#91;proposedSelectionIndexes count&#93; == 0) ;</code></pre>and then, according to your needs, turn on/off UI items.The initial state of these items remain to be set up in some "init" method: only you know if the selection is empty at start of the browsing session or not.CGFunctionCreate's callbacks and 64 bits compilationhttp://www.macosxguru.net/article.php?story=20110609211254942
Before you get bitten by this one, better to know how to correct most code examples found on the net...
Most example found on Internet will show filter function with this prototype:<pre><code>void filterFunction(void *info, const float *inData, float *outData){ float *colors = info;...</code></pre>That's wrong once you compile in 64 bits (arch x86_64), the correct prototype is:<pre><code>void filterFunction(void *info, const CGFloat *inData, CGFloat *outData){ CGFloat *colors = info;...</code></pre>Using CGFloat guarantees the pointer arithmetic you may use in the body of the function yields to the correct result.Speed-up SSH connectionshttp://www.macosxguru.net/article.php?story=20100926095331323
If you have shell scripts that need to execute several SSH command to a remote host, here is how to reduce the connection time…
As long as you use OpenSSH version 4 or newer:<br>add to ~/.ssh/config file:<pre><code>Host *ControlMaster auto ControlPath /tmp/%r@%h:%p</code></pre>will reduce connection time by using a local socket.<br>Replace * by a specific host name if you don't want to apply this to every host.