Tuesday, October 25, 2016

How to create PDFs from images in Mac OS

Creating a PDF from images as daunting it may seem, is quite easy to do in a Mac. It comes with a PDF creator which can be accessed from the print menu.
The simple steps are as follows:

  1. Select all the images that you want in the PDF by pressing Command while selecting, and right click to open with Preview.
  2. If you don't see the sidebar with thumbnails, click View -> Thumbnails.
  3. Reorder the thumbnails, as you would like them to appear in the PDF.
  4. You can also add additional images by dragging them to the thumbnail sidebar.
  5. Click File -> Print.
  6. In the bottom left corner you will see a Menu labeled PDF.
  7. Click the label to open the menu, and select "Save as PDF."
  8. Now you can save the pdf with an appropriate name at an appropriate location.
That's it!

Saturday, October 22, 2016

XCode Objective-C custom frameworks and iOS 10

There are two kinds of frameworks, those that come with XCode and those that you create on your own. Those that come with XCode can be used without any special steps, albeit the headers, but the other ones need special configuration, and there are two ways to it:
First, Drag the framework package, e.g. somelib.framework, to the Frameworks folder of the project and choose to copy the framework to the project and you are done. The problem with this approach is that the framework is "copied" to the project, so any changes that you may do to the framework in its own project, and new builds would not be reflected immediately and automatically in the dependent project. You will have to copy again and again for every change that you make.

Second, Add the framework package by drag 'n' drop, but do not copy. You can access the framework in XCode, but the linker will throw an error, stating the framework is missing. It's because the XCode does not take an additional step that it definitely should, and that is to add the framework's path to Framework Search Paths automatically, which you will have to do manually.

To add the path, select the target and go to "Build Settings." Scroll down to find the section labeled  "Search Paths". Under that you will find "Framework Search Paths". When you double click on the blank space on the right, it will open up a list with (+) and (-) buttons. Add the (+) button and add the path to the folder in which the framework is located, and you are good to go. Now the linker will link without throwing an error.

For iOS 8 and later, there would be a runtime error about missing library, stating, "dyld: Library not loaded ... Reason: image not found." This can be fixed by selecting the target and going to "General." After scrolling down, you should see a section labeled "Embedded Binaries." Press the (+) sign, and add the framework in question, and your app should not crash. That's it.

Tuesday, July 24, 2012

Using wxMaxima

wxMaxima is a good simple alternative for an application like Mathematica, and works well.

A few things :
  1. Use Ctrl+Enter to execute statements
  2. To define a variable x with value 1234, do
    x : 1234
  3. To undefine, remove, or unset, a variable use
  4. If the results are too long they would be shortened to a certain length with output like 347746739180370201052517440604[198 digits]155521811399837428754848, which is not much useful. To get the whole output, do
    To reset back to original, do
  5. To always get a numeric floating point output (there will be other complications), set
    numer: true
More to come soon.




Wednesday, August 11, 2010

apache2, mod_rewrite, SCRIPT_URL

Recently I moved my localhost website to a virtual host, and was unable to understand the reason for missing SCRIPT_URL in the $_SERVER variable in PHP. The problem was that I forgot to insert the rewrite rule in the vhost, and the SCRIPT_URL is dependent on the rewrite engine.

So, if you are not able to find SCRIPT_URL documented in PHP, check to see if you have rewrite engine on in your website definition.

Saturday, March 06, 2010

Webcam and Ubuntu karmic koala

It is a challenge to be able to use a webcam if you do not know the right tools. Since almost none of the webcams come with a software for the Linux platform, one really does not get the nifty (most of the times bulky) software interface to control and configure the webcam.

To test if your webcam is recognized and running, run VLC and select Media>Open Capture Device and simply click Play.

If you can see the output in the player, you have a successfully recognized and running webcam. Otherwise check for support for your webcam. Following URLs will come handy:

Now exit VLC, before installing running another webcam software.
To adjust the settings on your webcam install luvcview :

> sudo apt-get install luvcview
> luvcview

Even though you can choose the frame rate for your webcam, the output would not have it in low light conditions, especially if your exposure is set to auto. Set your exposure to non auto, and increase the value of exposure, thus lowering it, and you should have the desired frame rate. One can record the video in this software, but it is audio-less.

Once you set the values in luvcview, it will be remembered, and followed in other applications as well.

To record video try cheese:
>sudo apt-get install cheese

Cheese records in vob format.

That's it. Skype has very good support for webcams in Linux now, and so does Ekiga.

Sunday, December 13, 2009

Some algo fun

Well, I was trying to figure if a user could be given a pass code of length 40, and split in pieces for ease, I ended up dealing with numbers and so many calculations, that I finally made an algorithm and wrote it down in JS. The code is as follows:
//uses Firefox Firebug

var n = 1;

var s = 1202;

var m = 1;

while((s-n)/(n+1) >= 1 && n <= m) {

m = (s-n)/(n+1);

console.log('dashes = '+n);

console.log('chunksize = '+m);




Some results to consider:

String Length

Number of dashes

Split length










Tuesday, December 08, 2009

Nautilus auto-mount with long disk id

Since Ubuntu 9.05, the free partitions are mounted with their disk id in Nautilus, which is not very convenient.

An easy and simple solution is to create a label for that partition, and then Nautilus mounts it with that label, making it easy for future use, and even if one formats the partition causing its id to change, setting the label will fix the problem immediately.

For ext2, ext3, and ext4, one can use e2label, and mtools for vfat partitions.

It is very convenient when one has multiple programs pointing at that same partition, and its id has changed.