четверг, 26 ноября 2015 г.
My working minimal pom.xml
(c) http://habrahabr.ru/post/126966/
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany.projectgroup</groupId> <artifactId>projectname</artifactId> <version>01.03.03-00</version> <build> </build></project>
суббота, 31 октября 2015 г.
понедельник, 14 сентября 2015 г.
Finding palindrome in array in Java
static ArrayList<String> arr = new ArrayList<>();
public static void palidrome() throws IOException {
InputStream fis = new FileInputStream("C://tmp/palidrome.txt");
InputStreamReader isr = new InputStreamReader(fis, Charset.forName("UTF-8"));
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) arr.add(line);
for (int i=0; i<arr.size(); i++) {
if (!isPal(arr.get(i))) arr.set(i, "-1");
System.out.println(arr.get(i));
}
}
public static boolean isPal(String str) {
int i=0; int k = str.length()-1;
while (i<=k) {
if (str.charAt(i)==str.charAt(k) ) {
i++;
k--;
}
else return false;
}
return true;
}
воскресенье, 6 сентября 2015 г.
Quicksort in Java example
quicksort is the fastest sorting algorithm, and here is example of method in Java:
static public void quickSort(int[] arr, int l, int r) {It needs to be called like this:
int left = l; int right = r; int tmp;
int middle = arr[(left + right) / 2];
while (left <= right) {
while (arr[left]<middle) left++;
while (arr[right]>middle) right--;
if (arr[left]>arr[right]) {
tmp = arr[left];
arr[left] = arr[right];
arr[right] = tmp;
}
}
if (left<r) quickSort(arr, left, r);
if (l<right) quickSort(arr, l, right);
}
public static void main(String args[]) {
int[] array = { 4, 23,65, 76, 99, 12, 90, 34 }
quickSort(array, 0, array.length-1)
}
вторник, 25 августа 2015 г.
JAVA convert string[] to binary array
piece of code:
byte[] byt = MESSAGE.getBytes();
String bin = "";
for (int i : byt) bin += Integer.toBinaryString(i);
System.err.println(bin);
среда, 29 июля 2015 г.
Helloworld in Java Graphics2D
For this need to make 2 classes with names Painting and Frame. In my situation I have package named graphh
Painting.class:
Frame.class:
If you are using Eclipse just press Run button
Taken from https://www.youtube.com/watch?v=U2G_2AS0otE
Painting.class:
package graphh;
import java.awt.*;
import javax.swing.*;
public class Painting extends JPanel {
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawOval(60, 80, 20, 20);
}
}
package graphh;
import java.awt.*;
import javax.swing.*;
public class Frame {
public Frame() {
JFrame gui = new JFrame();
gui.setTitle("fsdfdsf");
gui.setSize(400, 300);
gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Painting panel = new Painting();
Container pane = gui.getContentPane();
pane.setLayout(new GridLayout(1, 1));
pane.add(panel);
gui.setVisible(true);
}
public static void main(String args[]) {
new Frame();
}
}
Taken from https://www.youtube.com/watch?v=U2G_2AS0otE
среда, 22 июля 2015 г.
Cannot add icons in KDE
Simply add extracted icons into /usr/share/icons and restart KDE Icons Settings window.
How to fix tk and tkinter error in Arch
In Arch, if you have similar error:
Just install short package named tk from official packages.$ Traceback (most recent call last):
File "main.pyw", line 43, in <module>
run_main()
File "main.pyw", line 31, in run_main
import src.app
File "/run/media/dc/62AA14DBAA14AD93/Program Files (x86)/LearningEnglish-master/src/
app.py", line 7, in <module>
from GUI import MainWindow
File "/run/media/dc/62AA14DBAA14AD93/Program Files (x86)/LearningEnglish-master/src/
GUI.py", line 3, in <module>
from tkFont import Font
File "/usr/lib/python2.7/lib-tk/tkFont.py", line 11, in <module>
import Tkinter
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: libtk8.6.so: cannot open shared object file: No such file or directory
Do not show window title in Opera and KDE
When you want to quickly switch between Opera tabs, you need to remove common window borders.
- go to the System Settings > Window Management > tab Window rules, press New...
- press on Detect Window Properties and click and drag on Opera window
- in new window press Ok
- in tab Appearance & Fixes add tick on No titlebar and frame, in dropdown list select Apply initially, and select Yes
- in previous tab enter own name of rule
- Don't forget to press Ok and in Window Rules press Apply on bottom
вторник, 21 июля 2015 г.
Подписаться на:
Сообщения (Atom)