我有一个看起来像这样的Json对象:
{
wvw_matches: [
{
wvw_match_id: "1-4",
red_world_id: 1011,
blue_world_id: 1003,
green_world_id: 1002,
start_time: "2013-09-14T01:00:00Z",
end_time: "2013-09-21T01:00:00Z"
},
{
wvw_match_id: "1-2",
red_world_id: 1017,
blue_world_id: 1021,
green_world_id: 1009,
start_time: "2013-09-14T01:00:00Z",
end_time: "2013-09-21T01:00:00Z"
}
]
}
Run Code Online (Sandbox Code Playgroud)
它包含的数组中的对象比上面显示的示例多得多.无论如何,我需要根据wvw_match_id选择Json对象.
我怎么做到这一点?:)
我需要检查我的数据库中是否有两个日期和另外两个日期.
我的数据库看起来像这样
+----+--------------+------------+------------+
| id | code | StartDate | EndDate |
+----+--------------+------------+------------+
| 1 | KUVX-21-40 | 2013-10-23 | 2013-11-22 |
| 2 | UEXA286-1273 | 2013-10-30 | 2013-11-29 |
| 3 | UAJFAU-2817 | 2013-10-21 | 2013-11-20 |
| 4 | KUVX-21-40 | 2013-10-30 | 2013-11-29 |
+----+--------------+------------+------------+
Run Code Online (Sandbox Code Playgroud)
在我的查询中,我指定范围:开始日期和结束日期让它们如下所示:
ScopeStartDate = "2013-10-1"
ScopeEndDate = "2013-11-26"
Run Code Online (Sandbox Code Playgroud)
上面应该返回所有记录,因为所有记录都与时间跨度重叠.
但是我无法查询工作:/
我试过以下查询没有运气:
WHERE
(
(StartDate < ScopeStartDate AND StartDate > ScopeStartDate)
OR
(StartDate > ScopeStartDate AND EndDate < ScopeEndDate )
)
Run Code Online (Sandbox Code Playgroud)
这给我两个结果: …
我正在尝试将Omnipay Paypal软件包与我的Laravel 4.1应用程序集成。我已经按照Omnipay的建议安装了laravel-omnipay软件包,并按照说明进行了设置。
我已经将laravel-omnipay包添加到了Laravel的app.php文件中的providers数组和aliases数组中。配置文件也已创建。
我的composer.json具有以下要求:
"ignited/laravel-omnipay": "1.*",
"omnipay/paypal": "~2.0"
Run Code Online (Sandbox Code Playgroud)
点火/ laravel-omnipay的配置文件如下所示:
<?php
return array(
// The default gateway to use
'default' => 'paypal',
// Add in each gateway here
'gateways' => array(
'paypal' => array(
'driver' => 'Paypal_Express',
'options' => array(
'solutionType' => '',
'landingPage' => '',
'headerImageUrl' => ''
)
)
)
);
Run Code Online (Sandbox Code Playgroud)
但是当我打电话时$gateway = Omnipay::gateway('paypal');
我得到了错误
找不到类别'\ Omnipay \ Paypal \ ExpressGateway'”
有什么我要忘记的吗?:一世
这可能是一种棘手的问题.基本上我有一个看起来像这样的课:
class Timer
{
public string boss { get; set; }
public List<DateTime> spawnTimes { get; set; }
public TimeSpan Runtime { get; set; }
public BossPriority priority { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我想在我的对象中添加DateTimes列表.所以我创建了一个如下所示的列表:
List<Timer> bosses = new List<Timer>();
Run Code Online (Sandbox Code Playgroud)
我希望我可以做类似的事情,添加DateTimes:
bosses.Add(new Timer { boss = "Tequatl", priority = BossPriority.HardCore, spanTimes = { DateTime.ParseExact("07:00 +0000", "hh:mm zzz", CultureInfo.InvariantCulture) } });
Run Code Online (Sandbox Code Playgroud)
不幸的是,这给了我一个"对象引用未设置为对象的实例".错误.
像这样做,也没有区别:(
Timer boss = new Timer();
DateTime t1 = DateTime.ParseExact("07:00 +0000", "hh:mm zzz", CultureInfo.InvariantCulture);
DateTime t2 = DateTime.ParseExact("11:30 +0000", "hh:mm …
Run Code Online (Sandbox Code Playgroud) 如果我想在Laravel中创建一个函数,那在我的应用程序中随处可用,我该怎么做呢?
我的意思是,如果我创建一个名为resizeimage()的函数并想在我的Laravel应用程序中的任何地方调用它,我该怎么做?
我正在为我的学校制作一个系统,我们可以检查学生是否入围黑人,参加派对和其他活动.我很容易检查学生是否被列入黑名单,因为我可以在我的数据库中查看学生并查看他/她是否列入黑名单.
这是困难的地方.
在我们的聚会上,每个学生都可以邀请一个人.理论上,黑名单的学生可以被另一名学生邀请并绕过该系统.我无法查看黑名单上的学生的客人表,因为当您邀请客人时只提供姓名.
因此,我需要检查列入黑名单的名称是否接近访客姓名,如果它们已经关闭则显示警告,遗憾的是有些内容需要考虑.
名字可能完全不同.在丹麦,标准名称包含三个"名字",如"Niels Faurskov Andersen"但学生可能只需键入"Niels Faurskov"或"Niels Andersen",甚至可以删除一些字符.
所以像Niels Faurskov Andersen这样的全名可能是
等等...
另一件事是丹麦字母除了通常的az之外还包含"æøå".据说,整个站点和数据库都是UTF-8编码的.
我已经研究了各种方法来检查两个字符串之间的区别,而Levenshtein距离并没有完全发挥作用.
我在StackOverflow上找到了这个线程:获得最接近的字符串匹配
这似乎提供了正确的数据,但我不太确定选择哪种方法
我在php编写这部分代码,是否有人知道如何做到这一点?也许与MySQL?或Levenshtein距离的修改版本?正则表达式可以吗?
我刚开始使用cropit,我遇到了一些问题.
我试图找到提交裁剪图像的最佳方法,我发现很难找到一个明确的答案,即使在谷歌搜索时也是如此.
到目前为止,我的想法是:
方式1
从新的位置获取js的位置,提交新的位置并裁剪它,我从js获得.
方式2
提交裁剪图像的base64版本作为隐藏表单元素.我担心我不能以这种方式获得完整的图像,因为预览(裁剪图像的位置)比实际应该的最终图像小.
关于什么是获得裁剪图像的最佳方法的任何想法?
$(function() {
$('.image-editor').cropit({
imageState: {
src: 'http://lorempixel.com/500/400/'
}
});
});
Run Code Online (Sandbox Code Playgroud)
.cropit-image-preview {
background-color: #f8f8f8;
background-size: cover;
border: 1px solid #ccc;
border-radius: 3px;
margin-top: 7px;
width: 275px;
height: 102px;
cursor: move;
}
.cropit-image-background {
opacity: .2;
cursor: auto;
}
.image-size-label {
margin-top: 0.6rem;
}
Run Code Online (Sandbox Code Playgroud)
<script src="http://scottcheng.github.io/cropit/scripts/vendor.js"></script>
<form>
<div class="image-editor">
<label>Cover Image</label>
<input type="file" class="cropit-image-input">
<div class="cropit-image-preview"></div>
<div class="image-size-label">
Resize image
</div>
<input type="range" class="cropit-image-zoom-input">
<p class="help-block">Optimal size is 550x203.</p>
</div>
<input type="submit"/>
</form> …
Run Code Online (Sandbox Code Playgroud)我现在花了很长时间,尝试在java中转换数字1.2846202978398e+19,但没有任何运气。目前我正在尝试做的事情(long)Double.parseDouble(hashes)
,但这给出了 9223372036854775807,这显然是不正确的。实际数字应类似于 12855103593745000000。
使用int val = new BigDecimal(stringValue).intValue();
return-134589568
因为它无法保存结果。将代码切换为long val = new BigDecimal(hashes).longValue();
-5600541095311551616 这也是不正确的。
我假设这是由于双精度型与长型相比的大小造成的。
有任何想法吗?
所以,这可能是一个非常愚蠢的问题,但我很难找到真正有用的答案.
所以我得到了一个看起来像这样的xml.
<LocationList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlopen.rejseplanen.dk/xml/rest/hafasRestStopsNearby.xsd">
<StopLocation name="Tesdorpfsvej (Odense Kommune)" x="10400699" y="55388303" id="461769300" distance="205"/>
<StopLocation name="Tesdorpfsvej / Munkebjergvej (Odense Kommune)" x="10400681" y="55388303" id="461055900" distance="206"/>
<StopLocation name="Munkebjerg Plads (Odense Kommune)" x="10401589" y="55386873" id="461120400" distance="312"/>
<StopLocation name="Munkebjergvej (Odense Kommune)" x="10397463" y="55390514" id="461038500" distance="372"/>
<StopLocation name="Jagtvej (Odense Kommune)" x="10396456" y="55389489" id="461019400" distance="420"/>
<StopLocation name="Allegade (Odense Kommune)" x="10396618" y="55390721" id="461026900" distance="430"/>
<StopLocation name="Guldbergsvej (Odense Kommune)" x="10396923" y="55391422" id="461104100" distance="443"/>
<StopLocation name="Nansensgade (Odense Kommune)" x="10409436" y="55391799" id="461115400" distance="472"/>
<StopLocation name="Chr. Sonnes Vej (Odense Kommune)" x="10404483" y="55385219" …
Run Code Online (Sandbox Code Playgroud) 我有一个看起来像这样的XML
<TripList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlopen.rejseplanen.dk/xml/rest/hafasRestTrip.xsd">
<Trip>
<Leg name="til fods" type="WALK">...</Leg>
<Leg name="Bus 61" type="BUS">...</Leg>
<Leg name="til fods" type="WALK">...</Leg>
<Leg name="Bus 52" type="BUS">...</Leg>
<Leg name="til fods" type="WALK">...</Leg>
</Trip>
<Trip>
<Leg name="til fods" type="WALK">...</Leg>
<Leg name="Bus 61" type="BUS">...</Leg>
<Leg name="til fods" type="WALK">...</Leg>
<Leg name="Bus 52" type="BUS">...</Leg>
<Leg name="til fods" type="WALK">...</Leg>
</Trip>
<Trip>
<Leg name="til fods" type="WALK">...</Leg>
<Leg name="Bus 191" type="BUS">...</Leg>
<Leg name="til fods" type="WALK">...</Leg>
<Leg name="Bus 152" type="BUS">...</Leg>
<Leg name="til fods" type="WALK">...</Leg>
</Trip>
<Trip>
<Leg name="til fods" type="WALK">...</Leg>
<Leg name="Bus 31" type="TB">...</Leg>
<Leg …
Run Code Online (Sandbox Code Playgroud) 在使用Crypt::Encrypt('secret')
Laravel时,我需要在C#中创建相同的结果.我发现这个线程Rijndael 256在c#和php之间加密/解密?
它似乎是我需要的,但我在第三个参数,初始化矢量:(.
Laravel使用Rijndael AES加密数据.所有用户必须输入的是一个秘密密钥,在config文件夹中,它是完全随机的,长度为32个字符.
encyrption方法如下所示:
public function encrypt($value)
{
$iv = mcrypt_create_iv($this->getIvSize(), $this->getRandomizer());
$value = base64_encode($this->padAndMcrypt($value, $iv));
// Once we have the encrypted value we will go ahead base64_encode the input
// vector and create the MAC for the encrypted value so we can verify its
// authenticity. Then, we'll JSON encode the data in a "payload" array.
$mac = $this->hash($iv = base64_encode($iv), $value);
return base64_encode(json_encode(compact('iv', 'value', 'mac')));
}
Run Code Online (Sandbox Code Playgroud)
完整的Encryptor.php可以在这里找到:http://pastebin.com/yfWLPxGn
有什么想法我必须输入以获得相同的结果?:)
我正在创建一个搜索功能来搜索一些图片.每张图片都有一个状态,表示是否被批准或拒绝.mysql在返回之前检查状态,但它仍然返回不应返回的图像.
这是我的查询:
SELECT * FROM Pictures
WHERE ImageTitle LIKE '%yaa%'
OR ImageDescription LIKE '%yaa%'
AND Approval='Approved'
Order BY DateTime DESC
Run Code Online (Sandbox Code Playgroud)
"yaa"是现在的搜索.这只是一个例子.查询返回标记为已批准的结果,但也返回标记为已拒绝的结果.我的查询有什么问题?
我已经尝试将AND语句移动到查询的开头,返回相同的内容.
我试图匹配一个看起来像这样的序列:ABC-.使用正则表达式使用expresso来测试我的正则表达式,我可以看到
ABC-1(当然)匹配ABC-2 ABC-!ABC-D ABC-z ......
但是,当我指定
preg_match('ABC-.', 'ABC-1')
Run Code Online (Sandbox Code Playgroud)
返回false布尔值
将正则表达式更改为
ABC-.
要么
ABC-.
也会返回虚假,有人能告诉我我做错了什么吗?
php ×6
c# ×5
laravel ×3
mysql ×3
datetime ×2
laravel-4 ×2
linq-to-xml ×2
regex ×2
compare ×1
crop ×1
encryption ×1
java ×1
javascript ×1
jquery ×1
json ×1
json.net ×1
list ×1
long-integer ×1
object ×1
omnipay ×1
paypal ×1
preg-match ×1
sql ×1
xml ×1
xml-parsing ×1
xmlnode ×1