Wednesday, November 27, 2013

Java .class version

javap - The Java Class File Disassembler



Usage


   javap -verbose YourClass

Output

  ...
  SourceFile: "YourClass.java"
  minor version: 0
  major version: 50
  flags: ACC_PUBLIC, ACC_SUPER
  ...

Major version

J2SE 7 = 51,
J2SE 6.0 = 50,
J2SE 5.0 = 49,
JDK 1.4 = 48,
JDK 1.3 = 47,
JDK 1.2 = 46,
JDK 1.1 = 45

Ref:
http://reverseengineering.stackexchange.com/questions/1328/find-out-a-java-class-files-compiler-version
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javap.html

Tuesday, November 12, 2013

Postgres tips

Log to database

psql -p port -U user database

Show databases

\l

Show tables

\d

Describe table

\d+ table_name


Exit

\q

Import script from terminal

(when database was exported in sql file)
psql -p port -U user -d dest_db -a -f fileName.sql
   (psql -U prov -d prov -a -f model-prov.sql)

Select TOP 5 records, char_length

SELECT string1, char_length(string1) FROM table1 ORDER BY createDate DESC LIMIT 5;

Dump (export) database

pg_dump -U user source_db -p port -f fileName.sql

List sequences

\ds
or by using SQL:
SELECT c.relname FROM pg_class c WHERE c.relkind = 'S';

list sequence dependencies

SELECT p.relname, a.adsrc FROM pg_class p JOIN pg_attrdef a ON (p.relfilenode = a.adrelid);

To get last value of a sequence use the following query:

SELECT last_value FROM test_id_seq;

remove a sequence


DROP SEQUENCE sequenceName;

Change column type


ALTER TABLE ad_hoc_history ALTER COLUMN parameters TYPE text;
(http://www.postgresql.org/docs/9.3/static/sql-altertable.html)

* change the size of a varchar column:
ALTER TABLE simlocation ALTER COLUMN location TYPE varchar(30);

drop constrain (NOT NULL)


ALTER TABLE table ALTER COLUMN column DROP NOT NULL;

Is some range present in system


Table is msisdn and msisdn is key, but it is string.
select count(*) from msisdn where to_number(msisdn,'9999999999999') >=4366305707030 and to_number(msisdn,'9999999999999') <=4366305712029;

Ref:
http://www.postgresqlforbeginners.com/2010/11/interacting-with-postgresql-psql.html
http://www.postgresql.org/docs/9.3/static/app-psql.html
http://www.postgresql.org/docs/9.3/static/functions-string.html
dump:
http://www.thegeekstuff.com/2009/01/how-to-backup-and-restore-postgres-database-using-pg_dump-and-psql/
http://www.postgresql.org/docs/9.3/static/app-pgdump.html
sequences:
http://www.neilconway.org/docs/sequences/
http://blog.sensible.io/2013/08/24/postgresql-sequences-and-array-column-types.html http://www.linuxtopia.org/online_books/database_guides/Practical_PostgreSQL_database/PostgreSQL_x14316_001.htm
http://www.techonthenet.com/postgresql/functions/to_number.php

Linux tips

yum manager

The Yellowdog Updater, Modified (yum) is an open-source command-line package-management utility for Linux operating systems using the RPM Package Manager. Though yum has a command-line interface, several other tools provide graphical user interfaces to yum functionality. Yum allows automatic updates, package and dependency management, on RPM-based distributions. Yum works with software repositories (collections of packages), which can be accessed locally or over a network connection.

install: yum install mvno-paygw
find: yum search mvno-paygw
update: yum update mvno-paygw
info: yum info mvno-paygw  (information about package; what version is on repository)
check-update: Checks to see whether updates are available. If they are, yum displays their names, version and repository area.
provides: searches for which packages provide the requested dependency of file. This also takes wildcards for files. E.g. yum provides */ldapsearch

Process status

ps -ef | grep java

Change password for current user

passwd

Change password for user by using root account

sudo su
passwd someUser

Check if port 80 is open

netstat -tulpn | grep :80

Download web page

wget localhost:80/bugzilla

List hosts file

cat /etc/hosts

Copy file

cp [OPTION]... SOURCE... DIRECTORY
cp /wsdls/EID_Provision-V0.5.wsdl /var/opt/wsdls/EID_Provision-V0.5.wsdl

Delete file

rm fileName

Remove a directory and its contents without prompting you to make sure you want to delete each file in the directory.
rm -rf directory

Zip file

zip dest.zip sourceFile

The following command compresses the file archivefile1.txt and replaces it with the compressed version named "archivefile1.txt.bz2". bzip2 creates smaller files.
bzip2 archivefile1.txt

Read file/logs
[sudo] tail -100f /var/log/someLogFile.log

copy sourceFile.zip to another comp to user directory

 scp ./sourceFile.zip 10.200.0.133:./
(scp source_file_name username@destination_host:destination_folder)


Find 56952849307 that occured at 2015-02-06 10:2x in provisioning.log file
cat provisioning.log | grep "2015-02-06 10:2.*56952849307" | more
grep -A 3 "stringToFind" fileName   // show 3 lines after
grep -B 3 "stringToFind" fileName   // show 3 lines before
grep -C 3 "stringToFind" fileName   // show 3 lines around

Find 56952849307 in all files that begin with provisioning (e.g. provisioning.log.1)
ls provisioning* | xargs cat | grep 56952849307

Find USSD word in all provisioning.log files and show next 5 lines
cat /var/log/provisioning.log.* | grep MOVILB -A 5

grep all files in current directory for exact match:
grep -F "SIM card was deleted. MSISDN" *

dump tcp traffic to file
tcpdump -i any -w /tmp/test_001.pcap

ssh remote host identification has changed
ssh-keygen -R hostname

Change permission on folder
if needed switch to root user
$ sudo su
$ chmod -R 777 folderName

Ref:
15 Practical Grep Command Examples In Linux / UNIX

Unix Less Command: 10 Tips for Effective Navigation
How To Use Linux Screen