灯角

文章 0 评论 0 浏览 23

灯角 2024-12-10 00:49:19

远程服务器发送一个包含资源 mime 类型的 Content-Type 标头。例如:

Content-Type: image/png

因此您可以检查此标头的值并为您的文件选择正确的扩展名。例如:

WebRequest request = WebRequest.Create("http://0.gravatar.com/avatar/a5a5ed70fa7c651aa5ec9ca8de57a4b8?s=60&d=identicon&r=G");
using (WebResponse response = request.GetResponse())
using (Stream stream = response.GetResponseStream())
{
    string contentType = response.ContentType;
    // TODO: examine the content type and decide how to name your file
    string filename = "test.jpg";

    // Download the file
    using (Stream file = File.OpenWrite(filename))
    {
        // Remark: if the file is very big read it in chunks
        // to avoid loading it into memory
        byte[] buffer = new byte[response.ContentLength];
        stream.Read(buffer, 0, buffer.Length);
        file.Write(buffer, 0, buffer.Length);
    }
}

The remote server sends a Content-Type header containing the mime type of the resource. For example:

Content-Type: image/png

So you can examine the value of this header and pick the proper extension for your file. For example:

WebRequest request = WebRequest.Create("http://0.gravatar.com/avatar/a5a5ed70fa7c651aa5ec9ca8de57a4b8?s=60&d=identicon&r=G");
using (WebResponse response = request.GetResponse())
using (Stream stream = response.GetResponseStream())
{
    string contentType = response.ContentType;
    // TODO: examine the content type and decide how to name your file
    string filename = "test.jpg";

    // Download the file
    using (Stream file = File.OpenWrite(filename))
    {
        // Remark: if the file is very big read it in chunks
        // to avoid loading it into memory
        byte[] buffer = new byte[response.ContentLength];
        stream.Read(buffer, 0, buffer.Length);
        file.Write(buffer, 0, buffer.Length);
    }
}

如何从远程 url 获取有效的文件名和扩展名来保存它?

灯角 2024-12-09 23:58:50

尝试浮动li。或者,您可以删除标记中的空格(

  • 之间)。当您使用 display:inline-block 时会发生这种情况。
  • Try floating the lis. Or you can get rid of the spaces in your markup (between <li> and <li>). This happens when you use display:inline-block.

    为什么这些选项卡之间有空格?

    灯角 2024-12-09 23:21:54

    我也遇到了同样的问题。
    不知道这是否是最好的解决方案,可能不是,但它对我有用。

    问题是 Latlng 未被识别。所以我重新创建了数组。

    var lats = [];
    var lat_size = steps[step].lat_lngs.length;
    
    for (var t=0; t <lat_size; t++) {
    
    lats.push(new google.maps.LatLng(steps[step].lat_lngs[t].lat(), steps[step].lat_lngs[t].lng()))
              }
    var polylineOptions = {
    map: map,
    path: lats
     }
    
    new google.maps.Polyline(polylineOptions);
    

    I was having the same problem.
    Don't know if its the best solution, probably not, but it worked for me.

    The problem was that the Latlng weren't being recognized. So I recreated the array.

    var lats = [];
    var lat_size = steps[step].lat_lngs.length;
    
    for (var t=0; t <lat_size; t++) {
    
    lats.push(new google.maps.LatLng(steps[step].lat_lngs[t].lat(), steps[step].lat_lngs[t].lng()))
              }
    var polylineOptions = {
    map: map,
    path: lats
     }
    
    new google.maps.Polyline(polylineOptions);
    

    谷歌地图 v3:绘制折线时构造函数参数 0 的值无效

    灯角 2024-12-09 12:48:35

    尝试以下操作,在命令提示符中

    adb devices
    

    查看是否显示连接的设备列表(

    如果没有),然后确保在测试设备上启用了调试
    要启用调试,请转到

    Phone Settings --> Applications --> Development --> Enable USB Debugging
    

    选中标记,然后尝试 adb devices

    Try the following, in your command prompt

    adb devices
    

    see if it shows the list of devices attached

    if not , then make sure you have debugging enabled on your test device
    To enable debugging go to

    Phone Settings --> Applications --> Development --> Enable USB Debugging
    

    Check mark it , the try adb devices

    为什么我在 Eclipse 的 DDMS 透视模式下看不到我的 Android 设备?

    灯角 2024-12-09 10:05:14

    诀窍是实际移动 DOM 中的元素。使用 .prependTo("#container"):

    http://jsfiddle.net/LA22t /7/

    $(".item a").click(function() {
        $(".desc").hide();
        $(this).parent().prependTo("#container").find(".desc").animate({height:"show"});
    });
    

    The trick is to actually move the elements in the DOM. Use .prependTo("#container"):

    http://jsfiddle.net/LA22t/7/

    $(".item a").click(function() {
        $(".desc").hide();
        $(this).parent().prependTo("#container").find(".desc").animate({height:"show"});
    });
    

    在 div 内移动内容?

    灯角 2024-12-09 09:32:36

    FreeBSD 是一个有凝聚力的系统。 Linux 是一个内核加上一堆软件包,而 FreeBSD 的所有核心都是构建在一起的(除了 ports 树之外的所有内容)。 FreeBSD 手册是开始学习的最佳资源免费的BSD。 FreeBSD 网站上还提供了一份开发人员手册。至于内核在源文件方面是什么,/usr/src/sys 下的任何内容都是内核源代码。如果您想了解内核的工作原理,《FreeBSD 操作系统的设计与实现》一书是有关内核细节的权威指南。

    FreeBSD is one cohesive system. Whereas Linux is a kernel plus a bunch of packages, all of FreeBSD core is built together (everything but the ports tree). The FreeBSD Handbook is the best resource to start from for learning FreeBSD. There is also a Developer's handbook that can be found on the FreeBSD website. As for what the kernel is in terms of source files, anything under /usr/src/sys is kernel source code. If you want to know about the workings of the kernel, the book "The Design and Implementation of the FreeBSD Operating System" is the definitive guide to the details of the kernel.

    削减 freebsd

    灯角 2024-12-09 07:23:27

    更新:找到了更好的方法,如果将Effect直接应用于ScrollViewer,则可以跳过Border部分将文本封装在模板中。

    <TextBox Text="Shadow Text">
        <TextBox.Resources>
            <Style TargetType="ScrollViewer">
                <Setter Property="Effect">
                    <Setter.Value>
                        <DropShadowEffect ShadowDepth="4"
                                          Direction="330"
                                          Color="Black"
                                          Opacity="0.5"
                                          BlurRadius="4"/>
                    </Setter.Value>
                </Setter>
            </Style>
        </TextBox.Resources>
    </TextBox>
    

    更新2:错过了在代码中创建TextBox的部分。这是与上面的 Xaml 等效的 C#

    Setter effectSetter = new Setter();
    effectSetter.Property = ScrollViewer.EffectProperty;
    effectSetter.Value = new DropShadowEffect
    {
        ShadowDepth = 4,
        Direction = 330,
        Color = Colors.Black,
        Opacity = 0.5,
        BlurRadius = 4
    };
    Style dropShadowScrollViewerStyle = new Style(typeof(ScrollViewer));
    dropShadowScrollViewerStyle.Setters.Add(effectSetter);
    
    TextBox dropShadowTextBox = new TextBox();
    dropShadowTextBox.Text = "Shadow Text";
    dropShadowTextBox.Foreground = Brushes.Teal;
    dropShadowTextBox.FontSize = 40;
    dropShadowTextBox.Margin = new Thickness(10);
    dropShadowTextBox.Resources.Add(typeof(ScrollViewer), dropShadowScrollViewerStyle);
    

    好问题,一个想法是使 TextBox 的背景和 BorderBrush 透明,并将其放置在 Border 中,

    <Border BorderThickness="1"
            BorderBrush="#FF7F9DB9"
            SnapsToDevicePixels="True"
            UseLayoutRounding="True"
            Margin="10">
        <TextBox Text="Shadow Text"
                 Foreground="Teal"
                 FontSize="40"
                 Background="Transparent"
                 BorderBrush="Transparent">
            <TextBox.Effect>
                <DropShadowEffect ShadowDepth="4"
                            Direction="330"
                            Color="Black"
                            Opacity="0.5"
                            BlurRadius="4"/>
            </TextBox.Effect>
        </TextBox>
    </Border>
    

    这是与一个“正常”TextBox

    在此处输入图像描述

    Update: Found a better way, you can skip the Border part if you apply the Effect directly to the ScrollViewer that encapsulates the text in the Template.

    <TextBox Text="Shadow Text">
        <TextBox.Resources>
            <Style TargetType="ScrollViewer">
                <Setter Property="Effect">
                    <Setter.Value>
                        <DropShadowEffect ShadowDepth="4"
                                          Direction="330"
                                          Color="Black"
                                          Opacity="0.5"
                                          BlurRadius="4"/>
                    </Setter.Value>
                </Setter>
            </Style>
        </TextBox.Resources>
    </TextBox>
    

    Update 2: Missed the part of creating the TextBox in code. Here is the c# equivalent to the Xaml above

    Setter effectSetter = new Setter();
    effectSetter.Property = ScrollViewer.EffectProperty;
    effectSetter.Value = new DropShadowEffect
    {
        ShadowDepth = 4,
        Direction = 330,
        Color = Colors.Black,
        Opacity = 0.5,
        BlurRadius = 4
    };
    Style dropShadowScrollViewerStyle = new Style(typeof(ScrollViewer));
    dropShadowScrollViewerStyle.Setters.Add(effectSetter);
    
    TextBox dropShadowTextBox = new TextBox();
    dropShadowTextBox.Text = "Shadow Text";
    dropShadowTextBox.Foreground = Brushes.Teal;
    dropShadowTextBox.FontSize = 40;
    dropShadowTextBox.Margin = new Thickness(10);
    dropShadowTextBox.Resources.Add(typeof(ScrollViewer), dropShadowScrollViewerStyle);
    

    Good question, one idea is to make the Background and BorderBrush Transparent for the TextBox and place it in a Border

    <Border BorderThickness="1"
            BorderBrush="#FF7F9DB9"
            SnapsToDevicePixels="True"
            UseLayoutRounding="True"
            Margin="10">
        <TextBox Text="Shadow Text"
                 Foreground="Teal"
                 FontSize="40"
                 Background="Transparent"
                 BorderBrush="Transparent">
            <TextBox.Effect>
                <DropShadowEffect ShadowDepth="4"
                            Direction="330"
                            Color="Black"
                            Opacity="0.5"
                            BlurRadius="4"/>
            </TextBox.Effect>
        </TextBox>
    </Border>
    

    Here is a comparison with a "normal" TextBox

    enter image description here

    如何将 dropshadoweffect 添加到文本框的文本(以编程方式)

    灯角 2024-12-09 07:19:44

    只要这样做:

    $counter = 1;
    while($row = mysql_fetch_assoc($primary_img_data)) { 
        echo "<img src='new_arrivals_img/thumbnails/".$row['imgURL']."'>";//this is where I want the result number echoed
        echo $counter++;
      }
    

    Just do:

    $counter = 1;
    while($row = mysql_fetch_assoc($primary_img_data)) { 
        echo "<img src='new_arrivals_img/thumbnails/".$row['imgURL']."'>";//this is where I want the result number echoed
        echo $counter++;
      }
    

    PHP:回显结果编号

    灯角 2024-12-09 04:13:43
    (db.table.field1==x)&(db.table.field2==y)
    

    请参阅本书中有关逻辑运算符的部分。

    (db.table.field1==x)&(db.table.field2==y)
    

    See the book section on logical operators.

    web2py - 测试具有两个字段值组合的行

    灯角 2024-12-09 00:19:05

    在这种情况下,点非常重要,它用于分隔两个变量。如果没有点返回错误

    Point is very important in this case it serves to separate the two variables in this case. If there is no point return error

    有插入查询的模板吗?

    灯角 2024-12-08 23:41:16

    好的,我通常不这样做,但我也对代码的 Delphi 版本感兴趣,所以我翻译了它。尝试我的翻译,看看是否适合您。

    FWIW,还可以看看同一作者的 Dirac3LE 库。这是一个更专业的库(PSOLA,不是 WSOLA),可用于 Windows、Linux、Mac、iPhone 等。刚刚尝试了 Mac 版本,听起来不错。

    OK, I usually don't do this, but I also have an interest in having a Delphi version of the code, so I translated it. Try my translation and see if that works for you.

    FWIW, also take a look at the Dirac3LE library by the same author. That is a much more professional library (PSOLA, not WSOLA), available for Windows, Linux, Mac, iPhone, etc. Just tried the Mac version and it sounds good.

    算法 smbPitchShift (帕斯卡)

    灯角 2024-12-08 23:13:17

    您将经过身份验证的用户重定向到 $facebook->getLoginUrl(array(...)),从而创建重定向循环。

    您应该仅重定向未经身份验证的用户(使用 req_perms 进行重定向应位于 else 子句中)。仅当您检测到用户未授予您所有必需的权限时,try 中的重定向才会发生。

    您可以通过调用以下命令来检查授予的权限:

    $perms = $facebook->api(array(
        'method' => 'fql.query',
        'query' => 'SELECT email,user_birthday,status_update,publish_stream,user_photos,user_videos FROM permissions WHERE uid=' . $facebook->getUser()
    ));
    


    Modified code:

    <?php
    # We require the library
    require("facebook.php");
    
    # Creating the facebook object
    $facebook = new Facebook(array(
        'appId'  => 'APP_ID_HERE',
        'secret' => 'APP_SECRET_HERE',
        'cookie' => true
    ));
    
    # Let's see if we have an active session
    $session = $facebook->getUser();
    
    if(empty($session)) {
        # There's no active session, let's generate one
        $url = $facebook->getLoginUrl(array(
            'req_perms' => 'email,user_birthday,status_update,publish_stream,user_photos,user_videos'
        ));
        header("Location: $url");
        exit;
    }
    // user is logged in
    

    You redirect authenticated user to $facebook->getLoginUrl(array(...)), creating a redirect loop.

    You should redirect only unauthenticated users (redirect with req_perms should be in else clause). The redirect in try should happen only if you detect that user hasn't granted you all required permissions.

    You can check granted permissions by invoking:

    $perms = $facebook->api(array(
        'method' => 'fql.query',
        'query' => 'SELECT email,user_birthday,status_update,publish_stream,user_photos,user_videos FROM permissions WHERE uid=' . $facebook->getUser()
    ));
    


    Modified code:

    <?php
    # We require the library
    require("facebook.php");
    
    # Creating the facebook object
    $facebook = new Facebook(array(
        'appId'  => 'APP_ID_HERE',
        'secret' => 'APP_SECRET_HERE',
        'cookie' => true
    ));
    
    # Let's see if we have an active session
    $session = $facebook->getUser();
    
    if(empty($session)) {
        # There's no active session, let's generate one
        $url = $facebook->getLoginUrl(array(
            'req_perms' => 'email,user_birthday,status_update,publish_stream,user_photos,user_videos'
        ));
        header("Location: $url");
        exit;
    }
    // user is logged in
    

    为什么我收到“页面未正确重定向”的消息错误?

    灯角 2024-12-08 21:52:04

    好的,我已经设法使用以下 PowerShell 代码解决了我的问题:

    if(circumstances)
    {
        $fileElement = $xml.CreateElement("fileRef")
        $directoryRefElement.SetAttribute("Id",$refId)      
    }
    else # use existing node
    {
        $fileElement = ""
        $currentNode = $xml.get_Item("fileRef")
    
        do
        {
            $currentId = $currentNode.GetAttribute("Id")
            if ($currentId -eq $refId)
            {
                $fileElement = $currentNode
            }
            else
            {
                $tempNode = $currentNode
                $currentNode = $tempNode.get_NextSibling()
            }
        }
        while($fileElement -eq "")
    }
    

    当我需要查找现有的兄弟节点时,我获取我正在查找的类型的第一个节点,并根据传入的 $refId 检查它的 Id 属性。如果它们不匹配,我将查看下一个兄弟,依此类推,直到 2 个 id 匹配。

    虽然这可能不是实现我的目标的最优雅的方式,但它确实有效:-)

    Ok, I've managed to solve my problem with the following PowerShell code:

    if(circumstances)
    {
        $fileElement = $xml.CreateElement("fileRef")
        $directoryRefElement.SetAttribute("Id",$refId)      
    }
    else # use existing node
    {
        $fileElement = ""
        $currentNode = $xml.get_Item("fileRef")
    
        do
        {
            $currentId = $currentNode.GetAttribute("Id")
            if ($currentId -eq $refId)
            {
                $fileElement = $currentNode
            }
            else
            {
                $tempNode = $currentNode
                $currentNode = $tempNode.get_NextSibling()
            }
        }
        while($fileElement -eq "")
    }
    

    When I need to find an existing node sibling, I get the first node of the type I'm looking for and check it's Id attribute against the passed in $refId. If they do not match, I will look at the next sibling and so on until the 2 ids match.

    While this may not be the most elegant way to achieve my goal, it does work nonetheless :-)

    PowerShell - 从现有 XML 节点同级创建变量

    灯角 2024-12-08 21:38:35

    尝试

    $("input[type='submit']").attr("disabled", "");
    

    $("input[type='submit']").attr("disabled", false);
    

    Try

    $("input[type='submit']").attr("disabled", "");
    

    or

    $("input[type='submit']").attr("disabled", false);
    

    JQuery 在 IE7 中启用/禁用提交按钮

    灯角 2024-12-08 21:17:44
    class ApplicationController < ActionController::Base
      before_filter :check_session_expiry
    
    
      def check_session_expiry
         return true if self.class != UsersController && self.action == "login"
         # do your thing
      end
    
    class ApplicationController < ActionController::Base
      before_filter :check_session_expiry
    
    
      def check_session_expiry
         return true if self.class != UsersController && self.action == "login"
         # do your thing
      end
    

    如何从 Rails 3.07 中的过滤器中排除单个控制器操作?

    更多

    推荐作者

    小瓶盖

    文章 0 评论 0

    wxsp_Ukbq8xGR

    文章 0 评论 0

    1638627670

    文章 0 评论 0

    仅一夜美梦

    文章 0 评论 0

    夜访吸血鬼

    文章 0 评论 0

    近卫軍团

    文章 0 评论 0

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