我有这样的模型:
var userSchema = new mongoose.Schema({
_id: { type: Schema.ObjectId },
email: { type: String, unique: true },
ipAddress: { type: String },
referals: [{
type: mongoose.Schema.Types.ObjectId, ref: 'User'
}],
redeem_token: {type: String, unique: true}
});
var User = mongoose.model('User', userSchema);
Run Code Online (Sandbox Code Playgroud)
这可以吗?用户需要具有对其他用户的引用.这是跟踪注册推荐.我想然后使用.Populate并扩展referals []中的用户
由于webkit浏览器处理触摸事件,我尝试了几种不同的方法来消除300ms的延迟.库FastClick.js似乎是首选方法,但我在实现它时遇到了一些麻烦.我已经包含它并且还添加了一个事件监听器,但我不知道我是否正确添加了监听器.这应该工作还是我没有做某事?谢谢!
考虑下面的代码,在哪里
<!DOCTYPE html>
<html>
<head>
<title>
Calculator
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum- scale=1.0, user-scalable=no;">
<meta charset="utf-8">
<script type="text/javascript" charset="utf-8" src="phonegap.js">
</script>
<<script type='application/javascript' src='js/fastclick.js'></script>
<script type="text/javascript">
function onBodyLoad()
{
document.addEventListener("deviceready", onDeviceReady, false);
$(function() {
FastClick.attach(document.body);
});
}
function onDeviceReady()
{
}
</script>
<script>
window.addEventListener('load', function() {
new FastClick(document.body);
}, false);
</script>
<link rel="stylesheet" href="./css/jquerymobile.css" type="text/css">
<link rel="stylesheet" href="./css/jquerymobile.nativedroid.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body onload="onBodyLoad()">
<!--START OF PAGE 1-->
<div data-role="page" data-theme='b' id="one">
<div data-role="content">
<a href="#one" …Run Code Online (Sandbox Code Playgroud) 我一直在努力将标准普尔500指数的价值(现在是1864.78)转换为它在内存中以IEEE单精度格式表示的价值.
转换小数点左边(1864)很容易.
11101001000.
但是如何获得十进制的二进制表示(.78)?我尝试使用该技术但它在8位指数IEEE格式上产生了许多数字:
.78*2 = 1.56 1
.56*2 = 1.12 1
.12*2 = .24 0
.24*2 = .48 0
.48*2 = .96 0
.96*2 = 1.92 1
.92*2 = 1.84 1
.84*2 = 1.68 1
.68*2 = 1.36 1
.36*2 = .72 0
.72*2 = 1.44 1
.44*2 = .88 1(向上舍入,因为现在我们总共有23位)
11101001000.110001111011 =尾数23位
添加0表示符号
0 11101001000.110001111011
现在我需要将小数移动10个以上
1.1101001000110001111011 x 2 ^ 10指数现在是10
添加0位以使全尾数为23位
1.11010010001100011110110
指数是10所以10 + 127 = 137
等于10001001
所以0 10001001 11010010001100011110110是32位数.
这看起来像是一个体面的方法吗?我测试了这个值并写下了这个问题,我实际上可以自己完成它.
用这个测试十进制FP. http://www.h-schmidt.net/FloatConverter/IEEE754.html
binary ×1
c ×1
cordova ×1
delay ×1
fastclick.js ×1
ieee-754 ×1
jquery ×1
mongoose ×1
performance ×1