小编Int*_*ist的帖子

jQuery'延迟对象/承诺'性能?

有没有人知道使用新的jQuery'promises/deferred object'模式而不是旧的jQuery样式ajax方法涉及标准的'成功'和'错误'回调所涉及的任何重大性能损失?

我知道向前推进我们现在没有太多选择,因为'延迟'对象现在内置在AJAX核心中,但只是想知道是否存在任何可测量的差异以及新的'promises'设计模式是否实际上比旧的更有效学校匿名函数回调?

亲切的问候,马克

jquery jquery-deferred

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

如何将代码块传递给Stylus中的函数或mixin

我正在从Sass转移到Stylus,我有很多mixins,我传入一个代码块,可以在mixin中访问@content.

例如...

@mixin respond-min($width) {
    // If we're outputting for a fixed media query set...
    @if $fix-mqs {
        // ...and if we should apply these rules...
        @if $fix-mqs >= $width {
            // ...output the content the user gave us.
            @content;
        }
    }
    @else {
        // Otherwise, output it using a regular media query
        @media all and (min-width: $width) {
            @content;
        }
    }
}

@include respond-min($mq-group2) {
    & {
        border: 1px solid green;
    }
}
Run Code Online (Sandbox Code Playgroud)

我想将上面的代码转换成Stylus,但我的主要问题是我如何将代码块传递给mixin,因为Stylus似乎没有这个功能.

有替代解决方案吗?

任何帮助赞赏.

css stylus sass

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

与其他浏览器相比,为什么IE9地理定位支持被破坏?

我正在构建一个地图应用程序,并注意到尽管IE9支持地理定位api,但它错误地计算了纬度/经度.

其他用户也注意到这个http://social.technet.microsoft.com/Forums/en-IE/ieitprocurrentver/thread/aea4db4e-0720-44fe-a9b8-09917e345080,但没有任何谷歌搜索引发开发者博客的任何结果/更多技术读者......我觉得这很奇怪,没有人在IE9中测试他们的地理定位代码!?

这是我的示例代码:https://gist.github.com/1710256

这里有没有人知道为什么会这样,因为它使特征检测地理位置api该死的几乎不可能.另外,我注意到后备(在Paul Irish的polyfill中提供)也有与IE9本机实现中相同的问题吗?

还有其他人在IE9上遇到过地理定位这个问题吗?

任何帮助/建议表示赞赏.

javascript geolocation internet-explorer-9

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

如何在 Mac OSX 上使用 Zsh shell 和 `sed` 命令重命名文件

我的桌面上有一个名为“Images”的文件夹,该文件夹内有 3 个图像...

File-A-B.gif
File-C-D.gif
File-E-F.gif
Run Code Online (Sandbox Code Playgroud)

...我想重命名命令行上的文件,以便删除第二个连字符/破折号。所以结果将是像这样命名的文件......

File-AB.gif
File-CD.gif
File-EF.gif
Run Code Online (Sandbox Code Playgroud)

...我正在使用相互传递的命令组合,但在让它们工作方面运气不佳。

最初我有 ls File-* | sed 's/\(File-[^-]\)-\(.+\)/mv & \1\2/' | sh

这个命令的分解是...

  • 列出所有开始的文件 File-
  • 将结果通过管道传输到 sed
  • 我们将用于sed捕获名称的不同部分
  • 查看我们将捕获的第一个文件File-AB.gif
  • sed我们然后用移动命令替换匹配的文件名,并有效地告诉它的原始文件重命名为数据的两片,我们已经捕获的由一个文件
  • 然后我们将该命令通过管道传输到 sh

我得到的最初错误是权限错误。我不知道为什么,因为我有对文件的“读写”访问权限。

为了解决这个问题,我chmod 777每个文件。

这导致了一个新的错误,即cannot execute binary file.

为了解决这个错误,我看到了这篇文章:http : //blog.mpdaugherty.com/2010/05/27/difference-with-sed-in-place-editing-on-mac-os-x-vs-linux/这建议添加一对额外的单引号。这样做的原因(显然)是因为sed会出错,因为它不知道要使用什么文件扩展名,但是放置一个空字符串可以消除该错误(附带说明:我的理解是您还需要使用-i标志 - 其中我没有使用 - 但这样做会导致一个不同的错误,所以我取消了它并只使用单引号来避免我得到的二进制文件错误)。

所以现在我有 ls File-* | sed '' 's/\(File-[^-]\)-\(.+\)/mv & \1\2/' | sh

但是这个错误与No such file or directory? …

macos shell zsh sed

4
推荐指数
2
解决办法
5273
查看次数

Ubuntu Zsh(通过 Vagrant)未定位 Zsh 或其功能

我有一个 Vagrant 配置脚本,如果 Zsh 不可用,它会尝试安装 Zsh,然后更改 shell 以使用 Zsh。

我认为我遇到了两个问题:

第一个是我不相信 shell 会更改为 Zsh,因为当我运行vagrant ssh以访问 Ubuntu VM 并且一旦运行ps -p $$命令表明 Bash 是正在运行的 shell(我期望 Zsh 的位置)。

第二个问题是,如果它正在更改为 Zsh shell(无论ps -p $$返回什么报告),那么当我获取 .zshrc 文件时,Zsh 会显示很多错误,这表明指定的函数丢失或只是没有被正确引用。


我将通过手动安装 Zsh 而不是通过 Vagrant 配置脚本将其分解为多个步骤......

  1. cat /etc/shells -> 我看到没有提到 Zsh†
  2. sudo apt-get update
  3. sudo apt-get install zsh?
  4. cat /etc/shells-> 现在/bin/zsh/usr/bin/zsh
  5. which zsh -> /usr/bin/zsh
  6. zsh --version -> zsh 5.0.2 (x86_64-pc-linux-gnu)
  7. chsh -s $(which zsh) …

linux bash shell ubuntu zsh

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

Ruby`require`调用在自定义代码上失败

我发现使用require像Sinatra Web框架这样的东西我没有问题,但我似乎无法使用require加载我自己的自定义代码?

例如,我有两个文件:

  1. test1.rb
  2. test2.rb

'test1.rb'的内容是:

#!/usr/bin/env ruby
require 'test2'
Run Code Online (Sandbox Code Playgroud)

'test2.rb'的内容是:

class String
    def vowels
        self.scan(/[aeiou]/i)
    end
end
Run Code Online (Sandbox Code Playgroud)

如果我尝试运行ruby test1.rb然后我得到以下错误...

/Users/<username>/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- test2 (LoadError)
    from /Users/<username>/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from test1.rb:3:in `<main>'
Run Code Online (Sandbox Code Playgroud)

然后我注意到如果我尝试使用shotgungem加载Web服务器,那么我得到一个不同但更详细的错误堆栈跟踪...

Boot Error
Something went wrong while loading test1.rb
LoadError: cannot load such file -- test2

/Users/<username>/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/<username>/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/<username>/Dropbox/Library/Ruby/Passage/test1.rb:3:in `<top (required)>'
/Users/<username>/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/<username>/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/shotgun-0.9/lib/shotgun/loader.rb:114:in `inner_app'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/shotgun-0.9/lib/shotgun/loader.rb:102:in `assemble_app'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/shotgun-0.9/lib/shotgun/loader.rb:86:in `proceed_as_child'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/shotgun-0.9/lib/shotgun/loader.rb:31:in `call!'
/Users/<username>/.rvm/gems/ruby-1.9.3-p125/gems/shotgun-0.9/lib/shotgun/loader.rb:18:in `call' …
Run Code Online (Sandbox Code Playgroud)

ruby

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

如何将这个CSS3动画转换为Sass mixin?

我有以下动画代码......

.a {
    background: url(../Images/experience-1.jpg) center center no-repeat red;
    z-index: 7;

    -webkit-animation-delay: 3s;
    -webkit-animation-duration: 5s;
    -webkit-animation-name: fadeout;
    -webkit-animation-fill-mode: forwards; /* this prevents the animation from restarting! */

    -moz-animation-delay: 3s;
    -moz-animation-duration: 5s;
    -moz-animation-name: fadeout;
    -moz-animation-fill-mode: forwards; /* this prevents the animation from restarting! */

    -o-animation-delay: 3s;
    -o-animation-duration: 5s;
    -o-animation-name: fadeout;
    -o-animation-fill-mode: forwards; /* this prevents the animation from restarting! */

    animation-delay: 3s;
    animation-duration: 5s;
    animation-name: fadeout;
    animation-fill-mode: forwards; /* this prevents the animation from restarting! */
}

.b {
    background: url(../Images/experience-2.jpg) …
Run Code Online (Sandbox Code Playgroud)

sass css3

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

打开 Vim 时 tmux 配色方案发生变化?

我有一个问题,打开 Vim 后我的 tmux 状态栏颜色方案会发生变化,但我不希望这样。

我的 tmux 状态栏配色方案本身就可以正常工作。请参阅下图的示例:

...请注意状态栏的白色栏和蓝色/黑色/红色部分,这一切都符合预期,您可以在此处查看相关设置:https: //github.com/Integralist/Fresh-Install /blob/master/Shell/.tmux.conf#L78-L86

当我在 tmux 中打开 Vim 时,状态栏配色方案被 Vim 的配色方案(明晚)覆盖。请参阅下图的示例:

当我关闭 Vim 时,tmux 状态栏颜色方案保持不变。请参阅下图的示例:

再说一次,即使没有办法阻止 Vim 在 Vim 打开时覆盖 tmux 状态栏配色方案,我还是希望有一种方法可以在 Vim 关闭时将 tmux 状态栏配色方案更改回正常状态。

我尝试检查 $TERM 环境变量,它似乎始终设置为screen-256color. 例如...

  • echo $TERM(仅限 tmux)==screen-256color
  • echo $TERM(仅限 Vim)==screen-256color
  • echo $TERM(tmux 中的 Vim)==screen-256color
  • echo $TERM(仅限 tmux,但在打开 Vim 后)==screen-256color

我的.zshrc文件具有以下设置:export TERM="screen-256color"您可以在此处查看完整文件: https: //github.com/Integralist/Fresh-Install/blob/master/Shell/.zshrc

我的.vimrc文件具有以下设置:set background=lightcolorscheme Tomorrow-Night可以在此处查看完整文件: https: …

vim color-scheme tmux

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