小编msa*_*ord的帖子

sudo pecl install apc返回错误

我运行命令: sudo pecl install apc

文件下载,配置成功,然后make启动,我收到以下错误.

/usr/include/php5/ext/pcre/php_pcre.h:29: fatal error: pcre.h: No such file or directory

有办法解决吗?

php pear apc pecl

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

通过ADB Shell或Terminal获取应用程序名称/标签

我正在开发一个使用ADB Shell与Android设备接口的应用程序,我需要一些打印出应用程序名称或应用程序标签的方法,可能是它们的包名.

简而言之,我需要一种方法来获取用户安装的应用程序的应用程序名称(即"愤怒的小鸟v1.0.0")adb shell.

对此事有何看法?任何帮助表示赞赏.

shell android label adb

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

!对象方法后的操作符

我有一个对象X,一个方法getY()返回一个Y带有方法的对象a(),在typescript中.这个表达式是什么意思:

X.getY()!.a()
Run Code Online (Sandbox Code Playgroud)

我猜!运算符用于检查null,但具体如何工作?语言中定义的位置是什么?

object operators typescript

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

Yahoo Finance API的替代品?

雅虎财务最近停止了他们的API.我一直在寻找替代品.到目前为止,我发现的是Google财经和Quandl.

Google财经在2011年被弃用,但似乎仍有所作为.但是,几乎没有文档,我需要提取我无法找到的股息数据.

Quandl似乎运行良好,但数据分布在多个数据库中,这使得及时和昂贵地获得适当的访问.

有没有人知道任何其他可行的替代品?

finance google-finance yahoo-api yahoo-finance quandl

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

使用RESTIFY提供静态文件

我正在学习使用Node.js. 目前,我有一个如下所示的文件夹结构:

index.html
server.js
client
  index.html
  subs
    index.html
    page.html
res
  css
    style.css
  img
    profile.png
  js
    page.js
    jquery.min.js
Run Code Online (Sandbox Code Playgroud)

server.js是我的网络服务器代码.我使用命令行运行它node server.js.该文件的内容是:

var restify = require('restify');

var server = restify.createServer({
    name: 'Test App',
    version: '1.0.0'
});

server.use(restify.acceptParser(server.acceptable));
server.use(restify.queryParser());
server.use(restify.bodyParser());

server.get('/echo/:name', function (req, res, next) {
    res.send(req.params);
    return next();
});

server.listen(2000, function () {
    console.log('%s running on %s', server.name, server.url);
});
Run Code Online (Sandbox Code Playgroud)

如您所见,此服务器依赖于RESTIFY.我被告知必须使用RESTIFY.但是,我无法弄清楚如何提供静态文件.例如,如何在我的应用程序中为*.html,*.css,*.png和*.js文件提供服务?

谢谢!

node.js restify

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

Golang - 结构字段中的首都

我正在使用这个库来访问couchDB(cloudant是具体的)"github.com/mikebell-org/go-couchdb",我注意到了一个问题.

当我将数据添加到数据库并传入结构时,只添加以大写字母开头的结构字段.

例如

type Person struct {
    name string
    Age  int
}

func main() {
    db, _ := couchdb.Database(host, database, username, password)
    joe := Person{
        name: "mike",
        Age:  190,
    }
    m, _ := db.PostDocument(joe)
}
Run Code Online (Sandbox Code Playgroud)

在这种情况下,只有"age"字段已更新并插入到我的数据库中.

我在另一个案例中也注意到了这个问题 - 当我做这样的事情时:

type Sample struct {
    Name string
    age  int 
}


joe := Sample{
    Name: "xx",
    age:  23,
}

byt, _ := json.Marshal(joe)

post_data := strings.NewReader(string(byt))
fmt.Println(post_data)
Run Code Online (Sandbox Code Playgroud)

在这种情况下,只会打印出名称:

output : &{{"Name":"xx"} 0 -1}
Run Code Online (Sandbox Code Playgroud)

为什么是这样?如果我想要一个小写的字段并且在数据库中,那可能吗?

json struct go

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

使用Angular 4.3 HttpClient解析日期

我目前正在转向Angular 4.3的新HttpClient.一个优点是我可以在GET方法上指定类型信息,并将返回的JSON解析为给定类型,例如

this.http.get<Person> (url).subscribe(...)
Run Code Online (Sandbox Code Playgroud)

但不幸的是,JSON中的所有日期都在结果对象中被解析为数字(可能是因为Java Date对象在后端被序列化为数字).

使用旧的Http我在调用JSON.parse()时使用了reviver函数:

this.http.get(url)
  .map(response => JSON.parse(response.text(), this.reviver))
Run Code Online (Sandbox Code Playgroud)

在reviver函数中,我从数字中创建了日期对象:

reviver (key, value): any {
  if (value !== null && (key === 'created' || key === 'modified'))
    return new Date(value);

  return value;
}
Run Code Online (Sandbox Code Playgroud)

新的HttpClient是否有类似的机制?或者在解析JSON时进行转换的最佳做法是什么?

json date angular angular-httpclient

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

如何将查询参数设置为url Angular2?

我需要设置一个带有查询参数的网址/Questions?id=1234&pageid=0.我试过这样做,router.Navigate['/Questions?id=1234&pageid=0']但没有运气.

导航浏览器显示之后/Questions%3Fid%3D1234%26pageid%3D0.

我也尝试了设置routerLink="/Questions?id=1234&pageid=0",但结果相同.

请建议任何解决方案.我使用rc5 for angular2.

query-parameters angular

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

将[(ngModel)]添加到单选按钮组后,默认[已选中]不再有效

我正在研究一个小的可重用组件,它可以设置单选按钮的样式并发出所选的值.

import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core";

@Component({
    moduleId: module.id,
    selector: 'button-select',
    template: `<div class="toggle-group">
                    <div *ngFor="let choice of choices">
                        <input type="radio"
                               id="{{ groupName + choice }}"
                               name="{{groupName}}"
                               value="{{ choice }}"
                               [checked]="choice === defaultChoice"
                               [(ngModel)]="value"
                               (ngModelChange)="choose($event)" />
                        <label class="toggle-button"
                               for="{{ groupName + choice }}">{{ choice }}</label>
                    </div>
                </div>`,
    styleUrls: [
        'editableField.css',
        'buttonSelect.css'
    ]
})

export class ButtonSelectComponent implements OnInit {
    @Input() choices: string[];
    @Input() defaultChoice: string;
    @Input() groupName: string;
    @Input() value: string;

    @Output() valueChosen: EventEmitter<any> = …
Run Code Online (Sandbox Code Playgroud)

angular2-forms angular

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

类型'标题'没有与'RequestOptionsArgs'类型相同的属性?

我刚刚对Angular 4应用程序和构建工具进行了两次重要的升级:

  1. @ angular/core ^4.1.3 => ^4.2.4(和/ http,/ forms等)
  2. tslint ^5.3.2 =>^5.4.3

我有一个服务,声明这样的选项:

@Injectable()
export class WorkOrderService {

    private headers: Headers = new Headers({ 'Content-Type': 'application/json' });
    private options: RequestOptions = new RequestOptions(this.headers);

    constructor(private http: Http) {}

    /* Methods ... */
}
Run Code Online (Sandbox Code Playgroud)

以上现在不再验证tslint,抛出以下错误:

错误TS2559:类型'标题'没有与'RequestOptionsArgs'类型相同的属性.

源(@角/ HTTP interface.d.ts:43)清楚地允许Headers作为RequestOptionsArgs:

/**
 * Interface for options to construct a RequestOptions, based on
 * [RequestInit](https://fetch.spec.whatwg.org/#requestinit) from the Fetch spec.
 *
 * @experimental
 */
export interface RequestOptionsArgs {
    url?: …
Run Code Online (Sandbox Code Playgroud)

typescript angular

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