这个错误在Windows机器上似乎很常见,但我的Amazon Linux EC2实例在我执行时抛出此错误npm install pg:
../src/binding.cc:1:23: fatal error: pg_config.h: No such file or directory
#include <pg_config.h>
^
compilation terminated.
make: *** [Release/obj.target/binding/src/binding.o] Error 1
make: Leaving directory `/home/ec2-user/macros/test/stateHash/node_modules/pg/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:807:12)
gyp ERR! System Linux 3.4.82-69.112.amzn1.x86_64
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/ec2-user/macros/test/stateHash/node_modules/pg
gyp ERR! node …Run Code Online (Sandbox Code Playgroud) 要求
我正在尝试写一对Observer/ Observable类.我想参数化,Observer以便可以进行类型安全更新调用.想象一下这个版本:
class View implements Observer<Model> {
@Override
public void update(Model model) { render(model); } // no casting:)
}
Run Code Online (Sandbox Code Playgroud)
而不是需要强制转换的版本:
class View implements Observer {
@Override
public void update(Object model) { render((Model) model); } // casting:(
}
Run Code Online (Sandbox Code Playgroud)
尝试
这是我到目前为止所拥有的.我的Observer界面:
public interface Observer<T extends Observable> {
public void update(T observable);
}
Run Code Online (Sandbox Code Playgroud)
和我的Observable抽象类:
import java.util.List;
public abstract class Observable {
private List<Observer<? extends Observable>> observers;
public Observable() {
System.out.println(this.getClass());
}
public void …Run Code Online (Sandbox Code Playgroud) 覆盖该Equals()方法时,MSDN建议:
class Point: Object {
protected int x, y;
public Point(int X, int Y) {
this.x = X;
this.y = Y;
}
public override bool Equals(Object obj) {
//Check for null and compare run-time types.
if (obj == null || GetType() != obj.GetType()) return false;
Point p = (Point)obj;
return (x == p.x) && (y == p.y);
}
}
Run Code Online (Sandbox Code Playgroud)
但是如果我们知道子类直接继承自的Object,那么下面是等价的吗?请注意!base.Equals()电话:
class Point: Object {
protected int x, y;
public Point(int …Run Code Online (Sandbox Code Playgroud) 我喜欢 NUnit 基于约束的 API。我经常使用这样的浮点比较:
double d = foo.SomeComputedProperty;
Assert.That(d, Is.EqualTo(42.0).Within(0.001));
Run Code Online (Sandbox Code Playgroud)
很有可读性!
但是,如果我有一个自定义类,其相等性取决于浮点比较:
class Coord
{
Coord(double radius, double radians)
{
this.Radius = radius;
this.Radians = radians;
}
double Radius { get; }
double Radians { get; }
public override bool Equals(Object obj)
{
Coord c = obj as Coord;
if (obj == null || c == null) return false;
return c.Radians == this.Radians && c.Radius == this.Radius;
}
}
Run Code Online (Sandbox Code Playgroud)
我想像这样编写我的测试:
Coord reference = new Coord(1.0, 3.14);
// test another Coord …Run Code Online (Sandbox Code Playgroud) 当用户滚动时,我的回收器视图中的项目重叠。注意底部的重叠文本:
这是生成此视图的代码:
ArrayList<Bitmap> drawables = mBitmaps;
RecyclerView recyclerView = new RecyclerView(ctx);
LinearLayoutManager llm = new LinearLayoutManager(ctx);
recyclerView.setLayoutManager(llm);
RecyclerView.Adapter adapter = new MyRecyclerAdapter(contentList, uriList, drawables);
recyclerView.setAdapter(adapter);
((ViewGroup) rootView).addView(recyclerView);
Run Code Online (Sandbox Code Playgroud)
mBitmaps 是一组图像contentList 是一个字符串列表uriList 是另一个字符串列表这是MyRecyclerAdapter类的代码:
public class MyRecyclerAdapter extends RecyclerView.Adapter<MyViewHolder> {
ArrayList<String> mContentList, mUriList;
ArrayList<Bitmap> mBitmaps;
MyRecyclerAdapter(ArrayList<String> contentList, ArrayList<String> uriList, ArrayList<Bitmap> drawables){
mContentList = contentList;
mUriList = uriList;
mBitmaps = drawables;
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
final Context ctx = parent.getContext();
CardView.LayoutParams params = new …Run Code Online (Sandbox Code Playgroud) TL; DR
在.ShowDialog()打开模式对话框并且用户单击原始表单时,对话框的标题栏闪烁。是否可以通过Windows.FormsAPI或其他任何方式访问该事件?
细节
这是带有父窗体和对话框窗口的标准C#6 Windows Forms项目。父表单只有一个按钮可以打开对话框:
using System;
using System.Windows.Forms;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
using (var dialog = new Dialog())
{
Console.WriteLine("Dialog starting.");
dialog.ShowDialog(this);
Console.WriteLine("Dialog done.");
}
}
}
Run Code Online (Sandbox Code Playgroud)
该Dialog由创建.ShowDialog(this)同样简单,与OK按钮和取消按钮:
using System;
using System.Windows.Forms;
public partial class Dialog : Form
{
public Dialog()
{
InitializeComponent();
}
private void btnOK_Click(object sender, EventArgs e)
{
Close();
}
private …Run Code Online (Sandbox Code Playgroud) 这是一个构造函数A,它给出了实例2的方法:printThing和printBall.我使用JSDoc来记录这样的方法:
var A = function () {
/**
* Prints 'Thing'
* @param {Number} N - The number of times to print.
*/
this.printThing = function (N) {
var i = 0;
while (i < N) {
console.log('Thing');
i++
}
};
/**
* Prints 'Ball'
* @param {Number} N - The number of times to print.
*/
this.printBall = function (N) {
var i = 0;
while (i < N) {
console.log('Ball'); …Run Code Online (Sandbox Code Playgroud) 使用 SPARQL 1.1 的value,以下查询返回以Einstein或Knuth作为主语的所有谓词(及其标签)。
PREFIX dbp: <http://dbpedia.org/resource/>
SELECT DISTINCT ?sub ?outpred ?label
{
VALUES ?sub { dbp:Albert_Einstein dbp:Donald_Knuth }
?sub ?outpred [] .
?outpred <http://www.w3.org/2000/01/rdf-schema#label> ?label .
}
Run Code Online (Sandbox Code Playgroud)
是否可以使用此值功能来公开谓词的交集而不是并集?或者我误解了价值观的用途?
举一个简化的例子,假设有以下三元组:
<Einstein> <influenced> <John>
<Einstein> <influenced> <Knuth>
<Einstein> <born> <Mars>
<Einstein> <died> <Los Angeles>
<Knuth> <influenced> <Kirby>
<Knuth> <born> <Mars>
<Knuth> <wrote> <TAOCP>
<Knuth> <drove> <Truck>
Run Code Online (Sandbox Code Playgroud)
我得到的“联合”是附加到任一主题的所有唯一谓词(为了清楚起见,以行分隔):
| ?sub | ?pred |
-------------------------
<Einstein> …Run Code Online (Sandbox Code Playgroud) 这是有关.NET的一般问题
我得到了IServiceProvider接口的实例,但是关于从中可以得到什么的信息很少。我如何找到它可能提供的所有服务的清单?
对我来说,与其他任何东西(甚至是另一个null类型)进行比较的null类型是未定义的操作.如果我错了,请纠正我.
根据这个假设,以下内容对我有意义:
nil.is_a? Comparable
=> false
nil.respond_to? :<=
=> false
nil.respond_to? :<
=> false
nil.respond_to? :>=
=> false
nil.respond_to? :>
=> false
Run Code Online (Sandbox Code Playgroud)
但是,nil 确实响应"宇宙飞船"比较运算符:
nil.respond_to? :<=>
=> true
Run Code Online (Sandbox Code Playgroud)
我无法想象比较nil甚至有意义的情况,更不用说实际了.为什么nil会有这种行为?
c# ×4
.net ×1
amazon-ec2 ×1
android ×1
assertions ×1
comparable ×1
dbpedia ×1
equality ×1
events ×1
generics ×1
inheritance ×1
java ×1
javascript ×1
jsdoc ×1
linked-data ×1
linux ×1
modal-dialog ×1
node.js ×1
null ×1
nunit ×1
postgresql ×1
rdf ×1
ruby ×1
semantic-web ×1
sparql ×1
type-safety ×1
winforms ×1