OSX Mail delayed Preview

This is the best thing since sliced bread

http://christianserving.org/project/truepreview

Delay “read” in OSX Mail by 5 seconds.

PDI under Mountain Lion (Weird Error 13)

If you are getting this weird error when starting Kettle under Mountain Lion:

17/12/12 11:39:39.201 AM com.apple.launchd.peruser.501[1827]: ([0x0-0x71b71b].Data Integration 64-bit[11211]) Job failed to exec(3) for weird reason: 13

This is how you fix it:

  1. Go to the directory you unzipped PDI in using terminal
  2. Go into the “Data Integration 64-bit.app/Contents/MacOS” directory
  3. chmod +x JavaApplicationStub
  4. All Done!!

Also make sure your security settings under preferences allows untrusted applications

 

Screen Shot 2012-12-17 at 11.45.53 AM

Sublime Regex

Here’s how you find and replace using Regex in Sublime Text 2

Find: (^.[0-9]),

Replace: 00\1,

This finds a number at the beginning of a line up to a comma and replaces it with 00 and the originally matched number and the original comma

Make sure you have selected the “.*” button in the find/Replace view for regex

Dumping large live database

Dumping a large database while it is live requires a slightly different command

mysqldump –single-transaction very_large_db > bakup_of_db.sql

This dumps the database (or table) at a point in time while not locking the database

Ref: here

NodeJS in 5 minutes

Download Mac Installer
http://nodejs.org

Install and note that node was installed at

/usr/local/bin/node

npm (Node Package Manager)  was installed at
/usr/local/bin/npm

Make sure that /usr/local/bin is in your $PATH.

echo $PATH

Use npm to install node.js packages. This will install package XYZ in current directory

npm install XYZ

This will install package XYZ globally

npm install -g XYZ

Install driver/mapping for MongoDB

npm install mongoose

install rest library

npm install restify

Put your .js files in a Site directory and run them:

node myserver.js

Here is an example from the Node site

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

save this file in your Sites directory as example.js and run the node server

node example.js

Now open the path to the server in a browser

http://127.0.0.1:1337/

MongoDb in 5 minutes

Download and Install MongoDB (using 2.0 64bit stable at the moment)

http://www.mongodb.org/

Copy unzipped directory anywhere (I have it in ~/mongodb-osx-x86_64-2.0.5)

Before you start mongod for the first time, you will need to create the data directory. By default, mongod writes data to the /data/db/ directory. To create this directory, and set the appropriate permissions use the following commands:

sudo mkdir -p /data/db
sudo chown `id -u` /data/db

Run MongoDB Server in one terminal windo

~/usr/mongodb-osx-x86_64-2.0.5/bin/mongod

Run MongoDB Client in another

~/usr/mongodb-osx-x86_64-2.0.5/bin/mongo

NSFetchedResultsController

Instead of using the usual

NSFetchRequest *request = [NSFetchRequestfetchRequestWithEntityName:@"SomeClass"];

which is prone to String typos, rather use

NSFetchRequest *request = [NSFetchRequestfetchRequestWithEntityName:NSStringFromClass([SomeClassclass])];

This is a neat way to tie the name of the class to the entity.

Of course you have to make sure that you have done the whole CoreData DataModel and create entity based on the entities created in the model.

Follow

Get every new post delivered to your Inbox.