Marco Cattai

Senior iOS Software Engineer
VoucherCodes.co.uk (RetailMeNot)

iOS7 Style - Custom Layout for UICollectionView

- - posted in UICollectionViewLayout, iOS, objc, video | Comments



My last work is this custom UICollectionViewLayout that is similar to the iOS 7 application’s menu. I enjoyed a lot doing this interface. It is fully customizable.

Next step: I will insert the drag and drop feature and maybe when I will have time I want to write an article about it sharing the relative code on gitHub.

Marco

Information Retrieval: A Simple SPOTLIGHT

- - posted in Information, iOS, retrieval, spotlight | Comments

In this post I want to write about Information retrieval. Spotlight is a selection-based search system, which creates a virtual index of all items and files you want.

we must solve the following problem:

We have a lot of PDF described by the text they contain or also images/videos described using TAGS. Spotlight allow the user to quickly locate a wide variety of relevant items that contain , with high probability, the informations you are looking for.

We will use:

An Information Retrieval System (IRS). It is a system designed and built to perform tasks of Information Retrieval for big collections of documents, it ensures decription of documents and retrieval of those considered relevant to the needs expressed by the user ’s questions.

Linux - Snippets

- - posted in linux, snippets | Comments

Search all the files/folder with that name and remove them

1
 find . -name "FILE-TO-FIND"-exec rm -rf {} \;

Find all files having .bak (*.bak) extension in current directory and remove them:

1
  find . -type f -name "*.bak" -exec rm -f {} \;

Find all core files and remove them

1
  find / -name core -exec rm -f {} \;

Find all *.bak files in current directory and removes them with confirmation from user:

1
  find . -type f -name "*.bak" -exec rm -i {} \;

Find all pdf files and copy them in DestinationFolder:

1
  find . -type f -name "*.pdf" -exec cp {} DestinationPath \;

Searching


Search for pattern in files

1
   grep pattern files

Search recursively for pattern in dir

1
   grep -r pattern dir

Search for pattern in the output of command

1
   command | grep pattern

Locate file – Find all instances of file
Starting with the root directory, look for the file called filename

1
   find / -name filename

Starting with the root directory, look for the file containing the string filename

1
   find / -name ”*filename*”

Starting with the directory called dir, look for and list all files containing TextStringToFind

1
   grep TextStringToFind /dir

Create symbolic link link to file

1
   ln -s file link

Create or update file

1
   touch file

Places standard input into file

1
   cat > file

Display the file called file one page at a time, proceed to next page using the spacebar

1
   more file

Output the first 10 lines of file

1
   head file

Display the first 20 lines of the file called file

1
   head -20 file

Output the last 10 lines of file

1
   tail file

Display the last 20 lines of the file called file

1
   tail -20 file

Output the contents of file as it grows, starting with the last 10 lines

1
   tail -f file

Compression

Compression

Create a tar named file.tar containing files

1
   tar cf file.tar files

Extract the files from file.tar

1
   tar xf file.tar

Create a tar with Gzip compression

1
   tar czf file.tar.gz files

Extract a tar using Gzip

1
   tar xzf file.tar.gz

Create a tar with Bzip2 compression

1
   tar cjf file.tar.bz2

Extract a tar using Bzip2

1
   tar xjf file.tar.bz2

Compresses file and renames it to file.gz

1
   gzip file

Decompresses file.gz back to file

1
   gzip -d file.gz

Client-Server Communication. Intercepting Proxy

- - | Comments

It is helpful to see what each side, in a client/Server communication, sends or receives. There are two Unix tools that could be usefull in such situations:

– OWASP WEBScrab Project

WebScarab operates as an intercepting proxy, allowing the operator to review and modify requests created by the browser before they are sent to the server, and to review and modify responses returned from the server before they are received by the browser. It is able to intercept both HTTP and HTTPS communication.

– Paros (Mac)

Paros features request and response editing and automated scanning of Cross Site Scripting and SQL injection vulnerabilities

– NETCAT  Listen all TCP/UDP connections on a specific port

– cURL  send ‘fake’ requests to a server.

Listening to incoming requests


We start a listening server with

1
   nc -lk $ip $port

  • -l: listen
  • -k: forces nc to stay listening for another connection after its current connection is completed.
  • $ip: the IP/interface you want to bind to. Use 0.0.0.0 to bind to all interfaces and IPs.
  • $port: the port you want to bind to. Doesn’t really matter which one you use, as long as the client uses the same one to connect to.

1
   nc -lk 0.0.0.0 8080

 

Sending “fake” requests to a server

 

With CURL it is as simply as that:

1
   curl -v -i -X POST -d $data $uri

  • v: verbose
  • -i: include HTTP headers in the output
  • -X: HTTP request type. Defaults to GET if none given
  • -d: data

1
   curl  -v -i -X POST -d  '{"id":1,"action":"getRecord","params":{"clientVersion":"1.0.0.230","user":"kat"}}'

Control for
Interpolation - Extrapolation of Points.

- - posted in dll, net, visualstudio | Comments

This DLL allow you to draw points on a Cartesian plane. Points will be interpolated using linear interpolation or spline cubic interpolation (i will give you this interpolation only if you ask me, this version of software doesn’t have it). You can also change the value of a single point changing directly its value. You can enable or disable floating points or dicrete points visualization only selecting the option button. You can cancel points and you can ask for the extrapolation’s value of any point you need for any specific X value that you want.


Click here to download example.

3D GRAPH - Direct3D

- - posted in 3d, direct3d, directx, net, visualstudio | Comments

This Software allow, using a DLL that I realized in C#/Direct3D, to visualize a 3D Map. You can modify the graph using direct manipulation of the intersection points or using 2D section’s views. Below you can see images, video and a downlodable example that show how it works.

I developed this for my dissertation at university and it is used in more complex software I did in 2008. The component is not the original one I did for Aprilia, the interface is different and a lot of functionalities are missing here. The original software allow the correction of injection maps of a four stroke engine. It is used for the correction of injection maps of Aprilia RSV4 (Superbike team). This component was also a simple way to see the injection maps using a 3D View.









Click here to download the example.

MPI - Parallel Rotation

- - posted in 24bpp, C, MPI, PCX(ZSOFT), c, mpi, parallel, pcx, rs6000 | Comments

Parallel rotation on IBM RS/6000 SP



Programmed in C language, using MPI libraries. This is a parallel implementation of a rotation algorithm for 24BPP image in PCX(ZSOFT) format. i also implemented reader/writer for that format. Software finish always with success its execution according to settings in job’s file assigned to scheduler using loadLeveler management system. Test was executed highlighting the networking subsystem in the multicore environment IBM RS/6000 SP with image’s input of any dimension. Considered parameters in different executions are: - Different size of PCX images (800x600 - 1024x768 - 1191x893 - 2048x1536 - 4000x3000); - Different networking system (high performance switch or ethernet); - Different number of CPU. Remains invariant the angle of rotation for all the tests.

I also give you the code for the algorithm of rotation/scaling in standard version for one processor. It includes encoding/decoding for images PCX(ZSOFT) 24BPP. You can use the source file under Linux and compile it with gcc.

 

RotazioneMPI.pdf View this file