小编dou*_*eep的帖子

jquery append/prepend/wrapInner?

预期结果:

.prepend()


启动html:

<li><a><span class="icon"></span><span class="text">Link Text</span></a></li>
Run Code Online (Sandbox Code Playgroud)

我试图单独使用.append(),但没有给出所需的输出..wrapInner().prepend()


.append()

输出:

.wrapInner()


<li><a>Link Text</a></li>
Run Code Online (Sandbox Code Playgroud)

输出:

.prepend()

我在这里设置了一个jsfiddle.有没有办法实现我想要的?

javascript jquery append

1
推荐指数
1
解决办法
3578
查看次数

使用jquery包含div内所有图像的链接

我有这样的事情:

<img class="photo" src="www.example.com" />
<img class="photo" src="www.example2.com" />
<img class="photo" src="www.example3.com" />
Run Code Online (Sandbox Code Playgroud)

我需要得到这个:

<a href="www.example.com" class="link">
    <img class="photo" src="www.example.com" />
</a>
<a href="www.example2.com" class="link">
    <img class="photo" src="www.example.com2" />
</a>
<a href="www.example3.com" class="link">
    <img class="photo" src="www.example.com3" />
</a>
Run Code Online (Sandbox Code Playgroud)

我需要添加链接,href使用与每个图像的SRC相同的代码,以及一个类.

我试图像这样做:

$('.photo').wrapAll('<a>');
Run Code Online (Sandbox Code Playgroud)

但它甚至不起作用.我究竟做错了什么?

谢谢.

javascript jquery image hyperlink

1
推荐指数
1
解决办法
4169
查看次数

linq list string就好

我有一个列表:List(Of String)

我想用linq过滤它.

我使用这样的东西:newList =(from l in myList Where l Like String.Format("%{0}%",value)).ToList

价值就像"一个"或"不"或......

我想在sql中像"LIKE"这样的东西:比如"%a%",所以我会得到一个字符串列表,其中每个字符串中都有一个"a".

我应该怎么做?

保护你

List(Of String)
Run Code Online (Sandbox Code Playgroud)

linq

1
推荐指数
1
解决办法
6048
查看次数

为什么这段代码会导致竞争?

可以有人解释一下,为什么作者认为下面部分源代码导致竞争?作者说:"如果有多个线程从队列中删除项目,但是在单一消费者系统中(如此处所讨论的),这种设计受制于空,前和弹出调用之间的竞争条件,这不是问题."

请参阅:http://digg.com/newsbar/topnews/How_to_write_a_Thread_Safe_Queue_in_C

谢谢

template<typename Data>
class concurrent_queue
{
private:
    std::queue<Data> the_queue;
    mutable boost::mutex the_mutex;
public:
    void push(const Data& data)
    {
        boost::mutex::scoped_lock lock(the_mutex);
        the_queue.push(data);
    }

    bool empty() const
    {
        boost::mutex::scoped_lock lock(the_mutex);
        return the_queue.empty();
    }

    Data& front()
    {
        boost::mutex::scoped_lock lock(the_mutex);
        return the_queue.front();
    }

    Data const& front() const
    {
        boost::mutex::scoped_lock lock(the_mutex);
        return the_queue.front();
    }

    void pop()
    {
        boost::mutex::scoped_lock lock(the_mutex);
        the_queue.pop();
    }
};
Run Code Online (Sandbox Code Playgroud)

c++ multithreading synchronization

1
推荐指数
1
解决办法
187
查看次数

在wordpress中:在div中包含每3个内容div?

我需要每三个类"loopcontent"的div包含在一个新的div"threeacross"中.我是wordpress的新手,还不是一个php的家伙,但我正在学习.

这是我的循环:

        <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
            <div class="loopcontent">
                <?php
                    if ( has_post_thumbnail() ) {
                        the_post_thumbnail();
                    } else {
                        // the current post lacks a thumbnail
                    }
                ?>
                <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
                <?php the_excerpt(); ?>
            </div>

        <?php endwhile; else : ?>

            <div class="loopcontent">
                <h1>Page Not Found</h1> 
                <p>Looks like the page you're looking for isn't here anymore. Try browsing the <a href="">categories</a>, <a href="">archives</a>, or using the search box below.</p>
                <?php include(TEMPLATEPATH.'/searhform.php'); ?>
            </div>

        <?php endif; ?>
Run Code Online (Sandbox Code Playgroud)

html wordpress loops

1
推荐指数
1
解决办法
3383
查看次数

尝试/捕获/最后,在最后使用Catch中的异常?

try catch finally在这里看了几个其他的问题,但我不确定这个问题是否得到了解答.做以下事情是不是很糟糕:

Exception? ex = null;
try { //something }
catch (Exception e) { ex = e ;}
finally {
    DoSomething();        
}
... //more code

//end of method
if (ex !=null) { throw ex; }
Run Code Online (Sandbox Code Playgroud)

基本上,我正在尝试确保运行某些代码(在try/catch/finally之外)并且如果发生异常则抛出异常,但直到所述代码运行之后才会抛出异常.我无法将所有代码放在finally块中,因为它超出了某些条件.

如果这样做,事实上,气味不好(我怀疑它确实如此),如何实现这一目标?

c# try-catch-finally

1
推荐指数
1
解决办法
622
查看次数

固定屏幕上的布局比例

在我的应用程序中,我有2个线性布局:一个在顶部,一个在底部.

我希望无论这些布局如何,顶部的布局占据屏幕高度的60%,底部布局占40%.这是我的XML代码:

   <?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:layout_weight="1.0" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.6"
        android:orientation="vertical" 
         android:id="@+id/layout_top">
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_weight="0.4" 
        android:id="@+id/layout_bottom">
    </LinearLayout>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

当这些布局是空的,没有问题时,它们具有良好的比例.

问题是,如果我在顶部布局中放置一个小的列表视图,那么布局将采用列表视图的大小,并且不会保留60/40%的比例.

即使我的列表视图很小(例如只有3项),我也会喜欢它,布局保留了60%,所以在我的listview下放了一些空白区域.

我试着寿变化android:layout_heightmatch_parent,但它不会改变任何东西.

谢谢.

android percentage android-layout android-view android-layout-weight

1
推荐指数
1
解决办法
2875
查看次数

Datalogic得利捷条形码/重量扫描仪

谁能给我任何关于从哪里开始编码的想法,以便从 C# 中的 OPOS(Datalogic Magellan 设备)加权和条形码扫描获取数据?例如,在这种情况下我应该使用什么库和什么函数。我一无所知,因为我已经花了很多时间在网上寻找答案。甚至在网上也没有接近。

我不知道有什么 API 可以用来将 USB 设备的重量和条形码输入到我的 C# 程序中。

我目前正在使用 Datalogic 体重秤。我尝试了内置的 Windows 阅读器,但它没有从设备读取任何数据。

.net c# barcode-scanner

1
推荐指数
1
解决办法
5397
查看次数

从Confluence 3.5迁移到Confluence 4.2.3后,链接无效

我们在Confluence版本3.5中编辑了大量带有文本的页面,但是在一个好日子里,我们决定将我们的系统升级到版本4.3.2.结果,现在,我们遇到了很大的数据问题.

项目中的所有链接都开始无效,文本字段的标记也发生了变化,我认为它与Confluence中的重大更改有关.

所以现在我试图找到如何更新这些数据并返回漂亮视图的方法.有插件吗?还是脚本?或者Confluence的任何默认功能来完成这项工作.

confluence

1
推荐指数
1
解决办法
1020
查看次数

循环遍历MySQL结果集时,PHP'允许的内存大小为67108864字节已用尽'

自从大约7年前开发我的第一个mySQL项目以来,我一直在使用相同的一组简单函数来访问数据库(尽管最近将这些函数放入了数据库类).随着我开发的项目变得越来越复杂,数据库中有更多的记录,因此更有可能出现内存问题.

Allowed memory size of 67108864 bytes exhausted在循环访问mySQL结果集时遇到PHP错误,并且想知道是否有更好的方法来实现我没有高内存使用的灵活性.

我的功能看起来像这样:

function get_resultset($query) { 
    $resultset = array();

    if (!($result = mysql_unbuffered_query($query))) {
        $men = mysql_errno();
        $mem = mysql_error();
        echo ('<h4>' . $query . ' ' . $men . ' ' . $mem . '</h4>');
        exit;
    } else {
        $xx = 0 ;
        while ( $row = mysql_fetch_array ($result) )  {
            $resultset[$xx] = $row;
            $xx++ ;
        }
        mysql_free_result($result);
        return $resultset;
    }
}
Run Code Online (Sandbox Code Playgroud)

然后我可以编写一个查询并使用该函数来获取所有结果,例如:

$query = 'SELECT * FROM `members`';
$resultset = …
Run Code Online (Sandbox Code Playgroud)

php mysql memory resultset

1
推荐指数
1
解决办法
983
查看次数