走过海棠暮

文章 评论 浏览 25

走过海棠暮 2024-10-07 02:22:51

你为什么要这样做?无论如何,你可以用一种“有点”肮脏的方式来做到这一点:

segment.construct<Equipments>((char*)123)("param1", "param2");

只要 sizeof(char*) >= sizeof(int) 在你的平台上(在 Win32/Win64 上),就可以安全地转换指针返回整数而不丢失信息。请确保您没有将指针值用作有效的 char* 指针。

哦,您必须确保底层库代码不会尝试将该值用作有效的字符指针。

Why would you want to do this? In any case, you can do it in a "bit" dirty way:

segment.construct<Equipments>((char*)123)("param1", "param2");

As long as sizeof(char*) >= sizeof(int) on your platform (which it is on Win32/Win64), the pointer can be safely cast back to the integer without loss of information. Just be sure that you don't use the pointer value as a valid char* pointer.

Oh, and you have to be sure that the underlying library code will not try to use the value as a valid char pointer.

使用整数标识符在共享内存上构造对象

走过海棠暮 2024-10-07 02:14:57

不幸的是,隐藏字段,甚至是“display:none”HTML 组件,也会被发送到服务器。

一个可能的解决方案可能是添加另一个 字段,并在显示/隐藏 div 时更改其值,这样您就会在服务器端知道如果您需要“考虑”“dealImage_xxx”的值或不“考虑”。

Unfortunately hidden fields, even into 'display:none' HTML components, are sent to the server.

A possible solution could be adding another <input type="hidden" .../> field and change its value when you show/hide the div, so you will be aware on server side if you need to "consider" the value of "dealImage_xxx" or not.

使用 PHP 时隐藏值正在传递,而 div 的显示样式为 none

走过海棠暮 2024-10-06 23:08:06

3 年后,但提供一个良好的工作解决方案永远不会太晚

这将转义除换行符之外的所有 HTML 字符(兼容 Linux、Windows 和 Mac)

html_escape(@place.description).gsub(/(?:\n\r?|\r\n?)/, '<br />').html_safe

3 years later, but it's never too late to provide a good working solution

This will escape all HTML chars but the newlines (compatible Linux, Windows and Mac)

html_escape(@place.description).gsub(/(?:\n\r?|\r\n?)/, '<br />').html_safe

转义 HTML 输出但不换行

走过海棠暮 2024-10-06 20:20:43

有可能:
请参阅 Rails 国际化 (I18n) API 中的4.1.2 默认值部分。

I18n.t :missing, :default => 'Not here'
# => 'Not here'

It is possible:
See section 4.1.2 Defaults at Rails Internationalization (I18n) API.

I18n.t :missing, :default => 'Not here'
# => 'Not here'

如何使用 i18n 键作为 Rails 3 中的默认翻译?

走过海棠暮 2024-10-06 12:00:24

将其放在每个内容之后:

  <div class="fb-like" data-href="unique_url_here_for_the_content" data-send="true" data-layout="button_count" data-width="100" data-show-faces="true"></div>

将“unique_url_here_for_the_content”替换为内容的实际 url

要修改 data-* atrribute,请转到 fb like 插件页面 这里

当然你需要在 body 标签之后使用它

 <div id="fb-root"></div>
 <script>(function(d, s, id) {
 var js, fjs = d.getElementsByTagName(s)[0];
 if (d.getElementById(id)) return;
 js = d.createElement(s); js.id = id;
 js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
 fjs.parentNode.insertBefore(js, fjs);
 }(document, 'script', 'facebook-jssdk'));</script>

Put this after each content:

  <div class="fb-like" data-href="unique_url_here_for_the_content" data-send="true" data-layout="button_count" data-width="100" data-show-faces="true"></div>

replace "unique_url_here_for_the_content" with the actual url of the content

To modify data-* atrribute please go to fb like plugin page here

and of couse you need to use this after the body tag

 <div id="fb-root"></div>
 <script>(function(d, s, id) {
 var js, fjs = d.getElementsByTagName(s)[0];
 if (d.getElementById(id)) return;
 js = d.createElement(s); js.id = id;
 js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
 fjs.parentNode.insertBefore(js, fjs);
 }(document, 'script', 'facebook-jssdk'));</script>

Facebook 点赞按钮,用于点赞索引/列表页面上的各个内容项

走过海棠暮 2024-10-05 22:00:57

在控制器中,您将传递给局部的 @comments 定义为相册上的评论数组:

@comments = @photoalbum.comments.roots.order("created_at DESC")

然后将局部中的可评论对象设置为相册中的第一张照片。

<%= render :partial => 'comments/index',:locals => {:commentable=> @photo.first,:comments => @comments}%>

所以,是的,您在对照片发布新评论的同时列出了相册的评论。将@comments 更改为照片的评论。

In your controller, you define @comments passed to the partial as the array of comments on your photo album:

@comments = @photoalbum.comments.roots.order("created_at DESC")

And then set the commentable object in your partial to the first photo in your album.

<%= render :partial => 'comments/index',:locals => {:commentable=> @photo.first,:comments => @comments}%>

So yes, you are listing an album's comments while posting new comments to a photo. Change @comments to comments for a photo.

相册、照片 - 相册分页

走过海棠暮 2024-10-05 17:07:07

您的语法错误:

select name, city, count(*) from table group by name, city having count(*) > 1

如果您对实际计数不感兴趣,请从查询中删除“, count(*)

You have the syntax wrong:

select name, city, count(*) from table group by name, city having count(*) > 1

If you are not interested in the actual count, remove ", count(*)" from the query

sql查询获取冗余记录

走过海棠暮 2024-10-05 07:02:16

您可以尝试创建一个 CSV 文件,如下所示:

name;surname;blabla
name;surname;blabla
name;surname;blabla
name;surname;blabla

Excel 应该吃这个:)

使用 PHP CVS 函数很方便: http://php.net/manual/en/function.fputcsv.php

You can try and create a CSV file, like this:

name;surname;blabla
name;surname;blabla
name;surname;blabla
name;surname;blabla

Excel should eat this :)

It is convenient to use PHP CVS functions: http://php.net/manual/en/function.fputcsv.php

如何使用 PHP 将数据写入 Excel?

走过海棠暮 2024-10-05 06:21:42
 netstat -anp |grep -i udp

流程在最后一栏

 netstat -anp |grep -i udp

The process is at the last column

如何识别 Linux 上哪个进程正在发送 UDP 流量?

走过海棠暮 2024-10-05 03:32:13

我已经找到问题了。它位于我的项目 A 的清单文件中。我不应该在那里声明活动 B。基本上来说,为了正确地从另一个应用程序(项目 B)调用活动,需要完成以下操作:

1)。通过运行或调试来安装应用程序 B(当然!)。

2)。在自己的项目中正确声明了活动 B 的意图过滤器。无需在将调用它的项目中声明它(这是我的错误所在)。

3)。使用意图过滤器中指定的意图启动活动。

将答案发布在这里,以防其他人遇到与我相同的问题:)

I've found the problem. It lies within my manifest file of project A. I shouldn't have declared the activity B there. So basically said, in order to correctly call an activity from another application (project B) the things need to be done:

1). Install the application B (of course!) by running or debugging it.

2). Declared the intent-filter of activity B correctly in its own project. No need to declare it in the project which will call it (this is where my mistake was).

3). Start the activity using the intent specified in the intent-filter.

Posted the answer here just in case someone else encounter the same problem as mine :)

两个不同项目的 R.java 的资源 id 冲突

走过海棠暮 2024-10-05 02:46:53
using System.Xml.Schema;
using System.IO;
using System.Reflection;

这应该可以工作,可能会引发一些错误,因为我没有在 IDE 中编译它,因为我不在开发机器 atm 上。

string xsd = "example.xsd";

FileStream fs;
XmlSchema schema;

fs = new FileStream(xsd, FileMode.Open);
schema = XmlSchema.Read(fs, new ValidationEventHandler(ShowCompileError));

foreach (XmlSchemaObject externalSchema in schema.Includes)
{
    string schemaLoc = (XmlSchemaExternal)externalSchema.SchemaLocation.ToString();
}
using System.Xml.Schema;
using System.IO;
using System.Reflection;

This should work, might throw some errors, as I didnt compile it in an IDE as im not on a Dev machine atm.

string xsd = "example.xsd";

FileStream fs;
XmlSchema schema;

fs = new FileStream(xsd, FileMode.Open);
schema = XmlSchema.Read(fs, new ValidationEventHandler(ShowCompileError));

foreach (XmlSchemaObject externalSchema in schema.Includes)
{
    string schemaLoc = (XmlSchemaExternal)externalSchema.SchemaLocation.ToString();
}

在 C# XmlSchema 中查找 schemaLocation

走过海棠暮 2024-10-05 02:18:20

要按月排序,请使用以下命令:

  ORDER BY DATEPART(Month,Created) ASC

DatePart() 返回指定部分的整数,1 表示一月,2 表示二月等。


您的 SQL 可以使用 COALESCE() 和 ISNULL( ) 函数。这与您的第一个选择相同:

SELECT
    COALESCE(tmpActivity.Year,tmpCreated.Year,tmpContactsCreated.Year) as Year, 
    COALESCE(tmpActivity.Month,tmpCreated.Month,tmpContactsCreated.Month) as Month,
    ISNULL(tmpActivity.ActiveAccounts,0) AS ActiveAccounts, 
    ISNULL(tmpCreated.NewAccounts,0) AS NewAccounts, 
    ISNULL(tmpContactsCreated.NewContacts,0) AS NewContacts

我认为您的选择中有一个错误,我相信您的最后一行必须是这样的:

) as tmpContactsCreated ON (tmpContactsCreated.Year = tmpCreated.Year AND tmpContactsCreated.Month = tmpCreated.Month) OR
                           (tmpContactsCreated.Year = tmpActivity.Year AND tmpContactsCreated.Month = tmpActivity.Month)     

但我必须对此进行测试以确定。


添加汇总很难做到——通常这是在控件中的 SQL 或任何显示结果的外部完成的。您可以这样做(人为的示例):

SELECT 1 as reportOrder, date, amount, null as total
FROM invoices
UNION ALL
SELECT 2 , null, null, sum(amount)
FROM invoices
ORDER BY reportOrder, date

或者您不能拥有“额外”总计列并将其放入金额列中。

To order by the month use the following:

  ORDER BY DATEPART(Month,Created) ASC

DatePart() returns an integer for the part specified 1 for January, 2 for Febuary etc.


You're SQL could be helped with the COALESCE() and ISNULL() functions. This is the same as your first select:

SELECT
    COALESCE(tmpActivity.Year,tmpCreated.Year,tmpContactsCreated.Year) as Year, 
    COALESCE(tmpActivity.Month,tmpCreated.Month,tmpContactsCreated.Month) as Month,
    ISNULL(tmpActivity.ActiveAccounts,0) AS ActiveAccounts, 
    ISNULL(tmpCreated.NewAccounts,0) AS NewAccounts, 
    ISNULL(tmpContactsCreated.NewContacts,0) AS NewContacts

I think there is a bug in your select, I believe your last line has to be this:

) as tmpContactsCreated ON (tmpContactsCreated.Year = tmpCreated.Year AND tmpContactsCreated.Month = tmpCreated.Month) OR
                           (tmpContactsCreated.Year = tmpActivity.Year AND tmpContactsCreated.Month = tmpActivity.Month)     

But I would have to test this to be sure.


Adding in rollups is hard to do -- typically this is done externally to the SQL in the control or whatever displays the results. You could do something like this (contrived example):

SELECT 1 as reportOrder, date, amount, null as total
FROM invoices
UNION ALL
SELECT 2 , null, null, sum(amount)
FROM invoices
ORDER BY reportOrder, date

or you could not have the "extra" total column and put it in the amount column.

关于我的 SQL 脚本的两个问题。如何添加小计/总计行以及排序问题

走过海棠暮 2024-10-05 00:11:02

我发现了问题。如果您没有唯一的元素名称,XML 解串器似乎会感到困惑。

I found the problem. It's seems that the xml deseraliser gets confused if you don't have unique element names.

可能的 xml 反序列化错误

走过海棠暮 2024-10-04 14:01:37

这对我来说适用于 Ubuntu 10.04。我只看到有关“标题”与“宝丽来”效果一起使用的文档。

#!/usr/bin/perl

use strict;
use warnings;
use Image::Magick;

my $im = new Image::Magick;
$im->Set(size => '586x1000');

my $e = $im->ReadImage('xc:black');

$im->Polaroid(
        fill => 'white',
        stroke => 'black',
        strokewidth => 3,
        gravity => 'center',
        pointsize => 78,
        caption => "Lorem ipsum etc etc"
);

$e = $im->Trim();
die $e if $e;

$e = $im->Set(page=>'0x0+0+0'); # +repage
die $e if $e;

$e = $im->Write('out.png');
die $e if $e;

替代文字

This works on Ubuntu 10.04 for me. I only see documentation for "caption" working with the "polaroid" effect.

#!/usr/bin/perl

use strict;
use warnings;
use Image::Magick;

my $im = new Image::Magick;
$im->Set(size => '586x1000');

my $e = $im->ReadImage('xc:black');

$im->Polaroid(
        fill => 'white',
        stroke => 'black',
        strokewidth => 3,
        gravity => 'center',
        pointsize => 78,
        caption => "Lorem ipsum etc etc"
);

$e = $im->Trim();
die $e if $e;

$e = $im->Set(page=>'0x0+0+0'); # +repage
die $e if $e;

$e = $im->Write('out.png');
die $e if $e;

alt text

如何在 PerlMagick 中将字幕居中?

走过海棠暮 2024-10-04 10:07:43

在您的管理仪表板上的“设置”->“永久链接,您可以为永久链接选择自定义结构,我相信这就是您正在寻找的。

On your admin dashboard, under Settings -> Permalinks, you can choose a custom structure for permalinks, I believe this is what you're looking for.

更改页面的 WordPress 永久链接结构

更多

推荐作者

hn8888

文章 0 评论 0

liai0114

文章 0 评论 0

以酷

文章 0 评论 0

阿楠

文章 0 评论 0

郝学勇

文章 0 评论 0

烟燃烟灭

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文