Friday, August 1, 2014

Debian hangs at “Select and Install Software”

Recently, I wanted to use Debian 5.0.3 Lenny (for work).

The first step was to find the ISO.
I couldn't find it on the Debian website. Fortunately I could find it on these both sites: http://www.debiantutorials.com/download-debian-iso/
 http://cdimage.debian.org/mirror/cdimage/archive/5.0.3/i386/iso-cd/

After downloading the file debian-503-i386-netinst.iso (~150Mo), I'm ready to create a VM using VirtualBox.

The installation is easy but it freezes at the screen "Select and Install Software".

The way to solve this is the following:
  • start a new installation 
  • just before 'Select and install software.' I could see a popup about a warning. Press alt+F2 
  • press enter to activate the console 
  • run the command to place you into the system you are installing
    chroot /target
  • run the command to install the keyring
    aptitude install debian-archive-keyring
  • run the command
    aptitude update
  • run the 3 following commands
    gpg --keyserver pgp.mit.edu --recv-keys 6070D3A1
    gpg --armor --export 6070D3A1 | apt-key add -
    apt-get update
    
  • press alt+F1 to go back to the installer 
  • continue the installation as normal to the end 

And that's it !


Here is a quick link in case you want to cross compile:
http://wiki.micromint.com/index.php/Debian_ARM_Cross-compile

source: http://forums.debian.net/viewtopic.php?t=12259

Wednesday, July 30, 2014

cross-compile ncurses for ARM: ARMEL & ARMHF

First, make sure you have installed these packages:

# ARMHF
sudo apt-get install gcc-arm-linux-gnueabihf
sudo apt-get install g++-arm-linux-gnueabihf
# ARMEL
sudo apt-get install gcc-arm-linux-gnueabi
sudo apt-get install g++-arm-linux-gnueabi
Make sure you did the following command and that "gcc" is in your path
sudo apt-get install build-essential

Download ncurses:
wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz

Extract ncurses:
tar -xzf ncurses-5.9.tar.gz

Go to the folder:
cd ncurses-5.9

And build ncurses:
#ARMEL
./configure --host=arm-linux-gnueabi --prefix=/usr/arm-linux-gnueabi CXX="arm-linux-gnueabi-g++"
#ARMHF
./configure --host=arm-linux-gnueabihf --prefix=/usr/arm-linux-gnueabihf CXX="arm-linux-gnueabihf-g++"
make
sudo make install

 Done!

Then you should see libncurses.a with this command:
ls /usr/arm-linux-gnueabi/lib
ls /usr/arm-linux-gnueabihf/lib

Saturday, September 14, 2013

VirtualBox is slow !

So my host OS is Windows 8 and I wanted to separate my everyday stuff from my projects (coding) stuff.
I created a virtual machine, guest OS is Linux Mint.
My PC is: intel i3570K, 8GB DDR3, 64SSD + 128SSD, Asus Z77. Not a bad one!

Problem

So when I was in Mint, it was kind of slow.

 In settings > System > Processor, I had only 1 processor and when I selected 2 processors, I could see a warning message saying something like "this is not the most efficient setup". I ignore this message and in settings > System > Accelation, I checked "Enable VT-x/AMD-v".
When I start my virtual machine, I add an error message and the machine didn't start at all.

Solution

After searching on the Web, I found out that I had to go to the bios and activate a feature.
I don't remember exactly the name of the feature (and I guess it depends of the motherboard), but it was in the CPU section, and the feature was like "activate virtualization something".

After activating it, I could select 2 CPU and now my virtual machine is not slow anymore!

And that's it!

Thursday, May 30, 2013

imageMagick on mac os

Recently, I'm working on a mac os, creating a website using Rails.
I want the user to be able to upload a picture as an avatar. I found excellent
information on Internet. The most popular library is probably Paperclip (https://github.com/thoughtbot/paperclip).
Paperclip is intended as an easy file attachment library for Active Record.


After installing Paperclip and  ImageMagick (with brew), I added the code in my model :
attr_accessible :avatar, :name
has_attached_file :avatar, :styles => { :medium=>"300x300>", :thumb => "100x100>"},
  :url  => "/assets/restaurants/:id/:style/:basename.:extension",
  :path => ":rails_root/public/assets/restaurants/:id/:style/:basename.:extension"

It's exactly like in the wiki page of Paperclip (nothing fancy).

Problem :
But when I tried to upload an image, I had this error :
 ... is not recognized by the 'identify' command.

On Internet, many people said to do:
which identify
#/usr/local/bin/identify
And then add in config/environment.rb:
Paperclip.options[:command_path] = "/usr/local/bin"

But this didn't work for me.
If I just tried the command "identify", I could see this error :
dyld: Library not loaded: /usr/local/lib/libtiff.3.dylib
  Referenced from: /usr/local/bin/identify
  Reason: image not found
Trace/BPT trap: 5

So I was thinking there is a problem with the file "libtiff.3.dylib".

Solution :
I copied the file libtigg.3.dylib :
from : /opt/local/lib/libtiff.3.dylib
to : /usr/local/lib/libtiff.3.dylib

I restarted my rails server, and now it's working !
It's probably not the best solution, but at least it's working so far.
I think ImageMagick is looking for the file libtiff.3.dylib in a wrong folder.
Maybe if I could modify ImageMagick config file and change to the good folder, this
would be a better solution.

And that's it !

Monday, March 4, 2013

Twitter bootstrap rails could not find in any of the sources

For my website, I'm using Twitter Bootstrap and it is cool !
So easy to use and my website have a nice look.

I'm using the gem Twitter-bootstrap-rails.
It is working great on my development environment. I followed the step by step and added this to my Gemfile:
gem 'twitter-bootstrap-rails'

Problem
When I deploy on production, I have to do "bundle install". No problem, everything is installed. But when I start the server I have this error:
Could not find twitter-bootstrap-rails-2.2.0 in any of the sources

A little bit surprised, because "bundle install" was ok, and I can see the gem.

Solution
In fact, my Gemfile should look like this:

gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'

I don't know if the latest build fix this problem or if it's using Git, but it is working!

And that's it!

Tuesday, February 19, 2013

Paperclip order of params

In my website I'm using Paperclip to take care of the attached files.

I have a model "image" who has many "collections".
A "collection" belongs to a "resolution".

I'm displaying the form of an image with a list of available resolutions.

In the model Collection:
has_attached_file :picture,
    :url => "...",
    :path => "...",
    :styles => { :custom => Proc.new { |col| "#{col.resolution.width}x#{col.resolution.height}" }}
   }}

Problem
When an image is updated, the Proc is executed and I have a "nil" exception.
I'm wondering why "resolution" is nil because the params contain a resolution_id.

Solution
In fact, it depends of the order you pass the parameters.

At first, the view was like this :
= f.file_field :picture
= f.hidden_field :resolution_id

But I should do like this:
= f.hidden_field :resolution_id
= f.file_field :picture


The "resolution_id" should be first !
By doing so, Rais is creating the relation between "resolution" and "collection" first, and then he is applying the style.

So, sometimes the order of the params is important!

And that's it!

Edit
Too bad for me, in fact the order is not sure... It is working on my development environment, but not in my production environment...

Friday, February 15, 2013

Rails default_scope delete

I have a model called User with a default_scope where('deleted_at is null'), because I'm using some kind of "soft delete".

Problem:
I want to delete an object who has been soft deleted.

First, I create an object :
user = User.new

Then I soft delete it:
user.soft_delete
# this set deleted_at = Time.now

Then I want to delete it:
user.delete
# nothing happen !
# the query looks like this: delete from users where id = 1 and deleted_at is null

Solution:
I can think about 2 solutions:

1) Is to execute sql code directly:

ActiveRecord::Base.connection.execute("delete from ...");

2) Use "unscoped"
User.unscoped.where(:id => 1).delete_all

And that's it!

If you know a better solution, please let me know