Решето |
package testDate;
import java.util.Arrays;
/**
*
* @author ISalnikov
*/
public class Resheto {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
boolean[] bm = getSieve(150000);
for (int i = 0; i < bm.length; i++) {
if(bm[i])
System.out.println("[" + i +"] "+ bm[i]);
}
}
public static boolean[] getSieve(int n) {
boolean[] primes = new boolean[n + 1];
Arrays.fill(primes, 2, n + 1, true);
for (int i = 2; i * i <= n; i++) {
if (primes[i]) {
for (int k = i * i; k <= n; k += i) {
primes[k] = false;
}
}
}
return primes;
}
}
|
Метки: решето |
dbvisualizer load sql |
|
|
Jboss start |
|
Метки: jboss start |
GWT |
button3.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final MyProxy myproxy = new MyProxy();
AsyncCallback collback = new AsyncCallback() {
public void onFailure(Throwable caught) {
}
public void onSuccess(Object result) {
Timer timer = new Timer() {
@Override
public void run() {
Button btn = myproxy.getApp().getButton();
RootPanel.get().add(btn);
}
};
timer.run();
timer.scheduleRepeating(10);
}
};
myproxy.getInstance(collback);
}
});
* This source code was highlighted with Source Code Highlighter./*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.yournamehere.client.util;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.ui.Button;
/**
*
* @author salnikov
*/
public interface MyApp extends RemoteService {
String getWindow();
public Button getButton();
}
* This source code was highlighted with Source Code Highlighter./*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.yournamehere.client.util;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
*
* @author salnikov
*/
public class MyProxy {
private MyApp app;
public void getInstance( final AsyncCallback collback ) {
GWT.runAsync(new RunAsyncCallback() {
public void onFailure(Throwable reason) {
collback.onFailure(reason);
}
public void onSuccess() {
app = new OrgApp();
collback.onSuccess(this);
}
});
}
public MyApp getApp() {
return app;
}
public void setApp(MyApp app) {
this.app = app;
}
}
* This source code was highlighted with Source Code Highlighter./*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.yournamehere.client.util;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
/**
*
* @author salnikov
*/
public class OrgApp implements MyApp {
private static int counter = 0;
public String getWindow() {
return "window from Proxy";
}
public Button getButton() {
counter++;
return new Button("num "+counter);
}
}
* This source code was highlighted with Source Code Highlighter.
|
Метки: gwt |
Видео Программирование лекция |
|
Метки: видео программирование лекция |
enum |
public enum AttributeType {
StringAttribute("StringAttribute"),
IntegerAttribute("IntegerAttribute"),
AttachedBlob("AttachedBlob");
private AttributeType(String attr) {
type = attr;
}
private String type;
public String value() {
return type;
}
public static AttributeType getByValue(String value) {
for (AttributeType t : AttributeType.values())
if (t.value().equals(value)) return t;
return null;
}
}
* This source code was highlighted with Source Code Highlighter.
|
Метки: enum |
Ubuntu Выбор Java |
Java 6
* sun-java6-bin
* sun-java6-javadb
* sun-java6-plugin
* sun-java6-demo
* sun-java6-jdk
* sun-java6-source
* sun-java6-doc
* sun-java6-jre
* sun-java6-src
* sun-java6-fonts
* sun-java6-jre-headless
java -version
root@test:~# java -version
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode)
update-java-alternatives -l
update-java-alternatives -s
|
|
Работа с GUI |
|
Метки: gui |
Работа с сокетом через прокси |
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("192.168.70.241", 80));
URL url = new URL("http://google.com/");
HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxy);
InputStream in = connection.getInputStream();
FileOutputStream out = new FileOutputStream("C:\\google.com.html");
byte[] buffer = new byte[64 * 1024];
int read;
while((read = in.read(buffer)) != -1)
out.write(buffer, 0, read);
out.close();
connection.disconnect();
* This source code was highlighted with Source Code Highlighter.
|
Метки: прокси сокет |
Без заголовка |
//So to scan you own PC and find open ports you can enter:
sudo netstat --tcp --udp --listening --program
//With this command you need to enter
sudo lsof +M -i4
//user, does help, but is not like those other tools, with fuser you can also kill the process which is listening on a given port.
sudo fuser -v 3143/tcp
|
Метки: linux port |
linux port |
|
Метки: linux port |
postgres dump |
code:
;если знаем где утилиты от postgres
;с компрессией если база большая
pg_dump dbname | gzip > filename.gz
;распаковка
createdb dbname
gunzip -c filename.gz | psql dbname
; сдампить всё
pg_dumpall > outfile
; если ничего не знаем)
tar -cf backup.tar /usr/local/pgsql/data
|
Метки: postgres dump |
postgres dump |
code:
$ su postgres
List the databases:
$ psql -l
Backup a specific postgres table
$ pg_dump --table products -U geekstuff article -f onlytable.sql
Backup all postgres databases using pg_dumpall:
$ pg_dumpall > all.sql
Restore a postgres database
$ psql -U erp -d erp_devel -f mydb.sql
|
Метки: postgres dump |
ubuntu удаление службы из загрузки |
|
Метки: sysv-rc-conf |
svn сменить пароль пользователю |
|
Метки: svn пароль |
java динамический прокси |
|
Метки: proxy потоки invocationhandler |
Открытие файлов и работа с файлами в java |
|
Метки: java file |
Открытие файла xdg-open |
|
Метки: java open file linux xdg-open |
Программирование |
Вложение: 3792728_hashcode.txt
|
Метки: программирование java md5 перебор выборка |
Генри Миллер. Черная весна. |
|
Метки: генри миллер черная весна |
Литература |
|
Метки: литература |
Амели |
|
|
... |
|
Метки: мафия |
... |
|
|
... |
|
Метки: монитор |
... |
|
|
... |
|
|
... |
|
|
... |
|
|
... |
|
|
... |
|
|
Все страны |
code:
Locale list[] = SimpleDateFormat.getAvailableLocales();
for (int i = 0; i < list.length; i++) {
System.out.println(list[i].toString() + "\t" + list[i].getDisplayName());
}
|
|