Dedunu

  • Technology
  • Travel
  • Portable Drive encryption with Ubuntu

    I haven’t used encryption on hard disk drives or pen drives ever. But recently I got a requirement to encrypt some portables disks. And there are some limitations also. After encrypting you would not be able to use that drive on Windows Operating System. You are going to limit to the ext4 file system as well.
    First, you have to install cryptsetup to format your portable drive with encryption. To install cryptsetup run following command on a terminal.

    sudo apt-get install cryptsetup
    After that, you have to open Disk utility application. To open it just search on Unity dashboard like below.
     
     Then you will get a window like this.
    Click on “Unmount Volume”
    Click on “Format Volume”. Then you will get a new dialogue box like below. Select “Encrypt underlying device” option, before clicking the “Format” button.
    After that Disk Utility will ask for a pass-phrase to encrypt the device. Give a strong pass-phrase and don’t forget it! If you forget it, you will lose your all important and confidential data.
    Then wait till it formats the drive. This may take some time depending on your device capacity.
    After completing formatting you will get below the window.
    Most probably after formatting disk utility will automatically mount your disk without prompting for the password. When you are connecting encrypted disk next time, Ubuntu will prompt for the password like below
    Just type the pass-phrase and use your portable drive.
    But sometimes Ubuntu will prompt for the pass-phrase. When you are attempting to mount drive you will get below error.
    Unable to mount x.x GB Encrypted
    Error unlocking device: cryptsetup exited code 5: Device <UUID> already exists.
    There is a workaround for this bug. What you have to do first is closing all the applications which are using files on your encrypted device. Even the terminal windows you have to close.
    Then run below command on a terminal.

    sudo dmsetup remove /dev/mapper/<UUID>

    Change the UUID part according to your error message. If you are getting an error like below after running above command, please check whether there is an application which uses your encrypted device. If you have anything running please close it and run above command again!

    device-mapper: remove ioctl failed: Device or resource busy
    Command failed

    nn

    Tags

    nn

      n

    • Ubuntu
    • n

    • linux
    • n

    • ubuntu portable drive encryption
    • n

    • drive encryption
    • n

    n

  • Sri Lanka Cartogram with d3.js

    We have been using d3js to visualize things on maps. And after struggling with topojson application my boss found a way to convert Sri Lanka Shapefile (.shp) to topojson format. Then we wanted to use cartograms for our visualizations.

    nn

    I found that there was a d3js cartogram implementation. – https://github.com/shawnbot/d3-cartogram/

    nn

    With the help of this blog post – http://www.limn.co.za/2013/10/making-a-cartogram/, I finished cartogram Visualization. 

    nn

    And Nisansa’s co-ordinations for the center of Sri Lanka was very helpful to calibrate Sri Lanka map.

    nn

    You can find my sri-lanka-cartogram repository on GitHub – https://github.com/dedunu/sri-lanka-cartogram. 

    nn

    You find the live demo from here – https://www.dedunu.info/sri-lanka-cartogram/

    nn

    nn

    Thanks, https://github.com/mbostock for d3js library! He is a wizard in visualizations. Thanks a lot, https://github.com/shawnbot for cartogram.js! Hope this will be useful to you.

    nn

    Tags

    nn

      n

    • sri lanka cartogram
    • n

    • cartogram
    • n

    • sri lanka d3js
    • n

    • d3js
    • n

    n

  • Hadoop with Maven

    The last couple of days, I have been playing with Hadoop. Because of that, I couldn’t blog much often.

    nn

    I wanted to automated packaging with Maven. Below gist shows a sample Maven pom.xml for Hadoop.

    nn

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"n	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">n	<modelVersion>4.0.0</modelVersion>nn	<groupId>groupId</groupId>n	<artifactId>artifactId</artifactId>n	<version>0.0.1-SNAPSHOT</version>n	<packaging>jar</packaging>nn	<name>Name</name>n	<url>http://maven.apache.org</url>nn	<properties>n		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>n	</properties>nn	<build>n		<plugins>n			<plugin>n				<groupId>org.apache.maven.plugins</groupId>n				<artifactId>maven-jar-plugin</artifactId>n				<configuration>n					<archive>n						<manifest>n							<addClasspath>true</addClasspath>n							<mainClass>package.MainClass</mainClass>n						</manifest>n					</archive>n				</configuration>n			</plugin>n			<plugin>n				<groupId>org.apache.maven.plugins</groupId>n				<artifactId>maven-compiler-plugin</artifactId>n                                <configuration>n                                       <source>1.6</source>n                                       <target>1.6</target>n                                </configuration>n			</plugin>n		</plugins>n	</build>nn	<dependencies>n		<dependency>n			<groupId>org.apache.hadoop</groupId>n			<artifactId>hadoop-core</artifactId>n			<version>1.2.1</version>n		</dependency>n	</dependencies>n</project>n

    nn

    This will resolve Hadoop dependency and package it as a jar file. Hope this will help you!

    nn

    Gists

    nn

      n

    • https://gist.github.com/dedunumax/8416120
    • n

    nn

    Tags

    nn

      n

    • hadoop
    • n

    • maven
    • n

    n

  • Hadoop Mapper only MapReduce jobs

    It’s funny! You can have mapper only Hadoop MapReduce Jobs. This would be useful sometime when you need to change the structure of data. Otherwise, you can use this way when to want to filter out data. But I don’t think you will need this much often.

    The first file is a simple mapper which really does nothing. You can change it as you want. You can see in the main method job.setNumReduceTasks(0); line which set reduce tasks to 0. You can find Maven project on GitHub

    nn

    Tags

    nn

      n

    • mapreduce
    • n

    • hadoop
    • n

    • mapper only mapreduce jobs
    • n

    n

  • Installing Cisco Packet Tracer 6.0.1 on Ubuntu 13.10 (64-Bit)

    I have posted about Installing Cisco Packet Tracer on Ubuntu 13.04 and prior versions. But this method is not working on Ubuntu 13.10 because of a repository issue, I think. Medywan posted a link. I followed the link and found a new way. But it was not in English, so I translated it.
    Thanks to the author who posted it first: http://www.be-root.com/2013/11/19/installation-de-cisco-packettracer-6-sur-ubuntu-13-10-64bits/ Credit should go to him!

    Run those commands in the terminal first.

    sudo dpkg --add-architecture i386
    
    sudo apt-get install libnss3-1d:i386 libqt4-qt3support:i386 libssl1.0.0:i386 libqtwebkit4:i386 libqt4-scripttools:i386
    

    After that, install using the bin file. “Cisco Packet Tracer 6.0.1 for Linux – Ubuntu installation (no tutorials).bin” would be the filename. This name is too long for me. Then I renamed it to “ciscopt.bin“. chmod +x ciscopt.bin

    ./ciscopt.bin
    

    Thanks again to Medywan and the author http://www.be-root.com/ site!

  • Where to declare Java Variables?

    Recently I went to Java Meetup. And it was all about Garbage Collector. So I learned lot more about Garbage Collectors. So Dr. Daya’s suggestions was not to declare variable in higher scopes unless we really know what we do. For a example, don’t declare class level variables if we are only using it inside on method. Then I was thinking about doing some tests on variable declarations. I used following code:

    nn

    public class Variable01 {nn	public static void main(String[] args) {n		long startTime = System.nanoTime();n		Method();n		long endTime = System.nanoTime();nn		long duration = endTime - startTime;nn		System.out.println("Method runtime : " + duration + " ms");n	}nn	public static void Method() {n		for (int i = 0; i < 100000; i++) {n			String str;n			// Some Logicn			str = Integer.toString(i);n			System.out.println(str);n		}n	}n}n

    nn

    Then I used following code to do see the difference. Following code is declaring a variable in a higher scope(which is bad according to Dr.Daya).

    nn

    public class Variable02 {nn	public static void main(String[] args) {n		long startTime = System.nanoTime();n		Method();n		long endTime = System.nanoTime();nn		long duration = endTime - startTime;nn		System.out.println("Method runtime : " + duration + " ms");n	}nn	public static void Method() {			n		String str;n		for (int i = 0; i < 100000; i++) {n			// Some Logicn			str = Integer.toString(i);n			System.out.println(str);n		}n	}nn}n

    nn

    First Code execution time was 1756557171 ms.(Variable01.java)nSecond Code execution time was 1826556296 ms.(Variable02.java)

    nn

    With those statistics, it’s clear that declaring objects(Strings) in relevant scopes improves performance. But primitive data types are different. So I did same code for a primitive data type.

    nn

    public class Variable03 {nn	public static void main(String[] args) {n		long startTime = System.nanoTime();n		Method();n		long endTime = System.nanoTime();nn		long duration = endTime - startTime;nn		System.out.println("Method runtime : " + duration + " ms");n	}nn	public static void Method() {n		for (int i = 0; i < 100000; i++) {n			int str;n			// Some Logicn			str = i;n			System.out.println(str);n		}n	}nn}nnpublic class Variable04 {nn	public static void main(String[] args) {n		long startTime = System.nanoTime();n		Method();n		long endTime = System.nanoTime();nn		long duration = endTime - startTime;nn		System.out.println("Method runtime : " + duration + " ms");n	}nn	public static void Method() {n		int str;n		for (int i = 0; i < 100000; i++) {n			// Some Logicn			str = i;n			System.out.println(str);n		}n	}nn}n

    nn

    int is a primitive data type. It will not behave like String did. Improvement is upside down here.

    nn

    Third Code execution time was 1829664932 ms.(Variable03.java)nForth Code execution time was 1681147372 ms.(Variable04.java)

    nn

    Those statistics were collected from same machine with same condition. And I ran those programs against JRE 1.6.0_45. I saw a difference in result, when I ran those programs on JRE 1.7.0_45. Now I’m digging into it!

    nn

    Tags

    nn

      n

    • Java
    • n

    • jvm
    • n

    • garbage collector
    • n

    n

  • 'Java EE 7 Essentials – Book Review'

    Java is one of my favourite languages. A long time ago I learnt Java EE. And this book polished that knowledge I had. This book covers from servlets to EJBs, SOAP web services and many more things. But I should highlight one important thing. If you really don’t know anything about Java EE, this is not for you. But if you are Java EE 6 Guru or you know something about Java EE, This is written for you. 

    nn

    For Guru’s, this will explain the new feature with good examples. And that example is enough to understand the new feature. Although this book has 300 pages, it is worth more than that. In a way, this book deserves as a reference book. When you need to find something new you can just turn some pages and find the thing what you are looking about Java EE. There would be nice brief examples to help you to understand the topic you are looking for.

    nn

    nn

    This is a good book. I like it. Here is the link to buy this book: http://shop.oreilly.com/product/0636920030614.do

    nn

    Tags

    nn

      n

    • Java
    • n

    • Java EE
    • n

    • Java EE 7
    • n

    n

  • Installing Cisco Packet Tracer 6.0.1 on Ubuntu 13.04/12.04 (64-Bit)

    I was watching some CBT Nuggets tutorials, and then I wanted to work with Cisco routers. But I didn’t have any Cisco device, so I downloaded the Cisco Packet Tracer.

    If you want to install Cisco Packet Tracer 6.0.1, you have to download the “Cisco Packet Tracer 6.0.1 for Linux – Ubuntu installation (no tutorials).bin” file. This name is too long for me, so I renamed it to “cp.bin”.

    Then take a terminal window and change the directory to the place where you downloaded the installation file. Type the following commands:

    chmod +x cp.bin
    ./cp.bin
    

    Then press the space bar to scroll down “EULA”. And press “y”. Then press the “Enter” key. Setup will prompt for the root password; please enter it. You will successfully install Cisco Packet Tracer, but if you are going to run it, you will get nothing. That is because the libraries you need to run this on the 64-bit Ubuntu version are not installed. You have to install them. To install those 32-bit libraries, type the following command in your terminal.

    sudo apt-get install ia32-libs-gtk
    

    After installing those libraries, you are good to go! You can enjoy Packet Tracer 6.0.1 on Ubuntu 13.04 64-bit.

    PS: I tested this on Ubuntu 12.04 64-bit as well. This works! This should work on 12.10 as well, but I couldn’t test it.

    If you are looking for “Installing Cisco Packet Tracer 6.0.1 on Ubuntu 13.10 (64-Bit)“

  • Data Science for Business

    Thanks, Foster and Tom for this great book! Since the trend in the industry is towards Big Data and Data Science, I was reading and learning about them. When I found this book, I felt like I found something valuable. And I couldn’t wait until start reading this book. This book’s introduction says that this book will not be too much technical. That was not a problem because this book’s title itself gives an idea that this book is not for technical people. But I’m a technical guy. 
    When we are explaining something to our managers, we have to be careful. Because there is a possibility that the Manager will misunderstand what we are explaining. Such a scenario relevant Data Science, this book will help you for sure. Because this book tells you why you want Data Science and how you use it with business. Then you can use Data Science to gain market share or to increase revenues. If you are a manager, it will be helpful to read and understand your techies. If you are a techie, you should this book to explain how you would be useful to the business.
    I like this book although it is not too much technical. But that doesn’t mean that this book doesn’t include any kind of technical stuff. I like this book! Thumbs up!
    You can buy this book from here

    nn

    Tags

    nn

      n

    • Data Science
    • n

    n

  • After renaming I can't access MongoDB collection! :(

    Yesterday while I was doing some test for the performance team, I renamed a collection. Actually, I renamed system.profile into “Profiling_28-08-2013”. Then I couldn’t access it. I couldn’t delete that collection use db.Profiling_28-08-2013.drop(). After renaming MongoDB shell can’t access that object. 

    1. JavaScript execution failed: ReferenceError: <Part of collection name> is not defined

     2. JavaScript execution failed: SyntaxError: Unexpected token ILLEGAL

     3. <Part of collection name> is not a legal ECMA-262 octal constant (shell):1

     4. SyntaxError: missing ; before statement (shell):1

     5. ReferenceError: <Part of collection name> is not defined (shell):1

    Those errors I got by trying a combination against MongoDB several versions. First two errors I got from  MongoDB 2.4 and the rest from MongoDB 2.2.
    If you have “-” inside your new collection name without any numbers you will get the first error. Rest errors you will only get if you have “-08” like parts in your collection names.
    MongoDB version 2.4.3 Shell version 2.4.3
    MongoDB version 2.2.3 Shell version 2.2.3
    Now you may want to get rid of those collections or you may want precious data in that collection. You can use runCommand to rename those collections or to drop them.

    db.runCommand({drop:”test.Profiling_28-08-2013″});
    db.runCommand({drop:”test.post-old”});

    Rename commands you may have to run against the admin database. For rename, you may have to use the complete namespace. But dropping you can do with just collection name. It is recommended to use namespace when you are dropping.

    db.runCommand({ renameCollection: “test.Profiling_28-08-2013”, to: “test.newCol”});
    db.runCommand({ renameCollection: “test.post-old”, to: “test.newCol”});

    nn

    Tags

    nn

      n

    • mongo
    • n

    • MongoDB Shell
    • n

    • Mongo Shell
    • n

    • mongodb administration
    • n

    • mongodb errors
    • n

    n

←Previous Page
1 … 9 10 11 12 13 … 17
Next Page→
 

Loading Comments...