Будущее России на 200 лет |
|
Метки: Седьмой технологический уклад Будущее России на 200 лет |
Convert XML or JSON to Java Pojo Classes - Online |
|
Метки: Convert XML or JSON to Java Pojo Classes - Online |
factorial |
import java.math.BigInteger;
import java.util.stream.LongStream;
import static java.lang.System.out;
import static java.math.BigInteger.ONE;
public class StreamFactorial {
public static void main(String[] args) {
//printFactorialOf(100);
long time = System.currentTimeMillis();
printFactorialOf(100_000);
System.out.println(System.currentTimeMillis() - time +" ms");
}
static void printFactorialOf(long num) {
out.println("factorial" + "\n" +" of " + num + "\n" +" is " + factorial(num)
);
}
static BigInteger factorial(long num) {
return LongStream.rangeClosed(1, num).mapToObj(BigInteger::valueOf).parallel().reduce(ONE, BigInteger::multiply);
}
}
|
Метки: factorial java 8 |
JsonItem Json |
java.io.Serializable;
java.text.SimpleDateFormat;
javax.json.Json;
javax.json.JsonObject;
javax.json.JsonObjectBuilder;
public abstract class AbstractEntity implements JsonItem,
Serializable{
@Override
public JsonObject toJson() {
JsonObjectBuilder builder = Json.createObjectBuilder();
addJson(builder);
return builder.build();
}
}
@Override
public void addJson(JsonObjectBuilder builder) {
builder.add("idCompany", idCompany)
.add("companyName", companyName);
}
|
Метки: Json AbstractEntity |
Мир и вселенная вокруг и внутри нас |
|
Метки: мир вселенная планеты |
spring RepositoryRestResource |
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource(collectionResourceRel = "jsonProjects", path = "jsonProjects")
public interface ProjectRepository extends CrudRepository {
List findById(@Param("name") String name);
}
@Override
protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
super.configureRepositoryRestConfiguration(config);
try {
config.setBaseUri(new URI("/api"));
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
|
Метки: spring RepositoryRestResource |
Худение |
|
Метки: Худение |
GilbertIterator - Решение рекурсивного генератора (заполняющей кривой Гилберта) |
var g = document.getElementById('c').getContext('2d');
var path=[];//массив точек
//нулевой уровень = коробка без стенки слева
path.push({x:0,y:0});
path.push({x:1,y:0});
path.push({x:1,y:1});
path.push({x:0,y:1});
var len=1;//размер нулевого уровня
for(var level=0;level<5;level++){//цикл генерирует кривую пятого уровня
var cnt=path.length;
var newpath=[];
//на каждом уровне делаем четыре копии массива точек так,
//чтобы в итоге сохранялась правильная последовательность, и тогда в конце их можно будет просто соединить линиями
for(var i=0;i/первую копию транспонируем
newpath[i]={};
newpath[i].x=path[i].y;
newpath[i].y=path[i].x;
}
for(var i=cnt;i/вторую копию просто смещаем вправо
newpath[i]={};
newpath[i].x=path[i%cnt].x+len+1;
newpath[i].y=path[i%cnt].y;
}
for(var i=cnt*2;i/третью копию смещаем вправо вниз
newpath[i]={};
newpath[i].x=path[i%cnt].x+len+1;
newpath[i].y=path[i%cnt].y+len+1;
}
for(var i=cnt*3;i/четвертую копию транспонируем вокруг побочной диагонали и смещаем вниз
newpath[i]={};
newpath[i].x=len-path[i%cnt].y;
newpath[i].y=len-path[i%cnt].x+len+1;
}
len=len*2+1;//размер увеличился
path=newpath;
}
var size=8;//размер отрезка
function line(p0,p1){
g.beginPath();
g.moveTo(p0.x*size+2,p0.y*size+2);
g.lineTo(p1.x*size+2,p1.y*size+2);
g.stroke();
}
var ind=1;
var cnt=path.length;
function rend(){//красиво рисуем
if(ind>=cnt)return;
line(path[ind-1],path[ind]);
ind++;
setTimeout(rend,10);
}
rend();
//нет рекурсий
|
|
java update upgrade |
Using worker: worker-linux-2-1.bb.travis-ci.org:travis-linux-14
git.1
0.09s$ git clone --depth=50 --branch=master git://github.com/BanzaiMan/travis_production_test.git BanzaiMan/travis_production_test
Cloning into 'BanzaiMan/travis_production_test'...
remote: Counting objects: 160, done.
remote: Compressing objects: 100% (113/113), done.
remote: Total 160 (delta 60), reused 113 (delta 40)
Receiving objects: 100% (160/160), 14.84 KiB | 0 bytes/s, done.
Resolving deltas: 100% (60/60), done.
Checking connectivity... done.
$ cd BanzaiMan/travis_production_test
git.4
$ git checkout -qf 6d9e59fa1c41886a429d75a1573569a882dab5c9
$ jdk_switcher use oraclejdk8
Switching to Oracle JDK8 (java-8-oracle), JAVA_HOME will be set to /usr/lib/jvm/java-8-oracle
$ java -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
$ javac -version
javac 1.8.0_05
before_script.1
11.42s$ sudo apt-get update -qq
before_script.2
104.18s$ sudo apt-get install oracle-java8-installer
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libgeos-3.2.2
Use 'apt-get autoremove' to remove them.
Suggested packages:
binfmt-support visualvm ttf-baekmuk ttf-unfonts ttf-unfonts-core
ttf-kochi-gothic ttf-sazanami-gothic ttf-kochi-mincho ttf-sazanami-mincho
ttf-arphic-uming
Recommended packages:
gsfonts-x11
The following packages will be upgraded:
oracle-java8-installer
1 upgraded, 0 newly installed, 0 to remove and 117 not upgraded.
Need to get 21.9 kB of archives.
After this operation, 4,096 B of additional disk space will be used.
Get:1 http://ppa.launchpad.net/webupd8team/java/ubuntu/ precise/main oracle-java8-installer all 8u20+8u6arm-1~webupd8~0 [21.9 kB]
Fetched 21.9 kB in 0s (76.4 kB/s)
Preconfiguring packages ...
(Reading database ... 71155 files and directories currently installed.)
Preparing to replace oracle-java8-installer 8u5-1~webupd8~3 (using .../oracle-java8-installer_8u20+8u6arm-1~webupd8~0_all.deb) ...
oracle-license-v1-1 license has already been accepted
Unpacking replacement oracle-java8-installer ...
Processing triggers for shared-mime-info ...
Setting up oracle-java8-installer (8u20+8u6arm-1~webupd8~0) ...
Downloading Oracle Java 8...
--2014-09-09 15:58:18-- http://download.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-linux-x64.tar.gz
Resolving download.oracle.com (download.oracle.com)... 23.67.60.56, 23.67.60.24
Connecting to download.oracle.com (download.oracle.com)|23.67.60.56|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-linux-x64.tar.gz [following]
--2014-09-09 15:58:18-- https://edelivery.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-linux-x64.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 184.86.70.140
Connecting to edelivery.oracle.com (edelivery.oracle.com)|184.86.70.140|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/otn-pub/java/jdk/8u20-b...c342e0896103bfbdda6dd5581f8e4e [following]
--2014-09-09 15:58:18-- http://download.oracle.com/otn-pub/java/jdk/8u20-b...c342e0896103bfbdda6dd5581f8e4e
Connecting to download.oracle.com (download.oracle.com)|23.67.60.56|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 160872342 (153M) [application/x-gzip]
Saving to: `jdk-8u20-linux-x64.tar.gz'
0K ........ ........ ........ ........ ........ ........ 1% 1.26M 2m0s
3072K ........ ........ ........ ........ ........ ........ 3% 2.64M 87s
6144K ........ ........ ........ ........ ........ ........ 5% 3.37M 71s
9216K ........ ........ ........ ........ ........ ........ 7% 3.37M 63s
12288K ........ ........ ........ ........ ........ ........ 9% 1.27M 71s
15360K ........ ........ ........ ........ ........ ........ 11% 945K 82s
18432K ........ ........ ........ ........ ........ ........ 13% 1.82M 79s
21504K ........ ........ ........ ........ ........ ........ 15% 1.75M 77s
24576K ........ ........ ........ ........ ........ ........ 17% 2.97M 72s
27648K ........ ........ ........ ........ ........ ........ 19% 1.65M 70s
30720K ........ ........ ........ ........ ........ ........ 21% 1.31M 71s
33792K ........ ........ ........ ........ ........ ........ 23% 2.40M 67s
36864K ........ ........ ........ ........ ........ ........ 25% 1.74M 66s
39936K ........ ........ ........ ........ ........ ........ 27% 2.67M 62s
43008K ........ ........ ........ ........ ........ ........ 29% 2.17M 60s
46080K ........ ........ ........ ........ ........ ........ 31% 1.33M 60s
49152K ........ ........ ........ ........ ........ ........ 33% 1.23M 59s
52224K ........ ........ ........ ........ ........ ........ 35% 1.21M 59s
55296K ........ ........ ........ ........ ........ ........ 37% 1.75M 57s
58368K ........ ........ ........ ........ ........ ........ 39% 2.76M 54s
61440K ........ ........ ........ ........ ........ ........ 41% 2.51M 52s
64512K ........ ........ ........ ........ ........ ........ 43% 1.64M 50s
67584K ........ ........ ........ ........ ........ ........ 44% 1.36M 49s
70656K ........ ........ ........ ........ ........ ........ 46% 3.96M 46s
73728K ........ ........ ........ ........ ........ ........ 48% 4.18M 43s
76800K ........ ........ ........ ........ ........ ........ 50% 4.08M 41s
79872K ........ ........ ........ ........ ........ ........ 52% 2.48M 39s
82944K ........ ........ ........ ........ ........ ........ 54% 2.45M 37s
86016K ........ ........ ........ ........ ........ ........ 56% 2.46M 35s
89088K ........ ........ ........ ........ ........ ........ 58% 1.51M 34s
92160K ........ ........ ........ ........ ........ ........ 60% 3.40M 32s
95232K ........ ........ ........ ........ ........ ........ 62% 2.74M 30s
98304K ........ ........ ........ ........ ........ ........ 64% 4.44M 28s
101376K ........ ........ ........ ........ ........ ........ 66% 2.76M 26s
104448K ........ ........ ........ ........ ........ ........ 68% 1.24M 25s
107520K ........ ........ ........ ........ ........ ........ 70% 1.84M 23s
110592K ........ ........ ........ ........ ........ ........ 72% 1.19M 22s
113664K ........ ........ ........ ........ ........ ........ 74% 1.03M 21s
116736K ........ ........ ........ ........ ........ ........ 76% 907K 20s
119808K ........ ........ ........ ........ ........ ........ 78% 830K 19s
122880K ........ ........ ........ ........ ........ ........ 80% 1.01M 18s
125952K ........ ........ ........ ........ ........ ........ 82% 988K 16s
129024K ........ ........ ........ ........ ........ ........ 84% 1.53M 14s
132096K ........ ........ ........ ........ ........ ........ 86% 1.09M 13s
135168K ........ ........ ........ ........ ........ ........ 87% 944K 11s
138240K ........ ........ ........ ........ ........ ........ 89% 1.52M 9s
141312K ........ ........ ........ ........ ........ ........ 91% 1.71M 8s
144384K ........ ........ ........ ........ ........ ........ 93% 1.36M 6s
147456K ........ ........ ........ ........ ........ ........ 95% 2.87M 4s
150528K ........ ........ ........ ........ ........ ........ 97% 1.70M 2s
153600K ........ ........ ........ ........ ........ ........ 99% 2.33M 0s
156672K ...... 100% 10.7M=92s
2014-09-09 15:59:51 (1.66 MB/s) - `jdk-8u20-linux-x64.tar.gz' saved [160872342/160872342]
Download done.
Removing outdated cached downloads...
removed `jdk-8u5-linux-x64.tar.gz'
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/javapackager to provide /usr/bin/javapackager (javapackager) in auto mode.
Oracle JDK 8 installed
Oracle JRE 8 browser plugin installed
0.12s$ java -version
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
The command "java -version" exited with 0.
Done. Your build exited with 0.
|
Метки: java update upgrade |
java getResource |
String url = this.getClass().getResource("").getPath();
URL url = getClass().getResource("/initialization/Lifepaths.txt");
InputStream strm = url.openStream();
|
Метки: getResource getResourceAsStream getResourceAsStream getResource Resource java |
Аппаратное ускорение в жизни верстальщика. Семинар в Яндексе |
|
Метки: javascript собеседованиеб |
Spring 3 и @Controller |
|
Метки: Spring 3 и @Controller ResponseBody RequestParam principal |
Редактирование полного списка автозапуска Ubuntu 11.10, 12.04 |
|
Метки: автозапуска Ubuntu |
Spring |
|
Метки: spring ldap dao |
Кьеркегор Сёрен – Дневник обольстителя 001 (S. Rai) |
|
Метки: книги читать |
spring android rest |
|
Метки: spring android |
Протокол Диффи-Хеллмана для обмена ключами (часть 2) |
|
|
Бизнес идея ! очки google |
|
Метки: Бизнес идея очки google |
java asm code |
|
Метки: java asm code |
Ubuntu netbeans fonts |
|
Метки: Ubuntu netbeans fonts |
Making the Android emulator run faster |
|
Метки: Making the Android emulator run faster |
Плавание |
|
Метки: Плавание |
Получить String из ByteBuffer |
code:
public static String toString (ByteBuffer byteBuffer, Charset charset)
{
if (byteBuffer.hasArray()) {
return new String(byteBuffer.array(), byteBuffer.arrayOffset() + byteBuffer.position(), byteBuffer.remaining(), charset);
}
else {
byte[] array = new byte[byteBuffer.remaining()];
int initialPosition = byteBuffer.position();
byteBuffer.get(array);
byteBuffer.position(initialPosition);
return new String(array, charset);
}
}
|
Метки: Получить String из ByteBuffer |
бизнес идея |
|
|
Без заголовка |
code:
// Get current size of heap in bytes
long heapSize = Runtime.getRuntime().totalMemory();
// Get maximum size of heap in bytes. The heap cannot grow beyond this size.// Any attempt will result in an OutOfMemoryException.
long heapMaxSize = Runtime.getRuntime().maxMemory();
// Get amount of free memory within the heap in bytes. This size will increase // after garbage collection and decrease as new objects are created.
long heapFreeSize = Runtime.getRuntime().freeMemory();
|
Метки: freeMemory maxMemory Memory totalMemory |
бизнес идея |
|
Метки: бизнес идея |
Северная Сикоку кран |
|
|
задачки |
|
|
GWT Multiple Modules |
|
|
sql |
|
Метки: sql |
/// |
|
|
@WebServlet(asyncSupported = true, value = "/AsyncServlet") |
|
Метки: @WebServlet(asyncSupported = true value = "/AsyncServlet") |
ResourceBundle WEB-INF properties |
// подсказка на коды ошибок
ResourceBundle msgsBundle = null;
try {
String fullPath = getServletContext().getRealPath("/WEB-INF/i18n/messages.properties");
msgsBundle = new PropertyResourceBundle(new FileReader(fullPath));
//PropertyResourceBundle.getBundle("WEB-INF.i18n.messages",locale); ///WEB-INF/i18n/messages.properties
} catch (Exception ex) {
out.print(ex);
}
|
Метки: ResourceBundle WEB-INF properties |
Integer.toHexString and string format |
String m = Integer.toHexString(ticket.getRequestSign());
msg = "error."+("0000" + m).substring(m.length()); // добивка нулями
|
Метки: toHexString and string format |
invokevirtual vs invokeinterface |
|
Метки: invokevirtual vs invokeinterface |