Are you familiar with the wc
(word count) command? Here is what it does:
$ wc test.txt -l
33 //number of lines in test.txt
$ wc test.txt -w
165 //number of words in test.txt
public class ImageSlicer { | |
public static void main(String[] args) throws IOException { | |
if (args.length < 3) { | |
System.out.println("Usage: java -jar imageSlicer.jar /path/to/image.jpg <number-of-pieces-wide> <number-of-pieces-high>"); | |
System.out.println("Usage: java -jar imageSlicer.jar /home/georgi/Desktop/sarah.jpg 4 4"); | |
return; | |
} | |
Path imagePath = Paths.get(args[0]); | |
int piecesWide = Integer.parseInt(args[1]); | |
int piecesHigh = Integer.parseInt(args[2]); |
След като минахме основите на езика и основните структури от данни, преминахме на използването на библиотеки. В днешно време почти всичко, което се прави, се използва библиотеки. | |
Първо започнахме с проста задачка - хората трябваше да напишат java приложение, което на 45 минути изкарва съобщения в системния tray потребителят да си почине, защото е натоварил очите си. | |
След което продължихме с друга просто задача - хората трябваше да направят QuickCodeInspector приложение, чрез което при отваряне на .java файл да се показва прозорец, показващ java кода на файла, но със syntax highlighting :) | |
(Скрийншот, подходящо е за картинка) | |
http://i.imgur.com/JPvIXJ5l.jpg | |
Добра имплементация може да се види тук: https://github.com/mirena92/HackBulgaria/tree/master/8-WorkingWithLibraries |
1.Master branch-a ВИНАГИ е deployable! | |
В master-a винаги имате нещо стабилно, работещо, deployable. Ако почвате да правите нови неща (например сте направили конзолен TicTacToe и решавате да добавите GUI), правете си feature branch-ове и работете в тях. В момента, в който нещата са готови и стабилни, push-нете ги в Github и ги merge-нете в master. | |
Just github workflow, нищо специално. | |
2. build folder | |
Много хубаво си качваме целия код в github, но хората, които ще го гледат, не трябват да слагат Eclipse-и, maven–и и т.н, за да ни компилират кода, та да видят какво сме правили. Не е яко. Затова си правете една 'build' папка, в която да държите jar-овете, които са резултата от нашия код - дали application или library. |
# You will need to install Tor in order for this to work. | |
# Install from Tor's official website. | |
# Set your own 'lucky' URL here | |
URL='http://sublimetexttips.com/giveaways/sublime-text-giveaway/?lucky=139418' | |
#Create temporary 10 min email address and fetch the address | |
require 'rubygems' | |
require 'json' |
Approach1: Group all files by the hashcode of their bytes.
Use a Map<Long, List<Path>>
to represent them.
Here, the key is the hashCode of all the bytes from a File.
The algorithm:
For each file(ancestor) of the folder given
bytes = Files.read(file);
hashCode = Arrays.hashCode(bytes);
//package com.hackbulgaria.corejava.oopfun; | |
//or similiar | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
public class Console { | |
private BufferedReader reader; |
@Override | |
public long getSmallestMultiple(int upperBound) { | |
long result = 1; | |
for (int i = 2; i <= upperBound; i++) { | |
int[] divisors = getDivisors(i); | |
int pointer = 0; | |
while (result%i != 0){ | |
result*=divisors[pointer++]; | |
} |
@Override | |
public long getSmallestMultiple(int upperBound) { | |
long result = 1; | |
for (int i = 2; i <= upperBound; i++) { | |
int[] divisors = getDivisors(i); | |
int pointer = 0; | |
while (result%i != 0){ | |
result*=divisors[pointer++]; | |
} | |
} |