If you receive a file with 7z extension, it means the file is compressed using 7zip approach. The decoder is not available by default on Ubuntu.
So you need to install p7zip-full in order to be able to decompress it with the command: p7zip x file.7z
Hints & Tricks
I always forget the tricks I use for software installation or configuration. I will use this blog as a reminder.
Friday, June 8, 2012
Tuesday, June 5, 2012
Install magento on Ubuntu
- Download The latest version of magenta on: http://www.magentocommerce.com/
- Install zend: sudo apt-get install zend-framework
- Decompress the tar.gz file from magento you downloaded and copy it on /var/www/data
- Change the owner of the magento folder: sudo chown -R www-data /var/www/data
- Install addiditional libraries needed by magento: sudo apt-get install php5-gd php5-curl php5-mcrypt php5-mysql
- Restart apache to make sure the changes are applied: sudo /etc/init.d/apache2 restart
- Magento should be properly installed: go on http://127.0.0.1/magento and fill the wizard
You should arrive to a page asking for mysql credentials. if you did not install them already, follow these steps:
- sudo apt-get install mysql-server
- Follow the instructions and set the root password to the database
- Run mysql script: mysql --user=root --password=XXXX where XXXX is the password you specified in previous step
- Create the magento schema: create schema magento;
- Exit the script: exit;
Note: This is by no mean a production environment installation. It is just a technique to have the server up and running.
Tuesday, May 29, 2012
double conversion with GWT
During my photogrammetry project, I worked with java that was converted into javavascript with GWT and I found an interesting optimization to convert double into integers.
The three first items are well known and are common java. However as the project is compiled in javascript, we can use javascript specific language that can provide interesting options:
To convert a double into an int, there exists multiple approaches:
- Cast to int
- Math.floor
- Math.round()
- ~~x
- x | 0
- "~~x" will do a 2 binary not operations on the natural part of x. In other words, not(not(x)) will return the content of the natural part of x.
- "x | 0" will do a logical of the natural part of x with 0. In other words, or(x,0) will return the natural part of x.
Be aware that these functions only work if x is greater or equal to 0...
It seems pretty trivial, however, we can see here: http://jsperf.com/math-floor-vs-math-round-vs-parseint/39 that running ~~x or x|0 is often faster than Math.floor(x)...
You will ask how to perform such javascript trick in GWT: for this, we must use JSNI:
private static native int floor(double x) /*-{return ~~x;}-*/;
Monday, May 21, 2012
Listen on every interface with GAE
Add the line -a 0.0.0.0 on the server parameters and the server will listen not only on localhost but on all the interfaces.
Wednesday, May 9, 2012
apt-file is your friend
Have you ever wondered in which package a library was provided? I did.
Usually, I looked on google to understand in which package the file was located and often I finished with 5 packages installed whereas only one was needed. To solve this problem, apt-file exists:
The result is the following:
What does it mean? It means that 2 packages have the expected file: the first one is called libann-dev (What a surprise!) and the file I am looking for would be (when installed) in /usr/include/ANN/ANN.h. The second one is called libmadlib-dev and the file would be in: /usr/include/MAdLib/ANN.h
Usually, I looked on google to understand in which package the file was located and often I finished with 5 packages installed whereas only one was needed. To solve this problem, apt-file exists:
- First install it: sudo apt-get install apt-file
- Then, update it's database so that all the information is fetched in the repository:
sudo apt-file update
apt-file search ANN.h
The result is the following:
libann-dev: /usr/include/ANN/ANN.h libmadlib-dev: /usr/include/MAdLib/ANN.h
What does it mean? It means that 2 packages have the expected file: the first one is called libann-dev (What a surprise!) and the file I am looking for would be (when installed) in /usr/include/ANN/ANN.h. The second one is called libmadlib-dev and the file would be in: /usr/include/MAdLib/ANN.h
Sunday, May 6, 2012
How to check a jpg is corrupted?
The best way to analyze if a jpeg is not corrupted is to open it, but some times, it happens, that you have a bunch of files to check.
To perform it, you can run jpeginfo which will display an error message if there is a problem. To find all the images:
A small explanation is needed here:
In my case, the images were automatically generated so I do not care and I would actually love to delete them:
To perform it, you can run jpeginfo which will display an error message if there is a problem. To find all the images:
find . -name "*jpg" -exec jpeginfo -c {} \; | grep -E "WARNING|ERROR"
A small explanation is needed here:
- find . -name "*.jpg" : we look in the current folder for all the files containing jpg extension
- For each of these images we run jpeginfo -c "filename" (filename is automatically replacing the the curly brackets)
- From the previous result, we get all the strings containing WARNING or ERROR. Be aware that if the file name contains this string, it will be displayed
In my case, the images were automatically generated so I do not care and I would actually love to delete them:
find . -name "*.jpg" -exec jpeginfo -c {} \; | grep -E "WARNING|ERROR" | awk '{print $1}' | xargs rm
In this command, we use the same result as before:
- but we take only the first item of each line (which is the filename)
- We remove all of them using: xargs rm
How to convert a video into frames?
That should be simple to convert a video into frames (and it is as soon as we know which tool to use).
For this purpose, we need vlc in order to convert the video. If you are on Ubuntu:
Note: if you go on the terminal before running this command, ubuntu will recommend to install vnc-nox. This installation will not contain the image encoders so it is better to install vlc package with its dependencies
Now that we have the command available. Let's convert the video using the following command:
A few comments on what this command does:
For this purpose, we need vlc in order to convert the video. If you are on Ubuntu:
sudo apt-get install vlc
Note: if you go on the terminal before running this command, ubuntu will recommend to install vnc-nox. This installation will not contain the image encoders so it is better to install vlc package with its dependencies
Now that we have the command available. Let's convert the video using the following command:
cvlc --video-filter scene -V dummy --scene-format="png" --scene-ratio=24 --scene-prefix=test --scene-path=<folder> <path-to-video> vlc://quit
A few comments on what this command does:
- We use cvlc and not vlc as this command we want to run as a command-line utility and avoid opening a new windows
- --video-filter scene: informs vlc that we want to use the scene module
- -V dummy: to avoid opening a window to show the video
- --scene-format=png: describes that we want to export the images in PNG format
- --scene-ratio=24: determines that 1 frame every 24 must be captured
- --scene-prefix=test: every new image will start with the string "test"
- --scene-path=<folder>: the images will be created in the folder test
- <path-to-video>: the path containing the video
- vlc://quit: to make sure that the we leave the command-line when all the images have been converted
Subscribe to:
Comments (Atom)