Wednesday, 12 March 2014

LINUX and WINDOWS in dual-boot mode on SSD+HDD

After many days of work I have finally managed to figure out  how to install Windows 8 & Linux in dual-boot mode on SSD+HDD with UEFI Bios system.

My plan was this: install Windows & Linux onto Samunsug Evo SSD (126gb) and use HDD as "data" for either systems. The combination  of UEFI Bios and Windows 8 produces an armored system that prevents installation of all other type of operatives system (like linux). So it is necessary to break this useless "armored" system.

As first thing you must enter in Bios (with F2 or Esc, the key depends on your machine) and disable the Secure Boot option, FastBoot (or something similar) and enable CMS (compatibily mode system). These options can have  different acronyms, it depends on your bios (I have an Asus s56cm ultrabook). Now, you are able to boot into a linux live-usb. The next move consists in partitioning your system.

I've started from a clean situation: both SDD and HDD  have been formatted. I've created this partition scheme (I've used gparted):
  • SSD with two partitions: the first formatted as an NTFS file system (Windows parition) and the second with ext4 (Linux partition).
  • HDD without any partition: only unallocated memory space (the reason for this move will be explained soon).
Now is time to install Windows. Windows doesn't allow the user to decide how to manage the partitions of their operative system. For this reason I've left the HDD with unallocated memory space: in this way, Windows will not use the HDD for its obscure decisions. So, during the installation, you must tell windows to use the first partiton of the SSD. If all goes well, windows should have only used  the first partition to store every part of its system (including the boot manager). The next step consists in install Linux (debian distro like Ubuntu or Linux Mint).

Fortunately Linux doesn't hide any particular "obscure mechanism". So it is simple to install. Firstly it is necessary to create two partitions on HDD: one for the swap and the other for the "home" folder (you must leave enough space to create another partition to use for windows data). Now we proceed to install linux. The second partition of SSD will be used to install the "root" of linux while the partition of HDD will be used as "home partion" as indicate above.

ATTENTION: you must install the grub into the SSD and not into its partitions!!!!! For example : dev\sdb and not dev\sdb1.

Now you can click on the install button. Good. If everything has gone according to plan you will find yourself in four scenarios:
  • First: the pc will boot only into Windows OS.
  • Second: the pc will boot only into Linux.
  • Third: the pc will not boot anything (Some kind of grub error has happened).
  • Fourth: You can dual boot windows and linux (GOAL STATE).
Don't panic. Nothing is impossible. We'll analayze the first scenario. If you have the scenario indicated on first point, you must follow this guide to re-install grub from a linux-live-usb: https://help.ubuntu.com/community/Boot-Repair ( remember: install grub into the root of SSD). If everything has gone well you will be able to dual-boot Linux and Windows. If everything hasn't gone well check into the bios if the right device boot is selected. It can happen that the bios boots with a device that doesn't have a grub installation. If you still have problems , follow the next lines.

From a terminal on linux-live-usb insert the following commands (I've taken the code from https://help.ubuntu.com/community/Grub2/Installing):

sudo mount /dev/sdXY /mnt # Example: sudo mount /dev/sda5 /mnt
sudo grub-install --boot-directory=/mnt/boot /dev/sdX # Example: sudo grub-install --boot-directory=/mnt/boot /dev/sda

Where "X" corresponds at the SSD position into the system (i.e mine is sdc). Now, reboot the system and finally (I hope) you are able to dual boot Linux and Windows. You might see the grub menu you see only in linux options, so you can't boot the windows system. To fix this problem, follow the following lines.

Troubles of this kind are generated from the Windows partitioning table. Windows uses the GPT partition table to install its operative system and it seems that grub doesn't recognize (when you install the grub) the GPT partition.
From linux-live-usb we will modify the grub with "hand-mode" (In my opinion it is the best way). So, from the terminal put the following commands (I've taken these code snippets from this thread http://askubuntu.com/questions/210914/grub-does-not-show-a-windows-8-option-after-dual-boot):

sudo nano /etc/grub.d/40_custom
then insert the following lines (into nano editor):

menuentry "Windows 8" {
    set root='(hdX,gpt1)'
    chainloader /EFI/microsoft/BOOT/bootmgfw.efi
}
where X is the partition of windows into SSD (In my case, SSD is sdc and it is the third disk in my system, so hdX become hd2, numbering is starts from 0,1,2... ). Now save the file and close the document. And update the grub with the command (always into the terminal):

sudo update-grub

Reboot the system and finally you are able to dual boot Windows and Linux!

Tuesday, 19 November 2013

Read or write from file inside a jar! What hell!

In my last "session" of java code I found myself in this problem: I must read and write from a file inside a jar. In detail i have a project that using this jar and from this project I must to interact with file.
Initially I thinked "oh it will very easy" but how wrong I was. The first problem is this:
How I can reference to file inside a jar? 
We must think that we cannot reference with an absolute or machine path: the project can be runned in hundreds of machines with hundreds of difference paths. So we must use a internal project path. Good. As first thing, read from this file. Java provides a fantastic method that which allows us to get an input stream from file with ponly passing as a parameter the name of file without the absolute path. For example: if my file inside jar has this name "pippo.txt" i can get an InputStream with this method:
getClass().getClassLoader().getResourceAsStream("pippo.txt")
To read the file,do this:
 InputStream stream = getClass().getClassLoader().getResourceAsStream("pippo.txt");
 String sCurrentLine;
BufferedReader br = new BufferedReader(new InputStreamReader(stream ));
          StringBuilder string = new StringBuilder();
while ((sCurrentLine = br.readLine()) != null) {
string .append(sCurrentLine);
}
string.toString();
Easy right? :)
But if I want to write inside a jar? This is a almost "impossible" task. You must think that a file inside a jar is as a file inside a .zip or .rar. Can you write a file inside a compress file? Yeah! But you must unzip the file, write the file and compressagain the entire package. In the same way works a file inside a jar. First you must extract all content of jar file, second you must write into file and third you must re-create the jar file and all of this operation you must do into your java code. It is an hell!
Usually the files inside a jar are a properties files: file that can be read and writed from other classes. But these files are special files: their are not a common files.  If you think that for your application there is a file that can be write as text file, you should think a way to create this file outside of jar. For example you can say to a class inside a jar to produce a file at runtime execution to  store in file system , save the path of file (you cannot save it on jar for the same problem described above: you cannot write inside a zip file.)and then the project that used this jar can ask to class to retrieve the path of this file and finally he can modify it.

Monday, 14 October 2013

My Android device as Remote Control!

Last night  I was watching Iron Man 3 on my computer, ehmmm no, my computer was connected on  tv and I was watching Iron Man on my tv. While I was watching my film, a whatsapp notification came out from my telphone!

DAMN! I MUST STOP THE FILM! I MUST TO GET  UP FROM MY CHAIR!

So I thought to myself "mmmmm probably there is some program to use my telephone as a remote control for VLC player on my computer" and then I found it! In the next few line I will explain as transforms you android device in a remote control.

First : your device and your computer must be connected at the same wi-fi connection. You must have vlc player on you computer, download it from http://www.videolan.org/vlc/ and you must download on your android device this program https://play.google.com/store/apps/details?id=org.peterbaldwin.client.android.vlcremote&hl=it . 


Now, after you have installed VLC on you computer, open it and go under Tools->Preferences. 
In the bottom right corner select "all" in show settings box. In " Interface" voice, click on "Main Interface" and select only "web" on "Extra Interface Modules". Click on triangle icon on "Main Interface" and click on Lua. Insert password on Lua http box. Save and restart VLC. 

Open a Windows Shell ( insert cmd on search program on windows) and insert ipconfig. Get your ip address,we will use after.If you have some problem to find your ip check the image.



From android device, open VLC remote and click on Add VLC Server. Now insert into dialog box ,the ip adress that you have find before and hit ok and insert the password into password dialog box that will open.
Well, now you can control your vlc from your CHAIR!

Monday, 7 October 2013

Export variable Java Linux! I see the light!

Why you don't find java or javac command in my terminal? I suppose  you have installed it, then because you don't find it? Maybe some malignant entities into your computer has removed java or maybe not.....where is the light in all of this?

It is simple! YOU MUST EXPORT JAVA_HOME! Java has an home? cool! 

Let's do it!

(This process set permantely your java variable into your computer)

  1. Open terminal in linux.
  2. If you don't know where is java is located, write in terminal: whereis java. A possible set of results can be:
    Save path that ending with ..../bin/java
  3. Now, write in your console: sudo nano /etc/profile and write at finsh of file these line:
    and instead of /home/lorenzo/Documenti/jdk1.7.0_25/bin insert the path, without the final words /java, that you have saved it before.
  4. Hit ctrl+o and press enter and hit ctrl+x.
  5. Write in console source /etc/profile 
  6. And work is complete!
FINISH HIM! (ehmm take out MortalKombat...)

Saturday, 5 October 2013

Damn! How to set image in a landscape mode into Lyx.

Ok. Finally i've discovered the magic formula to set a image in landscape mode into lyx, with custom margin.

The ingredients are these: 
  1. Modify Document preamble: go to Document->Settings->LaTextPreamble and add: 
    \usepackage{pdflscape}
    \usepackage{changepage}
    \usepackage{anysize}
  2. Before you insert the image, add a LaText box code (or hit CTRL+L) and insert: \marginsize{3cm}{2cm}{0cm}{1cm} % left rigth top bottom
    \begin{landscape}
  3.  Add Image (Insert->Image or Insert ->Floating Object and after, Insert->Image).
  4. Set image size: mouse right click on image and select Settings.
  5. After Image add another  LaText box code and insert: \end{landscape}
  6. Optionally: if you want change margin, add another time  \marginsize{3cm}{2cm}{0cm}{1cm} % left rigth top bottom with your preffered values.
This is the result: 

Friday, 27 September 2013

Lyx Program Listing cool style

Hello! While I was writing my thesis with lyx, I found myself to insert(to see to insert a box code, visit: http://stackoverflow.com/questions/2116944/insert-programming-code-in-a-lyx-document) a box contains a program code ( Java). Without options, the box code is very good, like:
It is nice, but if I want more style? In this document there are a lots of tricks to get our code box nicest http://ftp.uniroma2.it/TeX/macros/latex/contrib/listings/listings.pdf. To insert option configuration into box code, click with right click mouse into box code, and going to Settings->Advanced insert your options.

For example, to get this result : 






 


I have inserted these option: 

caption={Classe java Tripla}
emph={subject,predicate,object}
emphstyle={\color{blue}}
frame=shadowbox
keywordstyle={\color{violet}}
rulesepcolor={\color{gray}}

Try to believe!!

P.S. To enable all color into lyn, do this: go in Document->Settings->Latext Preamble and insert
\usepackage{xcolor}

Wednesday, 21 July 2010

Our Title

"Tinkering is what happens when you try something you don't quite know how to do, guided by whim, imagination, and curiosity.

When you tinker, there are no instructions — but there are also no failures, no right or wrong ways of doing things. It's about figuring out how things work and reworking them.

Contraptions, machines, wildly mismatched objects working in harmony—this is the stuff of tinkering.

Tinkering is, at its most basic, a process that marries play and inquiry."



From: www.exploratorium.edu/tinkering