Rabu, 02 April 2014

Something Else on myTerminal

When i log in as root on terminal i see error like this "sudo: /var/lib/sudo/username writable by non-owner (040777), should be mode 0700" I confused about this, so i search and google and i see someone to try type "sudo chmod 0700 /var/lib/sudo" but isn't work to me and now the notif changed to bla bla bla should be mode uid, now i can fixed :D , i get the solutions on askubuntu someone comment like this:

"
To fix that particular issue is easy:

sudo chown -R root /var/lib/sudo
As for why that happened... I believe that when you were messing with permissions for /var/www you somehow, by accident, changed permissions (and ownership) of all /var tree, including /var/lib/sudo. (I bet the user you were trying to set has id=33)

This may have many consequenses, the sudo warning message being just one symptom.

UPDATE

As for the consequences... it really depends on what (and where) you did. Many (but not all) files and folds in the /var tree are owned by root:root, and its basically impossible to know who each and every file and folder originally belonged to. Full reinstall would be the only feasible way to restore it.

If you changed only the /var/lib tree, it narrows down the "damage", but not much: there are still hundreds of files there.

You can try to find out which command you issued caused this trouble, accesing your bash history:

gedit ~/.bash_history &
Maybe this will give a clue about what happened and its consequences"

and it's works to me....

Selasa, 25 Maret 2014

Sticky Notes on Linux

Are you looking for sticky notes and other cool widgets like as windows desktop, ok linuxer, slow down now you can do it on your desktop here comes the solution:

1. You have to install screenlets framework from http://www.screenlets.org/index.php/Download

In terminal type following 3 commands: 
 
sudo apt-add-repository ppa:screenlets-dev/ppa 
sudo apt-get update
sudo apt-get install screenlets



2. Go to Application > Accessories > Screenlets. 
3. In the Screenlets-manager window select the screenlet "Lipik" (click on it)

4. If you want notes to automatically start on log-in check the checkbox "Auto start on login" (bottom-left side) 
 
5. click "launch/add" (left side)
 
6. if you do not want notes to stay always above other windows, 
right-click on the top of note > Window > uncheck "Keep above"

And that's it. You are done.

Sabtu, 15 Maret 2014

Android Button Style

State List Drawables

In the last article we covered the styling of a dialog box using vector drawables. In this article we are going to add a cancel button to that dialog box, and style the button. Styling widgets is a little more complex that the static styling that we’ve previously covered because widgets change state depending on whether they are disabled, have focus, are selected, clicked, etc. and they need to change visually to indicate that state to the user. State List drawables are the tool that we need to use to manage these state changes.

Let’s start by adding a button to the previous code. If you already have a working copy of the code from the previous article, then you can use that. Alternatively, you can download a working project here.
The first thing that we need to do is add add a button control inside a LinearLayout as the last child of the RelativeLayout in res/layout/main.xml:
<LinearLayout android:orientation="horizontal"
 android:layout_height="wrap_content" android:weightSum="2"
 android:layout_below="@+id/body" android:layout_width="match_parent"
 android:gravity="center">
 <Button android:text="Close" android:layout_width="wrap_content"
  android:layout_height="wrap_content" android:id="@+id/close"
  android:layout_weight="1"></Button>
</LinearLayout>
We are putting the button inside a LinearLayout because we want to be able to style to dialog footer. One interesting thing here is the use of weightSum in the LinearLayout and layout_weight in the button. Weights are a useful way of laying out children within a layout and we are using it here to size the button to half the width of its parent. If, for example, we wanted the button to be one third the width of the parent, we would simply change the weightSum in the LinearLayout to “3″.
Next we need to wire up the button so that it closes the window when it is clicked. In the onCreate() method of MainActivity:
@Override
public void onCreate(Bundle savedInstanceState) 
{
 super.onCreate(savedInstanceState);
 setContentView(R.layout.main);
 WindowManager.LayoutParams lp = getWindow().getAttributes();
 lp.dimAmount = 0.0f;
 getWindow().setAttributes( lp );
 getWindow().addFlags( WindowManager.LayoutParams.FLAG_BLUR_BEHIND );
 ((Button)findViewById(R.id.close)).setOnClickListener( new OnClickListener() {
  public void onClick(View v) 
  {
   MainActivity.this.finish();
  }
 });
}
This now looks like this:
Dialog Box With Button
Dialog Box With Button
Next we’ll define a new drawable for the LinearLayout that we’ve just created inres/drawable/dialog_footer.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="rectangle">
 <solid android:color="#4B4B4B" />
 <corners android:bottomLeftRadius="5dp" android:bottomRightRadius="5dp" />
 <stroke android:color="#4B4B4B" android:width="1dp" />
</shape>
This is has a solid grey fill with the bottom two corners rounded. Next we need to define a new style using this drawable, and adding some padding at the top which will balance the 5dp that will be added to the bottom because of the rounded corners:
<style name="dialog_footer">
 <item name="android:background">@drawable/dialog_footer</item>
 <item name="android:paddingTop">5dp</item>
</style>
We can apply this to the LinearLayout by setting its style attribute:
<LinearLayout android:orientation="horizontal"
 android:layout_height="wrap_content" android:weightSum="2"
 android:layout_below="@+id/body" android:layout_width="match_parent"
 android:gravity="center" style="@style/dialog_footer">
.
.
.
Which gives us:
A Styled Footer
A Styled Footer
Now let’s have a look at the button. As I have already mentioned, styling widgets is a little more complex than the styling that we’ve done thus far because widgets need to indicate visually when they have focus, are selected, are clicked, or are disabled.
It is worth a quick discussion about these various states because many of the problems which are encountered when styling controls are often the result of misunderstanding the widget state.
  • Pressed – when a widget such as a button is clicked
  • Focused – when the widget is highlighted via the D-pad or trackball
  • Selected – when a widget is activated, such as the active tab on atab control
  • Checkable – this is specific to widgets which can transition between a checkable and non-checkable state
  • Checked – when a widget, such as a checkbox, is checked
  • Enabled – when a widget is enabled
  • Window Focused – when the lop level window containing the widget has focus.
There are some subtle differences between these states and it is easy to use the wrong one, and find that the behaviour that you’re expecting doesn’t happen!
Now that we have an understating of the various states that a widget can have, we can define a State List drawable which assigns different drawables for the widget depending on its state. Create this at res/drawable/button.xml:
1
2
3
4
5
6
7
8
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
 <item android:state_pressed="true"
  android:drawable="@drawable/button_pressed" />
 <item android:state_focused="true"
  android:drawable="@drawable/button_focused" />
 <item android:drawable="@drawable/button_normal" />
</selector>
When rendering a control each line of state drawable is evaluated until a match is found, and then that drawable is used. Therefore the order of entries is vital. In this case it is important the the “pressed” state is matched before the “focused” state. If these entries were swapped, then navigating to the control using the D-pad or trackball and then clicking would still match to focused. More common problems with state drawables result from getting the entries in the wrong order.
We now need to define the drawables that this references. Firstres/drawable/button_normal.xml:
1
2
3
4
5
6
7
8
9
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="rectangle">
 <gradient android:startColor="#FFFFFFFF" android:endColor="#A4A4A4"
  android:angle="270" />
 <corners android:radius="2dp" />
 <padding android:top="10dp" android:bottom="10dp" android:left="10dp"
  android:right="10dp"/>
</shape>
This is a simple grey gradient with slightly rounded corners, and some padding around the text of the button.
Next res/drawable/button_focused.xml:
1
2
3
4
5
6
7
8
9
10
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="rectangle">
 <gradient android:startColor="#FFFFFFFF" android:endColor="#A4A4A4"
  android:angle="270" />
 <corners android:radius="2dp" />
 <stroke android:color="#14A804" android:width="2dp" />
 <padding android:top="10dp" android:bottom="10dp" android:left="10dp"
  android:right="10dp" />
</shape>
This is similar to button_normal, except that it draws a green border around the button when it has focus.
And finally res/drawable/button_focused.xml:
1
2
3
4
5
6
7
8
9
10
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="rectangle">
 <gradient android:startColor="#118c03" android:endColor="#14A804"
  android:angle="270" />
 <corners android:radius="2dp" />
 <stroke android:color="#4B4B4B" android:width="1dp" />
 <padding android:top="10dp" android:bottom="10dp" android:left="10dp"
  android:right="10dp" />
</shape>
This uses a green gradient fill.
We now need to create a style called button in res/values/styles.xml:
1
2
3
4
5
<?xml version="1.0" encoding="utf-8"?>
<style name="button" parent="@android:style/Widget.Button">
 <item name="android:background">@drawable/button</item>
 <item name="android:layout_marginTop">1dp</item>
 <item name="android:layout_marginBottom">5dp</item>
There is something new that we’ve done here: setting the style parent to @android:style/Widget.Button inherits the default attributes of the android button definition, but allows us to override what we like. Here we are specifying out state list drawable, and setting a couple of margins just to keep things looking balanced.
Finally we can set the style of the button in res/layout/main.xml:
1
2
3
4
<Button android:text="Close" android:layout_width="wrap_content"
 android:layout_height="wrap_content" android:id="@+id/close"
 android:layout_weight="1" style="@style/button">
</Button>
We can run this to see the three states of the button:
Button Normal
Button Normal
Button Focused
Button Focused
Button Pressed
Button Pressed
That’s looking pretty good. The only thing that I’m not happy with is that the text looks fine while it’s against the grey gradient, but it becomes a little lost on the green. Maybe it would look better if the text was white when the button was pressed. Now that we know how to select different drawables for the background based upon the state, what about dynamically changing the text style based upon state changes? We’ll cover that in the next article.
The source code for this article can be downloaded here.

~Reference of stylingandroid

Minggu, 02 Maret 2014

How to create virtual machine on linux

 Virtual machine (VM) is a software-based emulation of a computer. Virtual machines operate based on the computer architecture and functions of a real or hypothetical computer. Virtualization is a broad term that refers to the abstraction of computer resources such as:
  1. Platform Virtualization
  2. Resource Virtualization
  3. Storage Virtualization
  4. Network Virtualization
  5. Desktop Virtualization

Why should I use virtualization?

  • Consolidation - It means combining multiple software workloads on one computer system. You can run various virtual machines in order to save money and power (electricity).
  • Testing - You can test various configuration. You can create less resource hungry and low priority virtual machines (VM). Often, I test new Linux distro inside VM. This is also good for students who wish to learn new operating systems and programming languages / database without making any changes to working environment. At my work place I give developers virtual test machines for testing and debugging their software.
  • Security and Isolation - If mail server or any other app gets cracked, only that VM will be under control of the attacker. Also, isolation means misbehaving apps (e.g. memory leaks) cannot bring down whole server.

Open Source Linux Virtualization Software

  1. OpenVZ is an operating system-level virtualization technology based on the Linux kernel and operating system.
  2. Xen is a virtual machine monitor for 32 / 64 bit Intel / AMD (IA 64) and PowerPC 970 architectures. It allows several guest operating systems to be executed on the same computer hardware concurrently. XEN is included with most popular Linux distributions such as Debian, Ubuntu, CentOS, RHEL, Fedora and many others.
  3. Kernel-based Virtual Machine (KVM) is a Linux kernel virtualization infrastructure. KVM currently supports native virtualization using Intel VT or AMD-V. A wide variety of guest operating systems work with KVM, including many flavours of Linux, BSD, Solaris, and Windows etc. KVM is included with Debian, OpenSuse and other Linux distributions.
  4. Linux-VServer is a virtual private server implementation done by adding operating system-level virtualization capabilities to the Linux kernel.
  5. VirtualBox is an x86 virtualization software package, developed by Sun Microsystems as part of its Sun xVM virtualization platform. Supported host operating systems include Linux, Mac OS X, OS/2 Warp, Windows XP or Vista, and Solaris, while supported guest operating systems include FreeBSD, Linux, OpenBSD, OS/2 Warp, Windows and Solaris.
  6. Bochs is a portable x86 and AMD64 PC emulator and debugger. Many guest operating systems can be run using the emulator including DOS, several versions of Microsoft Windows, BSDs, Linux, AmigaOS, Rhapsody and MorphOS. Bochs can run on many host operating systems, like Windows, Windows Mobile, Linux and Mac OS X.
  7. User Mode Linux (UML) was the first virtualization technology for Linux. User-mode Linux is generally considered to have lower performance than some competing technologies, such as Xen and OpenVZ. Future work in adding support for x86 virtualization to UML may reduce this disadvantage.

Proprietary Linux Virtualization Software

  1. VMware ESX Server and VMWare Server - VMware Server (also known as GSX Server) is an entry-level server virtualization software. VMware ESX Server is an enterprise-level virtualization product providing data center virtualization. It can run various guest operating systems such as FreeBSD, Linux, Solaris, Windows and others.
  2. Commercial implementations of XEN available with various features and support.
    • Citrix XenServer : XenServer is based on the open source Xen hypervisor, an exceptionally lean technology that delivers low overhead and near-native performance.
    • Oracle VM : Oracle VM is based on the open-source Xen hypervisor technology, supports both Windows and Linux guests and includes an integrated Web browser based management console. Oracle VM features fully tested and certified Oracle Applications stack in an enterprise virtualization environment.
    • Sun xVM : The xVM Server uses a bare-metal hypervisor based on the open source Xen under a Solaris environment on x86-64 systems. On SPARC systems, xVM is based on Sun's Logical Domains and Solaris. Sun plans to support Microsoft Windows (on x86-64 systems only), Linux, and Solaris as guest operating systems.
  3. Parallels Virtuozzo Containers - It is an operating system-level virtualization product designed for large-scale homegenous server environments and data centers. Parallels Virtuozzo Containers is compatible with x86, x86-64 and IA-64 platforms. You can run various Linux distributions inside Parallels Virtuozzo Containers.

Now I'll tell you my experience, I want to install slackware os in my laptop, my laptop os backbox. I've tried using some vm but failed, I tried to install slackware on a virtual box failed, I tried to install in vmplayer failed, I can not know why the error, but in the end I managed well :D I can install in kvm-qemu, kvm-qemu is one belonging to the linux virtual machine. I install kvm through the terminal, okay checkicode :

  • Open terminal.
  • Type the following command to install KVM and supporting packages.

    sudo apt-get install qemu-kvm libvirt-bin bridge-utils virt-manager

  • After installation, register your user to the libvirtd so that the user is accessing can use the service libvirtd.

    sudo adduser creatorb libvirtd

    *creatorb change to your name
  • Log in as root, and issue the following command to view the existing virtual machine is running, but when the first after the installation has been no virtual machines running. 
    sudo su
    After it, type following command

    virsh -c qemu:///system list

    And next, screen will display like this

    Id Name State
    ---------------------------------
  • Yeah installation finished, launching now...
    Type the command on terminal virt-manager or search application virtual machine manager and launch.
     
  • Click Create New Virtual Machine on the toolbar, and then be directed to the VM installation menu.

  • Display will appear to select the media for installation. Such as VirtualBox or VMware, there will be several options of CD / DVD, ISO or network.


  • Insert the memory to be used by the Virtual Machine. For use over 2GB RAM, 64bit linux kernel is required.


  • Incorporate storage space that will be used. We can also include storage that has been prepared previously by selecting browse. For regular storage, we just enter the amount of storage available in the field.

  • By default, KVM provides NAT for networking. Virtual Machine you will not look directly at your network, but is a continuation of the host tissue. We can change the type of networking that suit their needs.

     

     
yeaah, now you can use virtualization, runing and play now :D happy linux and go opensource ^_^

Senin, 24 Februari 2014

How to set transparent background for image button, text edit, etc on android project.

When you want to change layout like that, somepeople add some code on file.java, but I have simple trick to change background of image button or EditText to transparant, it easy...you can add it's code android:background="#00ffffff" to your file.xml example:

Before:
<EditText
        android:id="@+id/I1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_x="1dp"
        android:layout_y="86dp"
        android:ems="10"
        android:gravity="center"
        android:hint="Input First Number"
        android:numeric="integer"
        android:textColorHint="#FAFAD2"
        android:textColor="#FAFAD2" />

After:
<EditText
        android:id="@+id/I1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_x="1dp"
        android:layout_y="86dp"
        android:background="#00ffffff"

        android:ems="10"
        android:gravity="center"
        android:hint="Input First Number"
        android:numeric="integer"
        android:textColorHint="#FAFAD2"
        android:textColor="#FAFAD2" />

save and run your project, and see the magic :D
okay...#keep coding, and be a programmer....

Rabu, 12 Februari 2014

How To Change CPU Cores on LINUX

 Multicore Processor

 

 

Opinion:

Some choose to use a single core or one processor core reasons:
• Computer only used for lightweight applications such as Internet browsing, office applications
• 1 core processors more power efficient.
• Single core is enough for me at this time.
- See more at: http://etutorialkomputer.blogspot.com/2011/02/fungsi-multicore-processor.html#sthash.0VwVLjXk.dpuf
I got it on other blog :)

Some people choose to use a single core:

• Computer only used for lightweight applications such as Internet browsing, office applications.
• 1 core processors more power efficient.
• Single core is enough.

Some people choose to use a dual core:

• dual core processor is more intensive for gaming applications.
• Speed ​​is not much different dual core quad cores for specific applications.
• Got a dual core processor speed better at the same price of a quad core.
• Power is more efficient than quad core.

hmmm... I also chose dualcore because, I think is helpful me,  for improving performance of the emulator. when I run to try a app of android have I created.
and how to change it, yeaah like that...

Method 1:
This method is dynamic and doesn’t require a reboot. You can just open a terminal and try this out:
  • sudo sh -c "echo 0 > /sys/devices/system/cpu7/online"
    sudo sh -c "echo 0 > /sys/devices/system/cpu6/online"
    Repeat the above steps for cpu2 to cpu7 and it’ll leave you with cpu0 and cpu1 active which is essentially what we’re trying to achieve.
Method 2:
I like it and working to me....This method will make the linux boot with 2 cores which might make kernel more optimized for dual core environment than the method above.


  • Add maxcpus=2 to GRUB command line by doing the following:
    gksu gedit /etc/default/grub
    Find:
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
    and change it to
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash maxcpus=2"
  • Then run:
    sudo update-grub
    When you reboot, linux will run on 2 cores.

    ok...see u next time, #keep coding programmer...
Some choose to use a single core or one processor core reasons:
• Computer only used for lightweight applications such as Internet browsing, office applications
• 1 core processors more power efficient.
• Single core is enough for me at this time.
- See more at: http://etutorialkomputer.blogspot.com/2011/02/fungsi-multicore-processor.html#sthash.0VwVLjXk.dpuf
Multicore Processor

Multicore Proce

Multicore Processor
Multicore Processor

Selasa, 04 Februari 2014

Can't launch emulator AVD in eclipse cause No Target Selected

Today, i'm coding on my eclipse workspace but something wrong because when i'm create android emulator 4.1 in AVD isn't working, i'm confusing about this, i see a error message "No Target Selected" i have changed target but no effect. But finally i can solved it ^_^ ok check this out...



when you have a problem same with me, because of "You don't install CPU System Images. for example: ARM EABI v7a System Image" and then i installing a cpu system image on sdk manager. I'm click the icon Android SDK manager on toolbar and i go to Android 4.1.2 API Level 16 and i checklist a cpu system image for download and installing it.


and finally, i can to create a android emulator 4.1 :D don't you believe me? let's try it's your home and see the magic :v ckckck.... i hope this can help you to solve your problems #keep coding programmer ;)