小编Eam*_*orr的帖子

刚上传的Android应用:在Android电子市场搜索中应用显示多长时间?

我刚刚上传了一个新的应用程序到Android市场.然而,当我尝试通过Android市场将其下载到我的手机时,它似乎没有出现!

请知道这一点的人让我知道如何让我的应用程序出现在搜索结果中.

android google-play

50
推荐指数
4
解决办法
4万
查看次数

如何在Android中计算字符串的SHA-256哈希值?

我想在Android中获取字符串的SHA256.

这是我要匹配的PHP代码:

echo bin2hex(mhash(MHASH_SHA256,"asdf"));
//outputs "f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b"
Run Code Online (Sandbox Code Playgroud)

现在,在Java中,我正在尝试执行以下操作:

            String password="asdf"
            MessageDigest digest=null;
    try {
        digest = MessageDigest.getInstance("SHA-256");
    } catch (NoSuchAlgorithmException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
       digest.reset();
       try {
        Log.i("Eamorr",digest.digest(password.getBytes("UTF-8")).toString());
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

但这打印出来:"a42yzk3axdv3k4yh98g8"

我在这做错了什么?


解决方案感谢erickson:

 Log.i("Eamorr",bin2hex(getHash("asdf")));

 public byte[] getHash(String password) {
       MessageDigest digest=null;
    try {
        digest = MessageDigest.getInstance("SHA-256");
    } catch (NoSuchAlgorithmException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
       digest.reset();
       return digest.digest(password.getBytes());
 }
static String bin2hex(byte[] data) …
Run Code Online (Sandbox Code Playgroud)

php java android sha digest

47
推荐指数
3
解决办法
5万
查看次数

Android:您的内容必须具有ListView,其id属性为android.R.id.list

我遇到了这个运行时错误,我真的很难找到它的底部:"你的内容必须有一个ListView,其id属性是android.R.id.list".

这是我的代码:

public class ShowAllJobsInArea extends ListActivity{

    Context context;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.show_jobs_in_area);
        context=getApplicationContext();

        String area=Cookie.getAreaSelected();

        final ProgressBar thinger=(ProgressBar) findViewById(R.id.progressBar2);
        TabHost tabHost=(TabHost)findViewById(android.R.id.tabhost);
        tabHost.setup();

        TabSpec spec1=tabHost.newTabSpec("Tab 1");
        spec1.setContent(R.id.tab1);
        spec1.setIndicator("Starting");

        TabSpec spec2=tabHost.newTabSpec("Tab 2");
        spec2.setContent(R.id.tab2);
        spec2.setIndicator("# Days");        

        TabSpec spec3=tabHost.newTabSpec("Tab 3");
        spec3.setContent(R.id.tab3);
        spec3.setIndicator("Rate");


        tabHost.addTab(spec1);
        tabHost.addTab(spec2);
        tabHost.addTab(spec3);

        Handler handler = new Handler() {
             public void handleMessage(Message message) {
                  switch (message.what) {
                      case HttpConnection.DID_START:
                          thinger.setVisibility(View.VISIBLE);
                          break;
                      case HttpConnection.DID_SUCCEED:
                          String response = (String) message.obj;
                          Log.i("EOH",response);

                          ArrayList<String> startDates=new ArrayList<String>();
                          ArrayList<String> ns=new ArrayList<String>();
                          ArrayList<String> rates=new ArrayList<String>(); …
Run Code Online (Sandbox Code Playgroud)

android listactivity android-activity

25
推荐指数
1
解决办法
4万
查看次数

在命令行上将字符串转换为十六进制

我正在尝试48 65 6c 6c 6f使用命令行尽可能高效地将"Hello"转换为十六进制.

我试过看printf谷歌,但我无法到达任何地方.

任何帮助非常感谢.

提前谢谢了,

linux string printf command-line hex

22
推荐指数
3
解决办法
3万
查看次数

使用omp_set_num_threads()设置线程数为2,但是omp_get_num_threads()返回1

我有使用OpenMP的以下C/C++代码:

    int nProcessors=omp_get_max_threads();
    if(argv[4]!=NULL){
        printf("argv[4]: %s\n",argv[4]);
        nProcessors=atoi(argv[4]);
        printf("nProcessors: %d\n",nProcessors);
    }
    omp_set_num_threads(nProcessors);
    printf("omp_get_num_threads(): %d\n",omp_get_num_threads());
    exit(0);
Run Code Online (Sandbox Code Playgroud)

如您所见,我正在尝试根据命令行传递的参数设置要使用的处理器数量.

但是,我得到以下输出:

argv[4]: 2   //OK
nProcessors: 2   //OK
omp_get_num_threads(): 1   //WTF?!
Run Code Online (Sandbox Code Playgroud)

为什么不omp_get_num_threads()回2?!!!


正如已经指出的那样,我omp_get_num_threads()在一个串行区域调用,因此函数返回1.

但是,我有以下并行代码:

#pragma omp parallel for private(i,j,tid,_hash) firstprivate(firstTime) reduction(+:nChunksDetected)
    for(i=0;i<fileLen-CHUNKSIZE;i++){
        tid=omp_get_thread_num();
        printf("%d\n",tid);
        int nThreads=omp_get_num_threads();
        printf("%d\n",nThreads);
...
Run Code Online (Sandbox Code Playgroud)

哪个输出:

0   //tid
1   //nThreads - this should be 2!
0
1
0
1
0
1
...
Run Code Online (Sandbox Code Playgroud)

c c++ parallel-processing openmp

21
推荐指数
2
解决办法
4万
查看次数

C++ Google Protocol Buffers:序列化为char*?

我想将协议缓冲区序列化为char*.这可能吗?我知道可以按顺序序列化到文件:

fstream output("/home/eamorr/test.bin", ios::out | ios::trunc | ios::binary);
if (!address_book.SerializeToOstream(&output)) {
  cerr << "Failed to write address book." << endl;
  return -1;
}
Run Code Online (Sandbox Code Playgroud)

但我想序列化为C风格的char*,以便通过网络传输.

这该怎么做?请记住,我对C++很新.

c++ protocol-buffers

21
推荐指数
4
解决办法
3万
查看次数

在特定时间运行命令

我正在尝试在特定时间运行命令.我看过"at"命令,但我不知道如何让它工作......

这是我做的:

at 1843 (Enter)
php /run/this/script.php (Ctrl+D)
Run Code Online (Sandbox Code Playgroud)

但是我如何在bash脚本中执行此操作?我的意思是,我需要按回车键并按"Ctrl + D"设置延迟...如何在脚本中执行此操作?

任何建议最受欢迎.

提前致谢,

linux bash command at-job

20
推荐指数
3
解决办法
4万
查看次数

Objective-C:异步填充UITableView - 如何做到这一点?

我似乎无法找到关于这个问题的任何信息,所以我想我会问社区.

基本上,我有一个UITableView,我想在我的服务器加载数据时显示一个活动指示器.

这是我正在尝试做的一些示例代码(我正在使用ASIHttpRequest).

    //self.listData = [[NSArray alloc] initWithObjects:@"Red", @"Green", @"Blue", @"Indigo", @"Violet", nil];   //this works
    NSString *urlStr=[[NSString alloc] initWithFormat:@"http://www.google.com"];   //some slow request
    NSURL *url=[NSURL URLWithString:urlStr];

    __block ASIHTTPRequest *request=[ASIHTTPRequest requestWithURL:url];
    [request setDelegate:self];
    [request setCompletionBlock:^{
        self.listData = [[NSArray alloc] initWithObjects:@"Red", @"Green", @"Blue", @"Indigo", @"Violet", nil];   //this doesn't work...
        [table reloadData];

    }];
    [request setFailedBlock:^{

    }];
    [request startAsynchronous];
Run Code Online (Sandbox Code Playgroud)

对google.com的虚拟请求什么都不做 - 它只是创建了一个延迟,在响应中我希望用我自己网站上的一些JSON响应来重新填充表格.

但是当我尝试用颜色填充表格时,没有任何反应!我只是得到一张空白的表...如果我取消注释上面的行,它工作正常,它只是在http响应事情不适合我.

任何建议都非常感谢.

编辑:

我做了一个[self.tableView reloadData];,现在它有效......

iphone objective-c uitableview

18
推荐指数
2
解决办法
2万
查看次数

Node.js - 将所有流量从端口A转发到端口B.

我正在尝试将所有流量从端口6999转发到端口7000(我知道我可以使用iptables,但想法是使用Node.js进行一些数据包检查).

这是我的代码:

var net=require('net');
var compress=require('./node-compress/compress');

var ip='172.16.1.224';
var ipPort=6999;
var opPort=7000;

var output=net.createServer(function(connOut){
        var input=net.createServer(function(connIn){
                connIn.pipe(connOut);
        });
        input.listen(ipPort,ip);
});
output.listen(opPort,ip);
Run Code Online (Sandbox Code Playgroud)

它似乎没有用.当我在端口7000上执行tcpdump时,没有任何显示.有人有什么建议吗?

提前谢谢了,

javascript portforwarding node.js

17
推荐指数
3
解决办法
2万
查看次数

GPS坐标:一个点周围1平方公里

我希望有人在那里可以提供给我的方程式(从a.aaa X从c.ccc b.bbb,Y向c.ccc)计算一公里平方左右的指定点,说lat = 53.38292839lon = -6.1843984?我还需要一个点周围2公里,5公里和10公里的方格.

我试过谷歌搜索无济于事......这是深夜,希望有人可以快速修复方便我钻研三角函数之前......

我将在Javascript中运行所有这些,虽然任何语言都可以.

javascript math gps coordinates

16
推荐指数
1
解决办法
2万
查看次数