Friday 21 February 2014

Dropbox Fails To Start


Past few days Dropbox have not started on my Linux computer, I'm running Ubuntu 13.10. When I try to start Dropbox manually by command line, I get this error:
$ dropbox start

Starting Dropbox...Traceback (most recent call last):
  File "dropbox/client/main.py", line 13, in 
  File "autogen_explicit_imports.py", line 13, in 
  File "ui/common/selective_sync.py", line 6, in 
  File "arch/__init__.py", line 28, in 
  File "arch/linux/tracing.py", line 8, in 
  File "hard_trace.py", line 6, in 
  File "client_api/connection_hub.py", line 21, in 
  File "client_api/kv_connection.py", line 23, in 
  File "pylinux/__init__.py", line 71, in 
  File "cffi/api.py", line 311, in verify
  File "dropbox/overrides.py", line 398, in load_library
  File "cffi/verifier.py", line 69, in load_library
  File "cffi/verifier.py", line 154, in _load_library
  File "cffi/vengine_cpy.py", line 124, in load_library
VerificationError: importing '/home/olig/pylinux/__pycache__/_cffi__xa0c4f46bx1d95b4de.so': No module named _cffi__xa0c4f46bx1d95b4de
To fix this, open a terminal CTRL+T and run the following commands
sudo rm -rf /var/lib/dropbox/.dropbox-dist
dropbox start -i

Extra

For more Dropbox command line options
$ dropbox help

Dropbox command-line interface

commands:

Note: use dropbox help command to view usage for a specific command.

 status       get current status of the dropboxd
 help         provide help
 puburl       get public url of a file in your dropbox
 stop         stop dropboxd
 running      return whether dropbox is running
 update       download latest version of dropbox
 start        start dropboxd
 filestatus   get current sync status of one or more files
 ls           list directory contents with current sync status
 autostart    automatically start dropbox at login
 exclude      ignores/excludes a directory from syncing
 lansync      enables or disables LAN sync


Installing LAMP (Linux, Apache, MySQL and PHP) On Linux

I'm running XLinux on my laptop and need to install webserver with php and MySQL, LAMP. (Linux, Apache, MySQL, PHP). Really thats a simple task, and I'm going do demostrate how

Step one, Install Apache

Open your terminal CTRL+ALT+T and enter following line.
sudo apt-get install apache2
Test Apache using this address in browser http://localhost/ and you will see a message saying:
It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet.

Step two, install PHP

sudo apt-get install php5 libapache2-mod-php5
Restart Apache
sudo /etc/init.d/apache2 restart
Now we can test php by adding to the terminal
sudo gedit /var/www/test.php
This will open up a file called test.php
Add following line
<?php
phpinfo();
?>
Open http://localhost/test.php in browser, you should see info about your php

Step three, install MySQL

Open the Terminal and then copy/paste or type this line
sudo apt-get install mysql-server
And it's done. You can now access your MySQL server like this
mysql -u root -p
--cheers
Friday 7 February 2014

How to create animated gif from video or images

There are many websites that generate animated gif from video for you, but most of them leave a watermark or logo on the gif. You can easily create your own and in this example we are going to use OpenShot 1.4.3 and command line tool, convert
First step is to select a video and edit it in OpenShot, select the part you like to animate and cut out everything else. If you already have sequince of images to use go strait to second step.
I selected very simple video only containing spinning dots.


To add files you can use CTRL+F and browse for file from there, or click on the "plus" sign. Next you drag the imported file down to the track part of OpenShot where you ca examine and cut the video. I selected ~2 sec to use of my video. Next you need to export the video, CTRL+E or the red circle. Now you can select where too and how. First select destination, I prefer to use new/empty directory.

Remember to set filename with leading zero; filename_%02d

Export 2
Export to "image sequence. Image format.
Now you might have some number of images.
Second step.
You should browse the images to see if the fit the loop you are aiming for. In my example I deleted first few and last few, leaving about 29 images.
The gif can get quite big, in that case see if you need to scale the images. My images are 720x480 px, and I like to scale the down to 45% of that size.


for file in *.png; do convert $file -resize 45% c-$file; done
Third step. After scaling the images it's time to create animated gif.
convert -delay 4 -loop 0 *.png my_animation.gif

Here is the final image.

Tuesday 4 February 2014

How to break out of iframe

There is a simple method I use to prevent pages on my website from being included through an iframe by another website. First I create one file no-iframe.js including
if (top.location!= self.location) {
 top.location = self.location.href
 }

Now you can add this to the header of any page of your website.
<script src="js/no-iframe.js" type="text/javascript"></script>

Now your site wont be "framed"