aptana 破解 for V1.1

Filed under: JAVA | No Comments »
Posted on
Java代码 复制代码
  1. package com.aptana.ide.core.licensing;
  2. import java.util.Calendar;
  3. import java.util.TimeZone;
  4. //crack by lizhou
  5. public final class ClientKey
  6. {
  7. private ClientKey()
  8. {
  9. this.type = 0;
  10. this.email = “Cracker@aptana.com”;
  11. this.expiration = 31536000000000L;
  12. }
  13. public static ClientKey decrypt(String encrypted, String email)
  14. {
  15. return new ClientKey();
  16. }
  17. public boolean isCloseToExpiring()
  18. {
  19. return false;
  20. }
  21. public boolean isValid()
  22. {
  23. return true;
  24. }
  25. public boolean isCloseToMatching()
  26. {
  27. return false;
  28. }
  29. public boolean isExpired()
  30. {
  31. return false;
  32. }
  33. public String getEmail()
  34. {
  35. return email;
  36. }
  37. public Calendar getExpiration()
  38. {
  39. Calendar expirationCal = Calendar.getInstance(GMT);
  40. expirationCal.setTimeInMillis(expiration);
  41. return expirationCal;
  42. }
  43. public boolean isTrial()
  44. {
  45. return false;
  46. }
  47. public boolean isPro()
  48. {
  49. return true;
  50. }
  51. public boolean shouldProPluginsRun()
  52. {
  53. return true;
  54. }
  55. public static String trimEncryptedLicense(String encrypted)
  56. {
  57. String newEncrypted = encrypted;
  58. newEncrypted = newEncrypted.trim();
  59. newEncrypted = newEncrypted.replaceAll(“–begin-aptana-license–”, “”);
  60. newEncrypted = newEncrypted.replaceAll(“–end-aptana-license–”, “”);
  61. newEncrypted = newEncrypted.replaceAll(“\\s+”, “”);
  62. return newEncrypted;
  63. }
  64. public static final String BEGIN_LICENSE_MARKER = “–begin-aptana-license–”;
  65. public static final String END_LICENSE_MARKER = “–end-aptana-license–”;
  66. private static final TimeZone GMT = TimeZone.getTimeZone(“GMT”);
  67. /*    private static final String EMAILS_NON_MATCHING = ”EMAILS_NON_MATCHING”;
  68. private static final int PRO = 0;
  69. private static final int TRIAL = 1;
  70. */
  71. private String email;
  72. private long expiration;
  73. private int type;
  74. }

上传视频后自动转成flv的核心JAVA方法

Filed under: JAVA | No Comments »
Posted on

【摘要】

作者:古刹飞鹰

BLOG:www.v246.com

QQ:28095553

Email:aquaqu(圈.a)gmail.com

本文属古刹飞鹰原创,转载请注明出处!

以下是源码:

【全文】

作者:古刹飞鹰

BLOG:www.v246.com

QQ:28095553

Email:aquaqu(圈.a)gmail.com

本文属古刹飞鹰原创,转载请注明出处!

本方法以经经过实战验证,正在项目中使用,稍后您可以查看:http://www.0431net.com,网站的视频模快的核心功能就是用这个方法实现的:)

以下是源码:

Cnvert 类

package com.v246.convertFLV;

import java.util.ArrayList;
import java.util.List;

import com.v246.utils.Aqu;

//作者:古刹飞鹰 blog:www.v246.com懒汉模式
public class Convert {

private static Convert instance = null;

//作者:古刹飞鹰 blog:www.v246.com flv截图工具的绝对地址
private String aquInterceptPicToolsPath = “c:\\FLVTools\\ffmpeg.exe”;

//作者:古刹飞鹰 blog:www.v246.com flv修复工具的绝对地址
private String fixFLVToolsPath = “c:\\FLVTools\\flvmdi.exe”;

//作者:古刹飞鹰 blog:www.v246.com flv转换工具的绝对地址
private String aquCoverFLVToolsPath = “c:\\FLVTools\\mencoder\\mencoder.exe”;

private Convert() {
//作者:古刹飞鹰 blog:www.v246.cominit();
}

public static Convert getInstance() {
if (instance == null) {
instance = new Convert();
}
return instance;
}
public void reset(){
//作者:古刹飞鹰 blog:www.v246.cominit();
}
private void init() {
/*aquInterceptPicToolsPath = Aqu.getXMLValue(”convertFLV.xml”,
“//作者:古刹飞鹰 blog:www.v246.com古刹飞鹰/FLV转换工具全路径”)[0];
fixFLVToolsPath = Aqu
.getXMLValue(”convertFLV.xml”, “//作者:古刹飞鹰 blog:www.v246.com古刹飞鹰/FLV截图工具全路径”)[0];
aquCoverFLVToolsPath = Aqu.getXMLValue(”convertFLV.xml”,
“//作者:古刹飞鹰 blog:www.v246.com古刹飞鹰/FLV修复工具全路径”)[0];
aquInterceptPicToolsPath = aquInterceptPicToolsPath.replace(”/”, “\\”);
fixFLVToolsPath = fixFLVToolsPath.replace(”/”, “\\”);
aquCoverFLVToolsPath = aquCoverFLVToolsPath.replace(”/”, “\\”);
System.out.println(aquInterceptPicToolsPath);
System.out.println(fixFLVToolsPath);
System.out.println(aquCoverFLVToolsPath);*/

}

public synchronized boolean convert(String aquInputPath, String outPath) {
boolean re = false;
//作者:古刹飞鹰 blog:www.v246.com 通一路径定位符
aquInputPath = aquInputPath.replace(”/”, “\\”);
//作者:古刹飞鹰 blog:www.v246.com 通一路径定位符
outPath = outPath.replace(”/”, “\\”);
//作者:古刹飞鹰 blog:www.v246.com 分析不包含文件名的输出路径
String interceptPicSavePath = outPath.substring(0, outPath
.lastIndexOf(”\\”) + 1);
//作者:古刹飞鹰 blog:www.v246.com 分析输出的文件名
String outFileName = outPath.substring(outPath.lastIndexOf(”\\”) + 1,
outPath.length());
//作者:古刹飞鹰 blog:www.v246.com 继续分析得出不包含扩展名的文件名
String outFileNameNoExt = outFileName.substring(0, outFileName
.lastIndexOf(”.”));

//作者:古刹飞鹰 blog:www.v246.com 工作目录,随便设置
//作者:古刹飞鹰 blog:www.v246.com String workdirectory = “c:\\windows\\temp”;
//作者:古刹飞鹰 blog:www.v246.com 修复命令
List<String> parameterForFix = new ArrayList<String>(100);
//作者:古刹飞鹰 blog:www.v246.com 转换命令
List<String> aquParameterForConvert = new ArrayList<String>(100);
//作者:古刹飞鹰 blog:www.v246.com 截图命令
List<String> aquParameterForIntercept = new ArrayList<String>(100);
//作者:古刹飞鹰 blog:www.v246.com 构建转换命令
aquParameterForConvert.add(aquCoverFLVToolsPath);
aquParameterForConvert.add(”-vf”);
aquParameterForConvert.add(”scale=320:240″);
aquParameterForConvert.add(”-ffourcc”);
aquParameterForConvert.add(”FLV1″);
aquParameterForConvert.add(”-of”);
aquParameterForConvert.add(”lavf”);
aquParameterForConvert.add(”-lavfopts”);
aquParameterForConvert
.add(”i_certify_that_my_video_stream_does_not_use_b_frames”);
aquParameterForConvert.add(”-ovc”);
aquParameterForConvert.add(”lavc”);
aquParameterForConvert.add(”-lavcopts”);
aquParameterForConvert.add(”vcodec=flv:vbitrate=200″);
aquParameterForConvert.add(”-srate”);
aquParameterForConvert.add(”22050″);
aquParameterForConvert.add(”-oac”);
aquParameterForConvert.add(”lavc”);
aquParameterForConvert.add(”-lavcopts”);
aquParameterForConvert.add(”acodec=mp3:abitrate=56″);
aquParameterForConvert.add(aquInputPath);
aquParameterForConvert.add(”-o”);
aquParameterForConvert.add(outPath);

//作者:古刹飞鹰 blog:www.v246.com 构建修复命令
parameterForFix.add(fixFLVToolsPath);
parameterForFix.add(outPath);
//作者:古刹飞鹰 blog:www.v246.com 构建截图命令
aquParameterForIntercept.add(aquInterceptPicToolsPath);
aquParameterForIntercept.add(”-i”);
aquParameterForIntercept.add(outPath);
aquParameterForIntercept.add(”-y”);
aquParameterForIntercept.add(”-f”);
aquParameterForIntercept.add(”image2″);
aquParameterForIntercept.add(”-ss”);
aquParameterForIntercept.add(”8″);
aquParameterForIntercept.add(”-t”);
aquParameterForIntercept.add(”0.001″);
aquParameterForIntercept.add(”-s”);
aquParameterForIntercept.add(”320×240″);
aquParameterForIntercept.add(interceptPicSavePath + outFileNameNoExt
+ “.jpg”);
//作者:古刹飞鹰 blog:www.v246.com转换
String tmp1 = Aqu.exec(aquParameterForConvert);
//作者:古刹飞鹰 blog:www.v246.com截图
String tmp2 = Aqu.exec(aquParameterForIntercept);
return re;
}

public static void main(String[] args) {
getInstance().convert(”h:\\QQ28095553\\古刹飞鹰.wmv”, “h:\\aquaqu(quana)gmail.com\\古刹飞鹰.flv”);
}
}

ConvertThread 类

package com.v246.convertFLV;

public class ConvertThread extends Thread{

private String fromPath = null;
private String toPath = null;
@Override
public void run(){
Convert.getInstance().convert(fromPath, toPath);
}
public void setFromPath(String fromPath) {
this.fromPath = fromPath;
}
public void setToPath(String toPath) {
this.toPath = toPath;
}
}

ConvertThreadProxy类:

package com.v246.convertFLV;

public class ConvertThreadProxy {
public static void convert(String fromPath, String toPath) {
ConvertThread ct = new ConvertThread();
ct.setFromPath(fromPath);
ct.setToPath(toPath);
ct.start();
}
}

使用的时候只要通过ConvertThreadProxy 类的静态方法将源视频绝对地址(包括文件名+括展名)和要生成的FLV文件的绝对地址(包括文件名+括展名)以字符串的方式传进去即可!因为用的是多线程,所以转换过程不会占用当前线程!

使用的时候只要通过ConvertThreadProxy 类的静态方法将源视频绝对地址(包括文件名+括展名)和要生成的FLV文件的绝对地址(包括文件名+括展名)以字符串的方式传进去即可!因为用的是多线程,所以转换过程不会占用当前线程!

核心转换类是线程同步的,所以您不用担心并法问题,因为一次只能转换一个文件!

lucene特殊排序实现

Filed under: JAVA | No Comments »
Posted on

在Lucene中有两种特别的类型是用来排序的:Score和Index order

要排序结果 可以使用IndexSearcher的重载serach函数,提供一个Sort参数.看个例子.SortingExample.java

01 package lia.advsearching;
02
03 import org.apache.commons.lang.StringUtils;
04 import org.apache.lucene.document.Document;
05 import org.apache.lucene.index.Term;
06 import org.apache.lucene.search.Hits;
07 import org.apache.lucene.search.IndexSearcher;
08 import org.apache.lucene.search.Query;
09 import org.apache.lucene.search.RangeQuery;
10 import org.apache.lucene.search.Sort;
11 import org.apache.lucene.search.SortField;
12 import org.apache.lucene.store.Directory;
13 import org.apache.lucene.store.FSDirectory;
14
15 import java.io.IOException;
16 import java.text.DecimalFormat;
17
18 public class SortingExample {
19   private Directory directory;
20
21   public SortingExample(Directory directory) {
22   this.directory = directory;
23   }
24   // 显示搜索结果
25   public void displayHits(Query query, Sort sort)
26     throws IOException {
27   IndexSearcher searcher = new IndexSearcher(directory);
28
29   Hits hits = searcher.search(query, sort); // 安sort 来排序搜索结果
30
31   System.out.println(” Results for: ”
32       query.toString() ” sorted by ” sort); // 打印query 和sort   // 使用StringUtils(来自Apache commons)打印结果
33
34   System.out.println(StringUtils.rightPad(”Title”, 30)
35       StringUtils.rightPad(”pubmonth”, 10) +
36       StringUtils.center(”id”, 4) +
37       StringUtils.center(”score”, 15));
38
39   DecimalFormat scoreFormatter = new DecimalFormat(”0.######”);
40   for (int i = 0; i < hits.length(); i++) {           // 打印结果
41     Document doc = hits.doc(i);
42     System.out.println(
43       StringUtils.rightPad(
44           StringUtils.abbreviate(doc.get(”title”), 29), 30) +
45       StringUtils.rightPad(doc.get(”pubmonth”), 10) +
46       StringUtils.center(”" hits.id(i), 4)
47       StringUtils.leftPad(
48           scoreFormatter.format(hits.score(i)), 12));
49     System.out.println(”   ” + doc.get(”category”));
50 //     System.out.println(searcher.explain(query, hits.id(i)));
51   }
52
53   searcher.close();
54   }
55
56   public static void main(String[] args) throws Exception {
57   Term earliest = new Term(”pubmonth”, “190001″);
58   Term latest = new Term(”pubmonth”, “201012″);
59   RangeQuery allBooks = new RangeQuery(earliest, latest, true);   // query
60
61   String indexDir = System.getProperty(”index.dir”); // index的目录
62
63   FSDirectory directory =
64       FSDirectory.getDirectory(indexDir, false);
65   SortingExample example = new SortingExample(directory);
66
67   example.displayHits(allBooks, Sort.RELEVANCE); // 使用Lucene默认的排序
68
69   example.displayHits(allBooks, Sort.INDEXORDER); // 根据IndexOrder排序
70
71   example.displayHits(allBooks, new Sort(”category”)); // 根据category 排序
72
73   example.displayHits(allBooks, new Sort(”pubmonth”, true)); // 根据pubmonth 排序
74
75   example.displayHits(allBooks,
76       new Sort(new SortField[]{
77       new SortField(”category”),
78       SortField.FIELD_SCORE,
79       new SortField(”pubmonth”, SortField.INT, true)
80       })); ///
81
82
83   example.displayHits(allBooks, new Sort(new SortField[] {SortField.FIELD_SCORE, new SortField(”category”)}));
84   }
85 }

当sort 参数是null ,new Sort(),和Sort.RELEVANCE 时,使用的是Lucene的默认排序(按照Relevance的递减排序), 默认搜索的结果如下:

先按照Score递减排序 如果Score相同则按照Docnum 递增排序.

If the order documents were indexed is relevant, you can use

Sort.INDEXORDER.

下面是其输出结果:(安装ID来排序)

要利用Field排序,该field要满足第二章排序(参考我的Blog上的内容)的要求. 下面是使用category field的输出.

默认的field排序是按照自然排序,利用Sort的重载函数,提供一个reverse参数可以改变顺序.结果如下:


example.displayHits(allBooks, new Sort(”pubmonth”, true)); 提供了true参数.  

还可以根据多个Field排序. 用法如下:

example.displayHits(allBooks,

new Sort(new SortField[]{

new SortField(”category”),

SortField.FIELD_SCORE,

new SortField(”pubmonth”, SortField.INT, true)

}));

结果如下:

当使用 SortField.STRING

public SortField (String field, Locale locale)

public SortField (String field, Locale locale, boolean reverse)

类型来排序时,结果可能会跟Locale有关,可以使用如下方法设置

在排序时候,要占用更多的资源.这一点值得注意.

如果是对中文进行排序,是怎么样的呢
找到方法了
SortField sf = new SortField(”operatorName”,Locale.CHINESE);
           
Hits hits = searcher.search(query,new Sort(sf));

Ubuntu Java 环境设置

Filed under: JAVA | No Comments »
Posted on

取得Sun JDK 5

sudo apt-get install sun-java5-jdk

查看安装的jdk列表

update-java-alternatives -l

设置默认Java
sudo update-java-alternatives -s java-1.5.0-sun

Ubuntu Linux下Java中文乱码解决办法!

Filed under: JAVA | No Comments »
Posted on

假设用的字体是 /usr/share/fonts/truetype/fireflysung.ttf

cd /path/to/jre/lib/fonts
sudo mkdir fallback
cd fallback
sudo ln -s /usr/share/fonts/truetype/fireflysung.ttf .
sudo mkfontdir
sudo mkfontscale

这是最简单的方法,其他方法也有,不过都很麻烦。