Saturday 22 October 2016

Spring and International Caps Lock Day

Well, as the wiki says, today is international caps day.
June 28 and October 22 are biannually observed as International CAPS LOCK DAY as a parody holiday created in October 2000 by Derek Arnold, a user on Metafilter. The second observation on June 28 was added by Arnold in memory of American pitchman Billy Mays.[7][8][9][10]

Saturday 15 October 2016

Weekend, new books, some free time to do something creative.

Well, after a full 40hours works week I am totally drained out. But it is okay, I will be rich in no time :cutting_veins:. I'v ordered some books... frankly I wont have enought time to get through all of them haha.
1)Spring MVC 4 by Geoffroy Warin
2)Spring framework by J Sharma, Ashish Sarin
3)Spring recipes by Gary Mak, Josh Long, Daniel Rubio
4)Java 8 by Cay S. Hortsmann
5)Clean code by Robert C. Martin.
I will start with "clean code". They say that this book is basic for every developer. I hope that I will learn something from it. Btw. Listen this shit, really, It melts brain. Anyway stay tuned, I will show something you soooooooooooooooon.

Wednesday 12 October 2016

Wasn't here for a long time, hos ?

Hello guys, sorry for not being here for a long time but : 1)I'v got a job. Yes, normal job - I am assembling refrigerators - sounds good, right? I am waking up at 5:30, drinking a coffee, eating meat and before 6:30 I am riding on my bike to the place where I work. 2)My pc gave up on me and died. I was forced to get new graphic card and hard disk. I'v bought saphire radeon r9 380x 4gb and ssd 300gb from GoodRam. Now I am installing all stuff and getting back to work. Stay tuned, I will post some sick shit soon. I am going to write a social network in spring. Have a nice day %-)

Thursday 22 September 2016

I give up on C#.

Well, during thinking about my ftp client i started to see that I lack a lot of knowledge from Java, mainly from design patterns. So for now I am changing my plans - at first I will learn design patterns and slowly write code of the client. I found really good lessons on caveofprogramming.com and in "Head first design patterns" AFter this I move to web dev. I know the basics of servlets and jsps so I will start with spring. It will be a long journey, wish me good luck!!!

Swing - populate JTable with files' names.

I am working on a gui for ftp client. I am using swing for gui and Apache Commons Net for ftp stuff. I still have problem with displaying icons in JTable. Later I will use MVC pattern. I am able to listen files' paths, size and modification date. Soon I will add more funcionality like changing directories, showing icons and basic operation on files and folder like: delete,cut,copy,change name, move but this all after I finish gui. Whole code on my github: GITHUB Code below:
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.File;
import java.text.SimpleDateFormat;

import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.filechooser.FileSystemView;
import javax.swing.table.DefaultTableModel;

public class LeftPanel extends JPanel {

 private JTable table;
 private NavigationPanel backAndDriverPanel;

 private String[] columns = { "Path", "Size", "Last Modified" };
 private File file;
 private File[] filesNames;

 private final String DIR = "C:/";

 public LeftPanel() {

  Dimension dimension = getPreferredSize();
  dimension.width = 640;
  setPreferredSize(dimension);
  setLayout(new BorderLayout());

  // CREATING COMPONENTS
  table = new JTable();
  backAndDriverPanel = new NavigationPanel();

  table.setAutoCreateRowSorter(true);
  table.setFocusable(false);
  table.setRowSelectionAllowed(true);

  JScrollPane tableScroll = new JScrollPane(table);

  // ADDING COMPONENTS TO PANEL
  add(tableScroll, BorderLayout.CENTER);
  add(backAndDriverPanel, BorderLayout.PAGE_START);

  createTableModel();

 }

 public void createTableModel() {

  // DATE FORMAT
  SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");

  file = new File(DIR);

  filesNames = file.listFiles();

  DefaultTableModel model = (DefaultTableModel) table.getModel();
  model.setColumnIdentifiers(columns);

  // LIST OF ROWS
  Object[] row = new Object[3];
  for (int i = 0; i < filesNames.length; i++) {

   row[0] = filesNames[i].getAbsolutePath();
   row[1] = filesNames[i].length();

   // CONVERTING FROM MILISECONDS TO NORMAL DATE
   row[2] = sdf.format(filesNames[i].lastModified());

   model.addRow(row);
  }

  // SETING EDITABLE TO FALSE
  for (int i = 0; i < table.getColumnCount(); i++) {

   Class<?> col_clas = table.getColumnClass(i);
   table.setDefaultEditor(col_clas, null);
  }

 }
}

via GIPHY

Friday 16 September 2016

What to do now?

Today I'v decided that I am starting learning C#. Why? Because I want to learn how to read memory and toy with it. I was trying to do so with Java but it is hard. You have to use additional library and there was still a problem with accessing all processes. I was able to "hack" Minesweeper and change the time and number of mines. What about Java? Still in it. I will move to learning Spring. I don't know if learning two languages at once is a good idea but let's give it a shot. Also I'v borrowed two books.
1) Algorithms and data structures = Programs 2)Projecting and analysis computer algorithms.
happy coding!

Sunday 11 September 2016

Today I was training algorithms and data structures on hackerrank.com. Here is one example:

Given a square matrix of size NxN, calculate the absolute difference between the sums of its diagonals.


import java.util.Scanner;

public class DiagonalAbsoluteSum {

 static int sumA = 0;
 static int sumB = 0;

 public static void main(String[] args) {
  Scanner in = new Scanner(System.in);
  int n = in.nextInt();
  int a[][] = new int[n][n];
  for (int a_i = 0; a_i < n; a_i++) {
   for (int a_j = 0; a_j < n; a_j++) {
    a[a_i][a_j] = in.nextInt();
   }
  }

  for (int i = 0; i < a.length; i++) {
   sumA += a[i][i];
  }

  for (int i = 0; i < a.length; i++) {

   sumB += a[i][a.length - i - 1];
  }

  System.out.println(Math.abs(sumA - sumB));
 }

}