poniedziałek, 29 grudnia 2014

Multiplication Table

i = 1
print "-" * 50
while i<11:
    n=1
    while n<=10:
        print "%4d" % (i * n),
        n += 1
    print ""
    i += 1
print "-" * 50

sobota, 27 grudnia 2014

ArrayList java

package tablice;

import java.util.ArrayList;

public class ListArray
{
public static void main(String[] args)
{
//create new ArrayList
ArrayList<Integer> elements = new ArrayList<>();
//add elements
//insert to ArrayList
for(int i=0;i<=1024;i++)
{
elements.add(i);
}

//read all elements
for(int i=0;i<elements.size();i++)
{
int value = elements.get(i);
System.out.println(value);
}

//get size
int ile = elements.size();
System.out.println("size: "+ile);
}
}

piątek, 26 grudnia 2014

Simple fibo test java

package Matematyka;

public class fib1
{
public static void main(String[] args)
{
int n = 5;
int temp;
int a = 1;
int b = 1;


for(int i=0;i<n;i++)
{
temp = a;
a = b;
b += temp;
System.out.println(temp);

}
System.out.println(Integer.toString(n)+". liczba fib to "+Integer.toString(a));
}
}

wtorek, 9 grudnia 2014

sobota, 20 września 2014

change default app xfce

run terminal- ctr + alt + t:

exo-preferred-applications

java - how to check execution time.

package practice;

public class dateTime
{
    public static void main (String[] args)
    {
        long t1 = System.currentTimeMillis();       
//something complicated
        for (int i =0; i<1E6; i++)
        {
            double x = Math.pow(Math.random(), Math.random());
        }
//end operation
        long t2 = System.currentTimeMillis();
        System.out.println((t2-t1)/1000.0 + " sec ");
       
    }
}

piątek, 19 września 2014

Java localhost port scanner

threadNetwork.java

package threads;
public class threadNetwork
{
    private static String host;
    public static void main(String[] args)
    {
        host = "localhost";
        for (int i = 22; i < 65356; i++)
        {
            portThread t = new portThread(host, i);
            t.start(); 
        }
    }
}

portThread.java

package threads;

import java.net.Socket;

public class portThread extends Thread
{
    private String host;
    private int port;
    public portThread(String host, int port)
    {
        this.host = host;
        this.port = port;
      
    }
    public void run()
    {
        try
        {
            Socket socket = new Socket(host, port);
            System.out.println("Port: "+ port + " is open...");
            socket.close()  
        }
        catch (Exception e)
        {
            //System.out.println("Port: "+ port + " is not in use");
        }
    }
}


sobota, 6 września 2014

Java - simple gui example program

package gui;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Date;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class myWindow extends JFrame implements ActionListener
{
    JButton bGetDate, bExit, bSysCheck;
    JLabel lshowDate;
   
   
    private static final long serialVersionUID = 1L;

    public myWindow()
    {
        setSize(400,300);
        setTitle("My Stratus");
        setLayout(null);
       
        bGetDate = new JButton("Date");
        bGetDate.setBounds(50, 50, 100, 20);
        add(bGetDate);
        bGetDate.addActionListener(this);
       
        bSysCheck = new JButton("SysChceck");
        bSysCheck.setBounds(150, 50, 100, 20);
        add(bSysCheck);
        bSysCheck.addActionListener(this);
       
       
        bExit = new JButton("Exit");
        bExit.setBounds(250, 50, 100, 20);
        add(bExit);
        bExit.addActionListener(this);
       
        lshowDate = new JLabel("Date: ");
        lshowDate.setBounds(50, 100, 200, 20);
        lshowDate.setForeground(Color.RED);
        lshowDate.setFont(new Font("SansSerif",Font.BOLD, 10));
        add(lshowDate);
           
    }
   
    public static void main(String[] args)
    {
        myWindow window = new myWindow();
        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        window.setVisible(true);
    }
   
    @Override
    public void actionPerformed(ActionEvent e)
    {
        Object src = e.getSource();
        if(src==bExit)
        {
            dispose();
        }
        else if(src==bGetDate)
        {
            //System.out.println(new Date());
            lshowDate.setText(new Date().toString());
           
           
        }
        else if(src==bSysCheck)
        {
            System.out.print("sys details: ");
            Runtime r = Runtime.getRuntime();
            Process p;
            try {
                p = r.exec("uname -a");
                p.waitFor();
                BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream()));
               
                String line = "";

                while ((line = b.readLine()) != null)
                {
                  System.out.println(line);
                }
               
               
            } catch (IOException | InterruptedException e1) {
               
                e1.printStackTrace();
            }

           
        }
    }
}

           
       
   

Java methods - simple calc

file: Methods.java

import java.util.Scanner;
import practice.fromOperation;

public class Methods
{
    public static void main(String[] args)
    {
        System.out.print("Plase enter a: ");
        Scanner scan = new Scanner(System.in);
       
        int a = scan.nextInt();
        System.out.print("Please enter b: ");
        int b = scan.nextInt();
       
        System.out.println("first: " +a);
        System.out.println("second: " +b);
       
        System.out.println("sum: "+fromOperation.addInt(a, b));
        System.out.println("min: "+fromOperation.minusInt(a, b));
        System.out.println("multiply: "+fromOperation.multiplyInt(a, b));
        if (b !=0)
        {
            System.out.println("div: "+fromOperation.divInt(a, b));
        }
        else
        {
            System.err.println("Divide by zero");
        }
        scan.close();
    }

}

file fromOperation.java

public class fromOperation
{
    static int addInt(int a, int b)
    {
        int sum = a + b;
        return sum;
    }
    static int minusInt(int a, int b)
    {
        int min = a - b;
        return min;
    }
    static int multiplyInt(int a, int b)
    {
        int multipl = a * b;
        return multipl;
    }
    static int divInt(int a, int b)
    {
        int div = a / b;
        return div;
    }
}


czwartek, 4 września 2014

Scala jar

scala -savecompiled helloWorld.scala


[marek@localhost src]$ jar tvf helloWorld.jar
   128 Thu Sep 04 10:21:26 CEST 2014 META-INF/MANIFEST.MF
   867 Thu Sep 04 10:21:26 CEST 2014 Main$.class
   555 Thu Sep 04 10:21:26 CEST 2014 Main.class

sobota, 26 lipca 2014

dir/files change monitoring

1. sudo pip install pyinotify
2. [root@localhost marek]# python -m pyinotify -v /var/log/httpd/

[root@localhost marek]# python -m pyinotify -v /var/log/httpd/
[2014-07-26 19:53:31,874 pyinotify DEBUG] Start monitoring ['/var/log/httpd/'], (press c^c to halt pyinotify)
[2014-07-26 19:53:31,875 pyinotify DEBUG] New <Watch wd=1 path=/var/log/httpd mask=4095 proc_fun=None auto_add=None exclude_filter=<function <lambda> at 0x7fac8bb971b8> dir=True >
[2014-07-26 19:53:57,269 pyinotify DEBUG] Event queue size: 32
[2014-07-26 19:53:57,270 pyinotify DEBUG] <_RawEvent cookie=0 mask=0x2 name=error_log wd=1 >
<Event dir=False mask=0x2 maskname=IN_MODIFY name=error_log path=/var/log/httpd pathname=/var/log/httpd/error_log wd=1 >
[2014-07-26 19:53:57,270 pyinotify DEBUG] Event queue size: 32
[2014-07-26 19:53:57,270 pyinotify DEBUG] <_RawEvent cookie=0 mask=0x2 name=access_log wd=1 >

<Event dir=False mask=0x2 maskname=IN_MODIFY name=access_log path=/var/log/httpd pathname=/var/log/httpd/access_log wd=1 >

piątek, 20 czerwca 2014

apt-get no public key warning

apt-get update after add new repo:


Czytanie list pakietów... Gotowe

W: Błąd GPG: http://apt.izzysoft.de generic Release: Następujące podpisy nie mogły zostać zweryfikowane z powodu braku klucza publicznego: NO_PUBKEY D744E9C2C9B9B62C


solution:

marek@lati:~$ wget http://apt.izzysoft.de/izzysoft.asc
--2014-06-20 16:48:52--  http://apt.izzysoft.de/izzysoft.asc
Translacja apt.izzysoft.de (apt.izzysoft.de)... 144.76.109.57
Łączenie się z apt.izzysoft.de (apt.izzysoft.de)|144.76.109.57|:80... połączono.
Żądanie HTTP wysłano, oczekiwanie na odpowiedź... 200 OK
Długość: 1692 (1,7K) [text/plain]
Zapis do: `izzysoft.asc'

100%[=================================================================================================================================>] 1.692       --.-K/s   w 0,002s  

2014-06-20 16:48:52 (1,00 MB/s) - zapisano `izzysoft.asc' [1692/1692]

marek@lati:~$ sudo apt-key izzysoft.asc
Usage: apt-key [--keyring file] [command] [arguments]

Manage apt's list of trusted keys

  apt-key add <file>          - add the key contained in <file> ('-' for stdin)
  apt-key del <keyid>         - remove the key <keyid>
  apt-key export <keyid>      - output the key <keyid>
  apt-key exportall           - output all trusted keys
  apt-key update              - update keys using the keyring package
  apt-key net-update          - update keys using the network
  apt-key list                - list keys
  apt-key finger              - list fingerprints
  apt-key adv                 - pass advanced options to gpg (download key)

If no specific keyring file is given the command applies to all keyring files.
marek@lati:~$ sudo apt-key add izzysoft.asc
OK

środa, 7 maja 2014

The easiest way to remove ppa repos from ubuntu

ls /etc/apt/sources.list.d


marek@lati:/etc/apt/sources.list.d$ ll
razem 20
drwxr-xr-x 2 root root 4096 maj  7 10:37 ./
drwxr-xr-x 6 root root 4096 maj  6 11:06 ../
-rw-r--r-- 1 root root  142 maj  7 10:37 mc3man-trusty-media-trusty.list
-rw-r--r-- 1 root root  142 maj  7 10:37 mc3man-trusty-media-trusty.list.save
-rw-r--r-- 1 root root  142 maj  7 10:37 ubuntu-on-rails-ppa-trusty.list




sudo rm -i /etc/apt/sources.list.d/ubuntu-on-rails-ppa-trusty.list

user input in ruby with to_i

#!/usr/bin/ruby

print ('Enter your score: ')
score= gets.to_i //without it you always choose invalid score :)
puts "#{score}"
result = case score
   when 0..40 then "Fail"
   when 41..60 then "Pass"
   when 61..70 then "Pass with Merit"
   when 71..100 then "Pass with Distinction"
   else "Invalid Score"
end

puts result

poniedziałek, 5 maja 2014

Missing message report in sbconsole?

The reports are stored in your Oracle Database.

Schema:[DOMAIN_NAME]_SOAINFRA
Tables:WLI_QS_REPORT_ATTRIBUTE and WLI_QS_REPORT_DATA

piątek, 2 maja 2014

enter anonymous password in mysql connection python

#!/usr/bin/python

import MySQLdb
import getpass

print "---====DB CONNECT====---"

user = raw_input("Enter username: ")
password = getpass.getpass("Enter password: ")
"""password = raw_input("Enter password: ")"""

try:
    db = MySQLdb.connect("localhost",user,password,"mysql")
    if db:
        print "connected"
        cursor = db.cursor()
        cursor.execute("Select version()")
        data = cursor.fetchone()
        print "db version: %s " %data
        db.close()
    else:
        print "error"
       
except MySQLdb.Error, e:
    try:
        print "MySQL Error [%d]: %s" % (e.args[0], e.args[1])
    except IndexError:
        print "MySQL Error: %s" % str(e)

search string in file python

#!/usr/bin/python


try:
    name = raw_input("Enter file name: ")

    f = open(name, "r")
    if os.path.isfile(name):
        searchline = raw_input("enter search phrease: ")
        searchlines = f.readlines()
        for i, line in enumerate(searchlines):
            if searchline in line:
                for l in searchlines[i:i+2]:
                    print l,
                print
except IOError as e:
    print "I/O error ({0}): {1}".format(e.errno, e.strerror)

request pers second apache

tail -f access.log|perl -e 'while (<>) {$l++;if (time > $e) {$e=time;print "$l\n";$l=0}}'

czwartek, 1 maja 2014

very very basic swing java app

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class App
{
    public static void main(String[] args)
    {
        //Swing Thread
        SwingUtilities.invokeLater(new Runnable()
        {
            public void run()
            {
                //main window
                JFrame frame = new JFrame("jMdev");
                frame.setSize(500,400);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        });

    }
}

poniedziałek, 28 kwietnia 2014

Scanner & Open File - Java

package com.marek.Files;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;

public class openFile
{
    public static void main(String[] args)
    {
        try
        {
            System.out.print("Please Enter file name: ");
            String fName;
           
            Scanner scanIn = new Scanner(System.in);
            fName = scanIn.nextLine();
            BufferedReader br = new BufferedReader(new FileReader(fName));
            String sCurrentLine;
            try
            {
            while ((sCurrentLine = br.readLine()) !=null)
            {
                System.out.println(sCurrentLine);
            }
            }
            finally
            {
                br.close();
                scanIn.close();
            }
        }
        catch (IOException e)
        {
            //e.printStackTrace();
            System.out.println("No such file..");
        }
    }
}

how to check if file is empty - Java

File f = new File(fileName);

try  
{
     if( f.length() == 0 )
     {
          f.createNewFile();
     }  
     else  
     {
            doSomething()
     }
} 
catch (IOException e)  
{
        System.out.println("IO Error: " + e.getMessage());
} 
    finally  
{

enable/disable glass fish app

cd $GLASS_FISH_HOME
for example:

/u01/usr/local/glasshfish3/glassfish/bin

asadmin disable appname
asadmin enable appname

 [root@kaukaz bin]# ./asadmin enable SwdDiagnostic
Enter admin user name>  admin
Enter admin password for user "admin">
remote failure: Unknown plain text format.  A properly formatted response from a PlainTextActionReporter
always starts with one of these 2 strings: PlainTextActionReporterSUCCESS or PlainTextActionReporterFAILURE.  The response we received from the server was not understood: Signature-Version: 1.0
message: Exception while preparing the app
Exception [EclipseL
 ink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): or
 g.eclipse.persistence.exceptions.DatabaseException
Internal Exception
 : java.sql.SQLException: Error in allocating a connection. Cause: Con
 nection could not be allocated because: ORA-01017: niepoprawna nazwa
 uĹŸytkownika/hasĹo; odmowa zalogowania

 [root@kaukaz bin]# ./asadmin enable SwdDiagnostic
Enter admin user name>  admin
Enter admin password for user "admin"

Command enable executed successfully

wtorek, 22 kwietnia 2014

oracle-xe ubuntu starting problem

problem:

root@lati:/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin# ./oracle_env.sh
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/nls_lang.sh: 108: /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/nls_lang.sh: [[: not found
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/nls_lang.sh: 110: /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/nls_lang.sh: [[: not found
root@lati:/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin# ./nls_lang.sh
./nls_lang.sh: 108: ./nls_lang.sh: [[: not found
./nls_lang.sh: 110: ./nls_lang.sh: [[: not found

solution:
in /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/nls_lang.sh
change:
#!/bin/sh
to
#!/bin/bash

ubuntu oracle-xe path

/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin

sed - how to add something in front of line

1. marek@lati:/tmp$ cat test
marek
sed
awk
linux

2. make change only in output
marek@lati:/tmp$ sed 's/^/....../g' test
......marek
......sed
......awk
......linux

3. add few "." in the front of the line and save it to source file

marek@lati:/tmp$ sed -i 's/^/....../g' test
marek@lati:/tmp$ cat test
......marek
......sed
......awk
......linux
 

poniedziałek, 14 kwietnia 2014

eclipse problem

problem:

root@lati:~/.eclipse/org.eclipse.platform_3.7.0_155965261/configuration# cat 1397493884904.log
!SESSION 2014-04-14 18:44:44.801 -----------------------------------------------
eclipse.buildId=I20110613-1736
java.version=1.7.0_51
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=pl_PL
Command-line arguments:  -os linux -ws gtk -arch x86_64

!ENTRY org.eclipse.osgi 4 0 2014-04-14 18:44:49.097
!MESSAGE Application error
!STACK 1
java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
    no swt-gtk-3740 in java.library.path
    no swt-gtk in java.library.path
    Can't load library: /home/marek/.swt/lib/linux/x86_64/libswt-gtk-3740.so
    Can't load library: /home/marek/.swt/lib/linux/x86_64/libswt-gtk.so

solution:

Ubuntu 12.04 32 bit. I edit the command to:
ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86/
 
And on Ubuntu 12.04 64 bit try:
ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86_64/

niedziela, 13 kwietnia 2014

install jdk mint linux

1.  sudo apt-get update && apt-get remove openjdk*
2. download newest version from oracle.com
3. "unzip" jdk archive  tar -zxvf jdk-
4.  sudo mkdir -p /opt/java
5.  sudo mv jdk1.7.0_25 /opt/java
6.  sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.7.0_25/bin/java" 1
sudo update-alternatives --set java /opt/java/jdk1.7.0_25/bin/java



how to enable autologin in weblogic

goto:
for example

/home/marek/as/weblogic/wl/user_projects/domains/mbo/servers/AdminServer

make dir: security

cd sercurity

vi boot.properties

username=weblogic
password=password1234

after  first start inside of this file we find:

<2014-04-13 11:20:49 CEST> <Notice> <Security> <BEA-090083> <Storing boot identity in the file: /home/marek/as/weblogic/wl/user_projects/domains/mbo/servers/AdminServer/security/boot.properties.>


[marek@localhost security]$ cat boot.properties
#Sun Apr 13 11:20:49 CEST 2014
password={AES}Ka1REcyH2XCTR04sH1231231231231231231231pQ\=
username={AES}5YSNvhM7R+j5RFRuXuKHoTZawFEjxCip1h4yytjzI9k\


sobota, 12 kwietnia 2014

add repository/source to eclipse

Scala source
1. Open Eclipse
2. Click Help / Install New Software
3. Click add and enter:
http://download.scala-ide.org/sdk/helium/e38/scala210/stable/site

Eclipse start whole process and after that process you need to restart the IDE

files from rpm package

How Do I List Files For Installed Package?

You need to use rpm command as follows:




[marek@localhost Pobrane]$ rpm -ql sqldeveloper


alernative


rpm -qlp sqldeveloper-4.0.1.14.48-1.noarch.rpm




Remi repo fedora

## Fedora 20 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-20.rpm

## Fedora 19 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-19.rpm
 
## Fedora 18 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-18.rpm
 
## Fedora 17 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-17.rpm
 
yum must remember to enable remi repo in:
 
[marek@localhost ~]$ cat /etc/yum.repos.d/remi.repo 
[remi]
name=Les RPM de remi pour Fedora $releasever - $basearch
#baseurl=http://rpms.famillecollet.com/fedora/$releasever/remi/$basearch/
mirrorlist=http://rpms.famillecollet.com/fedora/$releasever/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
 

piątek, 11 kwietnia 2014

discover active hosts in network

[marek@localhost Dokumenty]$ nmap -sP 192.168.0.0/24

Starting Nmap 6.40 ( http://nmap.org ) at 2014-04-11 22:30 CEST
Nmap scan report for 192.168.0.1
Host is up (0.0064s latency).
Nmap scan report for 192.168.0.10
Host is up (0.0095s latency).
Nmap scan report for 192.168.0.11
Host is up (0.000091s latency).
Nmap done: 256 IP addresses (3 hosts up) scanned in 2.94 seconds

czwartek, 10 kwietnia 2014

Fedora 20 flash player instalation

1.
su -c 'yum -y install http://linuxdownload.adobe.com/adobe-release/adobe-release-x86_64-1.0-1.noarch.rpm'
2. rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux
3. yum -y install flash-plugin    

file name change script

#!/usr/bin/bash

for i in UI*.java
do
        new="G${i}"
        echo $i ' ==> ' $new
        mv $i $new
done

poniedziałek, 7 kwietnia 2014

jsp connected to oracle-xe instance

<%@ page import="java.sql.*" %>

<HTML>
<HEAD>
<TITLE>Oracle Connection</TITLE>
</HEAD>
<BODY>
<%
    Connection conn = null;
    try
    {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "login", "pass");
        out.println("connected....!!");

    }

    catch(Exception e)
    {
        out.println("Exception : " + e.getMessage() + "");
    }


%>
</BODY>
</HTML>

create DB user with admin rights

CREATE USER username IDENTIFIED BY password;
then separately grant privileges with ADMIN OPTION;
GRANT dba TO username WITH ADMIN OPTION;
 
SQL> alter user marek identified by pass;

User altered. 

how to make heap dump

how to make gc heap dump

1. [marek@localhost bin]$ jcmd 8560 GC.heap_dump /tmp/test1.dump
    8560:
    Heap dump file created
2. Read file

[marek@localhost bin]$ jhat -port 7777 -J-mx4G /tmp/test1.dump
Reading from /tmp/test.dump...
Dump file created Mon Apr 07 15:04:00 CEST 2014
Snapshot read, resolving...
Resolving 819250 objects...
Chasing references, expect 163 dots...................................................................................................................................................................
Eliminating duplicate references...................................................................................................................................................................
Snapshot resolved.
Started HTTP server on port 7777
Server is ready.

jcmd - very usefull tool

jcmd - new diagnistic tool from jdk 7 package. Very usefool in all jvm administration processes.

very small example:

1. man jcmd
2. jcmd - process list
3. available options to run

[marek@localhost mb]$ jcmd 7607 help
7607:
The following commands are available:
VM.native_memory
VM.commercial_features
ManagementAgent.stop
ManagementAgent.start_local
ManagementAgent.start
Thread.print
GC.class_histogram
GC.heap_dump
GC.run_finalization
GC.run
VM.uptime
VM.flags
VM.system_properties
VM.command_line
VM.version
help

.....


[marek@localhost mb]$ jcmd 8560 PerfCounter.print | grep java.property.java.vm
java.property.java.vm.info="mixed mode"
java.property.java.vm.name="Java HotSpot(TM) 64-Bit Server VM"
java.property.java.vm.specification.name="Java Virtual Machine Specification"
java.property.java.vm.specification.vendor="Oracle Corporation"
java.property.java.vm.specification.version="1.7"
java.property.java.vm.vendor="Oracle Corporation"
java.property.java.vm.version="24.51-b03"



piątek, 14 marca 2014

Ubuntu oracle jdk repo

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

środa, 12 marca 2014

poniedziałek, 24 lutego 2014

Restore ubuntu boot screen

root@lapek:~# sudo update-alternatives --config default.plymouth
Są 2 dostępne alternatywy dla default.plymouth (dostarczające /lib/plymouth/themes/default.plymouth).

  Wybór       Ścieżka                                                Priorytet  Status
------------------------------------------------------------
* 0            /lib/plymouth/themes/kubuntu-logo/kubuntu-logo.plymouth   150       tryb auto
  1            /lib/plymouth/themes/kubuntu-logo/kubuntu-logo.plymouth   150       tryb ręczny
  2            /lib/plymouth/themes/ubuntu-logo/ubuntu-logo.plymouth     100       tryb ręczny

Proszę wcisnąć Enter, aby pozostawić bieżący wybór[*]; albo wpisać wybrany numer: 2
update-alternatives: using /lib/plymouth/themes/ubuntu-logo/ubuntu-logo.plymouth to provide /lib/plymouth/themes/default.plymouth (default.plymouth) in tryb ręczny
root@lapek:~# sudo update-initramfs -u
update-initramfs: Generating /boot/initrd.img-3.5.0-46-generi

środa, 19 lutego 2014

Resource leak - java eclipse

good way:

When you write a code like bellow:


import java.util.Scanner;

public class userio
{
    public static void main(String[] args)
    {
      
        Scanner input = new Scanner(System.in);
      
        System.out.print("Enter a line of text: ");
      
        String line = input.nextLine();
      
        System.out.println("you entered: "+line);
    }
}

in marked line you always have warning when you write your code in eclipse.
Eclipse suggest you that you have resources leak. To eliminate this problem use case like bellow


import java.util.Scanner;

public class userio
{
    public static void main(String[] args)
    {

            Scanner input = new Scanner(System.in);
            try
            {
                System.out.print("Enter a line of text: ");
                String line = input.nextLine();
                System.out.println("you entered: "+line);
            }
            finally
            {
                input.close();
            }
    }
               
}

--------------------------



piątek, 14 lutego 2014

eclipse shortcut

usefull shortcut to use alternativly to: System.out.println() in java:

type Sysout or syso and press ctrl+space



nmcli fedora20

[marek@localhost log]$ nmcli connection show active
NAZWA              UUID                                               URZĄDZENIA  DOMYŚLNE  VPN  GŁÓWNA-ŚCIEŻKA 
Połączenie Orange  079fa768-31c6-421f-9a0e-b29e654588f1  ttyACM1                    tak       nie  -


nmcli connection up/down id "Połączenie Orange"

czwartek, 13 lutego 2014

connection test

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

GET /index.html HTTP/1.0

HTTP/1.1 200 OK
Date: Thu, 13 Feb 2014 10:17:11 GMT
Server: Apache/2.4.6 (Ubuntu)
Last-Modified: Thu, 13 Feb 2014 10:16:24 GMT
ETag: "b1-4f246fb464b2b"
Accept-Ranges: bytes
Content-Length: 177
Vary: Accept-Encoding
Connection: close
Content-Type: text/html

<html><body><h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body></html>
Connection closed by foreign host.


python substitute:

#!/usr/bin/python

import socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("www.google.pl",80))
s.send("GET /index.html HTTP/1.0\n\n")
data = s.recv(10000)
print "received data: ",data
s.close()



python socket practice

#!/usr/bin/python

import socket
host = ['www.google.pl','www.onet.pl','www.facebook.com','www.redhtube.com','www.youtube.com']
for h in host:
        ip = socket.gethostbyname(h)
        print "ip: ",ip ,"host:",h

wtorek, 11 lutego 2014

use deb package in Fedora/Redhat distros

Remeber you always can install and use alien but

for this purpse i use:

ar - create, modify, and extract from archives

output:

[root@localhost Pobrane]# ar vx ubuntu-wallpapers-saucy_13.04.0+13.10.20130823-0ubuntu1_all.deb
x - debian-binary
x - control.tar.gz
x - data.tar.gz