Monday, October 28, 2013

Installing SeedDMS Opensource DMS in Debian / Ubuntu


SeedDMS is a very useful opensource document managament system. To install SeedDMS we need to install first a couple of package in our Debian / Ubuntu.

1) Solving dependences.

sudo  aptitude install php-pear
aptitude install php-http-webdav-server

wget http://sourceforge.net/projects/seeddms/files/seeddms-4.0.0-pre5/SeedDMS_Lucene-1.1.1.tgz
wget http://sourceforge.net/projects/seeddms/files/seeddms-4.0.0-pre5/SeedDMS_Core-4.0.0pre5.tgz
wget http://sourceforge.net/projects/seeddms/files/seeddms-4.0.0-pre5/SeedDMS_Preview-1.0.0.tgz
pear install SeedDMS_Core-4.0.0pre5.tgz
pear install SeedDMS_Lucene-1.1.1.tgz
pear install SeedDMS_Preview-1.0.0.tgz

2) Install Log using pear
wget http://download.pear.php.net/package/Log-1.12.7.tgz
pear install Log-1.12.7.tgz

3) Donwload seeddms in our apache root server (or other web location)
wget http://sourceforge.net/projects/seeddms/files/seeddms-4.0.0-pre5/seeddms-4.0.0-pre5.tar.gz
tar -xvzf seeddms-4.0.0-pre5.tar.gz

4) Create a mysql user with privilages:
create database seeddms;
grant all privileges on seeddms.* to seeddms@localhost identified by 'secret';
 
5) Create the file ENABLE_INSTALL_TOOL in the folder conf
touch ENABLE_INSTALL_TOOL

6) Access to the web URL, for example: 127.0.0.1/seeddms/install/install.php to start the automatic installation process. Fill out the form and continue.

7) If everything is ok you will receive the  message: "The installation has been successfully completed."
Delete the file  ENABLE_INSTALL_TOOL  and access to your new DMS with the default login admin/admin.

Hope help!

Bye




Tuesday, May 7, 2013

Split A3 2 slides PDF into a A4 using ghostview and pdftk

What we need

One new question is how to split a 2 pages/side PDF into a simple page per side. To start we need a list of free tools:

  • ghostview - To extract and split the pages
  • pdftk - To merge the generated documents into one

For the example I will use a A3 document with page size (595.22x842) as we can see in the last section.

Extracting odd pages

We will use the next command

gs -o left-sections.pdf -sDEVICE=pdfwrite -sPAPERSIZE=a4 
-c "</PageOffset[0 0]>> setpagedevice" -g5950x8420 -f input.pdf
> setpagedevice" -f input.pdf

where 
-o output file
-sDEVICE is the type o file we create
-sPAPERSIZE
-g is the page geometry (page size)
-c crop the page according with [x,y] and the geometry of our page

Extracting even pages

We will use the next command

gs -o right-sections.pdf -sDEVICE=pdfwrite -sPAPERSIZE=a4 -g5950x8420 -c "</PageOffset[421 0]>> setpagedevice" -f input.pdf

How to extract a range of pages

We can use ghost view again as follow:
gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=10 -dLastPage=20 -o left-sections.pdf -f tmpleft-sections.pdf
to extract pages from 10 to 20.

How to merge the two documents into one

The command we can use is pdftk:

SORT=""
PAGE="1"

while [ $PAGE -le $PAGES ]
do
        SORT=$SORT"A"$PAGE" B"$PAGE" "
        PAGE=$[$PAGE+1]
done

echo $SORT 
pdftk A=right-sections.pdf B=left-sections.pdf cat $SORT output mergedoc.pdf  verbose

How to know the geometry of the document (page size)

The easiest way is using the command pdfinfo. For example:
# pdfinfo tabebak.pdf 
Title:          .indd
Author:         xxxx
Creator:        PScript5.dll Version 5.2.2
Producer:       Acrobat Distiller 8.0.0 (Windows)
CreationDate:   Sat Jan 12 10:21:09 2013
ModDate:        Sat Jan 12 10:21:09 2013
Tagged:         no
Form:           none
Pages:          27
Encrypted:      no
Page size:      595.22 x 842 pts (A4)
Page rot:       90
File size:      7782888 bytes
Optimized:      yes
PDF version:    1.4
We can extract more information into variables using for example:
WIDTH=$(pdfinfo $1 | grep -i "page size" | tail -n 1 | awk '{ print $3 }')
HEIGHT=$(pdfinfo $1 | grep -i "page size" | tail -n 1 | awk '{ print $5 }')
PAGES=$(pdfinfo $1 | grep -i pages | tail -n 1 | awk '{ print $2 }')

UIWebview. How to call javascript functions from objective-c

I wrote about this long time ago but only to remember how simple it is.

1) Write the javascript function in your HTML file

function callMePlease () {
    // Your code here
}


2) Use this line to call the function from Objective-C using your  UIWebView object.
[webview stringByEvaluatingJavaScriptFromString:@"callMePlease()"];

For example if we only want to execute some javascript code in our webview we can use:

NSInteger pos = 100;NSString* s=[[NSString alloc] initWithFormat:@"window.scrollTo(%i, 0)",pos];[webViewMenu stringByEvaluatingJavaScriptFromString:s];

If we want to call a Objective-C function from our JavaScript code... things are a little bit more difficult:

1) In Objective C we must have

- someFunctionOnInit {
    
    webView = [[UIWebView alloc] init];
    // Register the UIWebViewDelegate in order to shouldStartLoadWithRequest to be called (next function)
    webView.delegate = self;
    
}

// This function is called on all location change :
- (BOOL)webView:(UIWebView *)webView2
shouldStartLoadWithRequest:(NSURLRequest *)request
 navigationType:(UIWebViewNavigationType)navigationType {
    
    // Intercept custom location change, URL begins with "js-call:"
    if ([[[request URL] absoluteString] hasPrefix:@"js-call:"]) {
        
        // Extract the selector name from the URL
        NSArray *components = [requestString componentsSeparatedByString:@":"];
        NSString *function = [components objectAtIndex:1];
        
        // Call the given selector
        [self performSelector:NSSelectorFromString(functionName)];
        
        // Cancel the location change
        return NO;
    }
    
    // Accept this location change
    return YES;
    
}

- (void)myObjectiveCFunction {
    
    // Do whatever you want!
    
}

There are another ways to do the same but it is enough for today. For more information check this.


Cheers

Sunday, May 5, 2013

Icon sizes for iPhone & iPad


I decided to recompile some information about the sizes and names of the icons we need when we create an App.

Review of Icon Sizes

Image Description iPhone iPhone Retina Display iPad iPad Retina Display iPhone5
Application Icon Icon displayed on the device’s home screen, used to launch an application. 57x57 114x114 72x72 144x144 114x114
Settings Icon Icon used to identity an application in the iOS Settings Application. 29x29 58x58 29x29 58x58 58x58
Spotlight Search (uses same image as Setttings on iPhone) Icon used to identify an application in the Spotlight Search results. 29x29 58x58 50x50 100x100 58x58
iTunes Image Large image used by iTunes during ad hoc distribution. 512x512 512x512 512x512 512x512 1024x1024
Launch Image Image used as a placeholder screen while the application loads. 320x480 640x960 Portrait: 768x1004 Landscape: 1024x748 Portrait: 1536x2008 Landscape: 2048x1496 640x1136

iPhone Launch Images

Device Target File Name Size (in pixels)
iPhone 3GS Default.png 320x480
iPhone 4 Default@2x.png 640x960
iPhone 5 Default-568h@2x.png 640x1136

iPad Launch Images

File Name Size (in pixels) Use
Default~ipad.png

Default@2x~ipad.png
768x1004

1536x2008
This is the basic loading image that is used if a more specific image is not available. If no more specific images are supplied, this should be present.
Default-Portrait~ipad.png

Default-Portrait@2x~ipad.png
768x1004

1536x2008
This is the generic portrait-loading image. This image is used for right side up (home button on bottom) portrait orientations and takes precedence over Default~ipad.png. Therefore, if you supply this image, Default~ipad.png is not used. Additionally, if Default-PortraitUpsideDown~ipad.png is not supplied, this image is used.
Default-Landscape~ipad.png

Default-Landscape@2x~ipad.png
1024x748

2048x1496
This is the generic landscape-loading image. This image takes precedence over Default~ipad.png. Therefore, if you supply this image, Default~ipad.png is not used. Additionally, if Default-LandscapeLeft~ipad.png or Default-LandscapeRight~ipad.png is not supplied, this image is used.
Default-PortraitUpsideDown~ipad.png

Default-PortraitUpsideDown@2x~ipad.png
768x1004

1536x2008
This is the portrait upside-down (home button on top) loading image.
Default-LandscapeLeft~ipad.png

Default-LandscapeLeft@2x~ipad.png
1024x748

2048x1496
This is the landscape left (home button on left) loading image.
Default-LandscapeRight~ipad.png

Default-LandscapeRight@2x~ipad.png
1024x748

2048x1496
This is the landscape-right (home button on right) loading image.

Newsstand Icons

The aspect ratio of all Newsstand icons should be between 1:2 and 2:1. In addition, all Newsstand icons must be flat and have 90° corners.
Description
iPhone 5 
high-resolution iPhone 
iPhone iPod touch
high-resolution iPad
iPad
Guidelines
App icon (required for all apps)114 x 114114 x 11457 x 57144 x 14472 x 72“App Icons”

UITabBarItem Icons

If your want to create an Icon for the UITabBarItem you must consider the next steps:
  1. Image -> Mode -> Grayscale
  2. "Discard color information" -> Discard
  3. Mark all [cmd A]
  4. Copy [cmd C]
  5. Layer -> Layer Mask -> Reveal all
  6. In "Chanels" (Window -> Chanels) show the "Layer 0 Mask" (click on the left)
  7. Paste [cmd V]
  8. Image -> Adjustment -> Invert [cmd I]
  9. Save for web [cmd alt shift S] as PNG 24
using the Icon size of 30x30 pixels for iPhone and double for retina display 60x60 pixels.

In general, when you are supplying a retina image you should name it with [name]@2x~iphone.png or [name]@2x~ipad.png. Then, in the IB you should put the name of the file without the whole suffix, so just [name] instead of [name]@2x~iphone.png. The image won't show up in the IB, but should be ok in the live app.

Saturday, April 20, 2013

How to change the MAC Address for Mac OS X Mountain Lion

Creating a random MAC Address
A MAC address is always in the format xx:xx:xx:xx:xx:xx. If you want to generate randomly a new MAC Address you can use the following command using openssl:
openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'

Setting up the new MAC

In Mac OS X the network interface usually is en0 or en1.  The command for changing the MAC address is as follows:
sudo ifconfig en0 ether xx:xx:xx:xx:xx:xx
replacing “xx:xx:xx:xx:xx:xx” with the new MAC address. For example:
sudo ifconfig en0 ether 36:81:51:8e:f1:76

Hope help

Wednesday, January 16, 2013

How to execute python matplolib pylab from PHP

Hey people and Happy new year,

It's crazy try to execute python pylab from an script PHP. After several hours looking for a solution I got it.

If we want to exec a python script from PHP which imports the matplotlib it's necesary to add a couple of extra lines to our code.

# To import pylab
os.environ[ 'MPLCONFIGDIR' ] = '/tmp/'
import matplotlib
matplotlib.use('agg')
import pylab

Before testing your script from the server try to do it on the terminal:

sudo -u www-data php script_name.php

It works for me.

Note: If you want to download and compile matplotlib by yourself, you can download it from:

wget https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.1.1/matplotlib-1.1.1.tar.gz

Decompress , build and execute as root the command:

python setup.py install

Hope help!