Tuesday, December 16, 2014

Ubuntu Install - Error invalid arch-independent ELF magic

sudo fdisk -lu /dev/sda
sudo mount /dev/sda1 /mnt (if /dev/sda1 is the boot partition)
sudo grub-install --root-directory=/mnt           /dev/sda
sudo reboot

Enjoy your newly installed Ubuntu!

Windows 7: get pc serial number from command line

To get your machine serial number in Windows 7, you can try these command:
wmic bios get serialnumber or
wmic csproduct get identifyingnumber
Have fun without looking at the back of your pc to find the serial number!

Wednesday, November 12, 2014

Flume and rolling into a big file

I takes me for a while to figure out how to stop Flume from rolling small files, but into a big file (e.g 128 MB). I read 2 books on Flumes and none of them showing me how to accomplish that! Even Flume docs doesn't show you to do that neither.
I started Google and have to put pieces together and here's the working config for Flume to roll in the file size you want. This config for JMS queue. The magic is "JmsAgent.sinks.HDFS.hdfs.minBlockReplicas = 1"!

JmsAgent.sources = JmsSrc
JmsAgent.channels = MemChannel
JmsAgent.sinks = HDFS

JmsAgent.sources.JmsSrc.type = jms
JmsAgent.sources.JmsSrc.initialContextFactory = ...
JmsAgent.sources.JmsSrc.connectionFactory = ...
JmsAgent.sources.JmsSrc.providerURL = ...
JmsAgent.sources.JmsSrc.destinationName = ...
#default batchsize = 100
JmsAgent.sources.JmsSrc.batchSize = 500
JmsAgent.sources.JmsSrc.destinationType = QUEUE


JmsAgent.sinks.HDFS.type = hdfs
JmsAgent.sinks.HDFS.hdfs.useLocalTimeStamp = true
JmsAgent.sinks.HDFS.hdfs.path = hdfs://host/path/%Y-%m-%d
JmsAgent.sinks.HDFS.hdfs.filePrefix = jms_sample
JmsAgent.sinks.HDFS.hdfs.fileType = DataStream
JmsAgent.sinks.HDFS.hdfs.writeFormat = Text
JmsAgent.sinks.HDFS.hdfs.batchSize = 10000
#256mg =  268435456
#JmsAgent.sinks.HDFS.hdfs.rollSize = 268435456
#128mg = 134217728
JmsAgent.sinks.HDFS.hdfs.rollSize =  134217728
JmsAgent.sinks.HDFS.hdfs.rollCount = 0
#default rollInterval
JmsAgent.sinks.HDFS.hdfs.rollInterval = 0
JmsAgent.sinks.HDFS.hdfs.idleTimeout = 3600
JmsAgent.sinks.HDFS.hdfs.minBlockReplicas = 1

JmsAgent.channels.MemChannel.type = memory
JmsAgent.channels.MemChannel.capacity = 11000
JmsAgent.channels.MemChannel.transactionCapacity = 10000

JmsAgent.sources.JmsSrc.channels = MemChannel
JmsAgent.sinks.HDFS.channel = MemChannel

Have fun with Flume!

Typesafe Activator behind proxy

As started playing with Scala, I need to run Typesafe Activator. And I tried to run activator ui and got an error. It turned out that Activator needs to download dependencies from maven repos and it was blocked by the firewall.
Here is how to configure the proxy for Activator: https://typesafe.com/activator/docs
Now I can  have some fun with Scala and Activator!

Wednesday, October 15, 2014

Toshiba Laptop Windows 8 boot from external device

Recently, I've tried to fix a Toshiba for a friend and have a hard time to get it boot from external device.
After a Google search, I did two things:
Security Boot: disable
Boot Mode: UEFI > CSM
That's it!. Now it can boot from the device I want!

Wednesday, June 18, 2014

Linux: view memory info

Use this command:

free -m (display in megabytes)
free -k (display in kilobytes)

or this command:
cat /proc/meminfo

Note: For Windows environment, msinfo32 is the equivalent.

Tuesday, June 17, 2014

JPA: Error loading the persistence descriptor WEB-INF/lib/_wl_cls_gen.jar!/META-INF/persistence.xml from the module

Root cause:
persistence.xml is located in src/main/resources/META-INF
Solution: 
move persistence.xml to src/main/java
That's it. Is that simple!?

Note: if you encounter an error, when trying to run a main (as Java application in Eclipse), then you need to move it back to src/main/resources/META-INF


Monday, June 16, 2014

Java JPA error: No Persistence provider for EntityManager named

While working on a JPA project, this type error keeps popping up despite that fact that the persistence unit name is correctly specified. At first, I thought I may miss some jar files or class path problem. However, it turned out that the persistence.xml need to be placed under src/main/resources/META-INF folder (if META-INF is not there, you need to create one).

Tuesday, May 27, 2014

weblogic.application.ModuleException: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

Eclipse Maven and Weblogic:
As I tried to deploy my web app into a remote Weblogic server, I got this kind of error:
weblogic.application.ModuleException: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

My app just ran fine the other day and I just made one single change on a file related to spring bean. And this error made me think that the root cause of the problem was the change I had just made. However, it turned out that the Maven dependencies were not included in the project class path. This is an Eclipse defect, I guess! Sometime it does include, other time it doesn't

Solution: to fix it error:  Right click on the project > Properties > Deployment Assembly > Add > Java Build Path Entries > Maven Dependencies

Monday, May 19, 2014

Weblogic Install: Files was unexpected at this time!

As trying to install the newest Weblogic version 12g 1.20 on my Windows machine, I ran into the weird error that I haven't seen before. And it's called "Files was unexpected at this time"!

It took me like to 2 days to figure out! The root cause of this error is that the system variable PATH contains double quote such as "C:\Program Files(x86)\someprogram".

Solution: just remove the double quote!

My guess is that when I tried to execute configure.cmd, it tried to set up my local machine environment for Weblogic installation/launching. In doing so, it had to parse and add elements to the system variable PATH. Since my PATH contained double quote, it failed to parse it. And that's the reason it threw the error: "Files was unexpected at this time"!

Hope it save you some time when running to this issue!




Monday, April 21, 2014

powercfg: Windows

Let's say you're able to change the power configuration from the GUI, you call use the following commands (e.g. powershell) to override the current configuration. 

powercfg -change -standby-timeout-ac 0
powercfg -change -hibernate-timeout-ac 0
powercfg -change -monitor-timeout-ac 0

Note:
0 (zero) or any number: set the computer to standby/hibernate/monitor sleep after this number of minutes idle.

Saturday, April 19, 2014

gcc and c99 mode

In Java, the standard "for loop" is that the counter i is declared inside the loop as follows:

for (int i=0; i < 10; i++){
    System.out.println("Hello, world!");
}

However, for C, if you try to declare the counter inside the for for loop:
for (int it=0; i<10;i++{
     printf("Hello, world!\n");
}

You may get this error:
for_loop_test.c: In function ‘main’:
for_loop_test.c:4: error: ‘for’ loop initial declaration used outside C99 mode

By default, the compiler gcc uses the ANSI c syntax (aka C89 mode), not ISO syntax (aka C99 mode). To turn on the C90 mode, add this argument to gcc
gcc -std=c99 foo.c


Note:
ANSI < American National Standard Institute
ISO < International Standard Organization

Thursday, April 10, 2014

cygwin: linux native for windows platform

Download and install cygwin (e.g. c:\cygwin)
Setup path variable for cygwin
Setup cygwin update
         setup-x86_64.exex
ifconfig command is not supported by cygwin, but the good news that you can use ipconfig!
dig command from the packages: bind-utils and curl

gdb and objdump: C debugger

By default, the assembly language for your machine may use ATT syntax, to set gdb use Intel syntax assembly language, use this command when in gdb:

         set disassembly intel (if not working, try this: set disassebmly-flavor intel)

You may try to configure this setting to run every time GDB start up by putting the command in the file .gdbinit in your home directory.

          echo "set disassembly-flavor intel" > ~/.gdbinit

To view the value at memory address (e.g. 0x1004010dd), use x (examine) command. This command requires 2 arguments: the memory address and the display format (o: octal, x: hex, u: base-10 decimal, t: binary).
          x/x 0x1004010dd

The x command may be also used to display assembly instruction at the memory address
         x/i 0x1004010dd (i short for instruction)

To use objdump*:
        objdump -D a.out
        objdump -M intel -D a.out (display with Intel syntax, otherwise AT&T syntax by default)

Note: * for Mac OSX, objdump is not installed by default. To install it, use this command:
       sudo port install binutils
And installation location: /opt/local/x86_64-apple-darwin11.3.0/bin