小编Dat*_*sik的帖子

如何为失去焦点的元素设置转换

我有一个从黑色到深灰色的简单过渡,如下所示:

.navbar .logo:hover {
    -o-transition: 1s;  
    -ms-transition: 1s;
    -moz-tranistion: 1s;
    -webkit-transition: 1s;
    transition: 0.2s;

    color: darkgrey;

}
Run Code Online (Sandbox Code Playgroud)

演示:http://jsfiddle.net/yD46F/10/

但当我停止徘徊时,它立即变回黑色,而不是转变为黑色,我该如何解决这个问题呢?谢谢!

css

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

如何使用Node.js自动编译.coffeescript?

我喜欢在CoffeeScript中编写我的堆栈,我只是想知道如何在运行时使用Node.js自动编译它,所以我不必手动编译我编辑的每个咖啡文件并将.js移动到文件中,这就是我现在所拥有的(只是为了测试);


/routes/index.coffee:
Run Code Online (Sandbox Code Playgroud)
exports.index = (req, res) ->
  res.render "index",
    title: "Express"
Run Code Online (Sandbox Code Playgroud)
app.js:
Run Code Online (Sandbox Code Playgroud)
/**
 * Module dependencies.
 */
require('coffee-script');
var express = require('express')
  , staticp = require('./routes/index')
  , user = require('./routes/user')
  , http = require('http')
  , path = require('path');

var app = express();

// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));

// development only
if ('development' == app.get('env')) {
  app.use(express.errorHandler());
}

app.get('/', staticp.index);
app.get('/users', user.list);

http.createServer(app).listen(app.get('port'), function(){
  console.log('Express …
Run Code Online (Sandbox Code Playgroud)

javascript node.js coffeescript

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

Graphics CopyFromScreen方法如何复制到位图?

private void startBot_Click(object sender, EventArgs e)
{
        Bitmap bmpScreenshot = Screenshot();
        this.BackgroundImage = bmpScreenshot;
}

private Bitmap Screenshot()
{

    // This is where we will store a snapshot of the screen
    Bitmap bmpScreenshot = 
        new Bitmap(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height);

    // Creates a graphic object so we can draw the screen in the bitmap (bmpScreenshot);
    Graphics g = Graphics.FromImage(bmpScreenshot);

    // Copy from screen into the bitmap we created
    g.CopyFromScreen(0, 0, 0, 0, Screen.PrimaryScreen.Bounds.Size);

    // Return the screenshot
    return bmpScreenshot;
}
Run Code Online (Sandbox Code Playgroud)

我最近一直在玩C#,我只是按照一些教程,我只是不明白如果我要擦除Graphics g它不会把图像作为背景,但代码在任何时候都没有指定任何变量之间的关系,除了 …

c#

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

如何使用MongoDB验证输入?

我有一个简单的小用户注册表单,如下所示:

// POST Register new user
exports.new = function(req, res) {
    var db = require('mongojs').connect('localhost/busapp', ['users']);
    db.users.ensureIndex({email:1}, {unique: true})

    function User(email, username, password, dateCreated) {
        this.email = email;
        this.username  = username;
        this.password = password;
        this.dateCreated = new Date();
        this.admin = 0;
        this.activated = 0
    }

    if (req.body.user.password !== req.body.user.passwordc) {
        res.send('Passwords do not match');
    } else {

        var user = new User(req.body.user.email, req.body.user.username, 
                            req.body.user.password);

        // TODO: Remove this after we clarify that it works.

        console.log(user.email + " " + user.username …
Run Code Online (Sandbox Code Playgroud)

javascript mongodb node.js

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

难以理解Objective-C中的指针

所以我明白在ObjC中所有东西都存在于堆中,而且一切都有指向它的指针.我正在阅读O'Reilys的书,我正在抓住大多数事情,但是当我按照教程/示例进行操作时会出现类似的内容

NSMutableArray *bar = [[[foo alloc] init] callMethod];

就在*旁边bar,但是你有类似的东西

- (NSString *)createDeck:(NSString *)numOfCards;

为什么NSString *不是- (NSString)*createDeck:(NSString)*numOfCards;

任何帮助理解事物的概念都会非常感谢.

编辑:

NSUInteger *randomIndex = arc4random() % [deck count]; 错误

由于Where NSUInteger randomIndex = arc4random() % [deck count]; 工作正常,在这种情况下如何移除指针有效?

objective-c

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

Meteor应用程序中Blaze和SpaceBars之间的区别是什么

我一直在潜入Meteor并听说过参考Blaze,我知道SpaceBars是Meteors Templating语言.但Blaze在哪里进来?当我查看他们的GitHub页面时,我看到的模板在我看来就像SpaceBars.

Blaze到SpaceBars和DDP到WebSockets是一样的吗?我糊涂了.谢谢.

meteor

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

为什么我在执行 err == sql.ErrNoRows 时无法使用类型 *sql.Row 作为类型错误

我试图按照此处给出的答案中的示例进行操作: Golang: How to check for empty array (array of struct)

关于如何检查数据库返回是否为空

所以我有这个:

err = db.QueryRow("SELECT FROM accounts WHERE steamid=?", steamid)
switch {
        case err == sql.ErrNoRows:
        case err != nil:
        default:
                //do stuff
}
Run Code Online (Sandbox Code Playgroud)

但我收到错误:

cannot use db.QueryRow("SELECT FROM accounts WHERE steamid=?", steamid) (type *sql.Row) as type error in assignment:
    *sql.Row does not implement error (missing Error method)
Run Code Online (Sandbox Code Playgroud)

不知道为什么它在他的例子中起作用,但在我尝试实现它时不起作用。谢谢。

go

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

如何在函数式编程语言中使用函数而不是早期返回

我最近开始学习Elixir,我真的非常喜欢它,但它是我用过的第一种函数式编程语言.我遇到的问题来自于我一直在阅读教程和在LearnElixir上观看截屏视频,你应该尽量避免使用IF类型语句.

但我发现自己经常筑巢condcase

我会用Golang或Javascript之类的其他语言解决这些解决方案,只需使用带有早期返回的if语句,这样超出该范围的代码就不会运行,这使得我不得不通过检查falsy来占用条件的99%的时间价值观和回归.

因此,在Elixir(或其他函数式编程语言)中,如何在不使用嵌套的情况下以适当的方式编写类似下面的内容,并利用该语言的功能.

def loginPost(conn, %{"user" => user_params}) do
    # Look for user in database
    query = from u in User,
      where: u.email == ^user_params["email"],
      select: [u.email, u.username, u.password]

    data = Repo.all(query)

    # Check to see if a user had been found
    case (length data) == 0 do
      true -> # No user was found, send an error message
        conn
        |> json(%{ success: false, errors: ["Wrong username or …
Run Code Online (Sandbox Code Playgroud)

functional-programming elixir

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

Node 加密包中的 crypto.randomBytes(32) 在 Golang 中的等价物是什么?

大家好,我基本上是在尝试重新创建这个节点包:

https://github.com/seishun/node-steam-crypto/blob/master/index.js

golang这样我就可以进行API调用的API蒸汽需要这些加密的sessionKeys,什么不是。

我正在查看crypto包,但是有很多不同的散列方法可以使用,我不确定哪一个最接近

crypto.randomBytes(32) 在节点包中。

还有

crypto.publicEncrypt()

对不起,如果这个问题是废话,不知道如何表达它,因为我以前没有真正处理过这种东西。任何信息都会非常感谢。

go node.js

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

调用具有相同名称的多定义函数时,函数如何排序

大家好,我正在关注http://learnelixir.tv的截屏视频,这些视频非常棒,这是我的第一个基于函数的编程语言,但我真的很喜欢它。

我目前正在学习列表,我们制作了一个自定义长度函数,如下所示:

defmodule MyList do
    def length(list) do
        length(list, 0)
    end

    defp length([], count) do
        count
    end

    defp length([_|t], count) do
        length(t, count + 1)
    end
end
Run Code Online (Sandbox Code Playgroud)

哪个效果很好

MyList.length([1, 2, 3, 4])
// 4
Run Code Online (Sandbox Code Playgroud)

所以根据我的理解,我们最初传入了对非私有函数的第一次调用,length-private现在调用虚拟机是否正常有 2 个版本,一个接受空数组,一个接受非空数组?

为什么它不直接跳到length([], count)第一个并返回,count // 0而是转到最后一个声明的length函数,

(小题)

count 如何在 2 个私有长度函数之间共享,以及如何[_|t]改变数组并在 2 个函数之间共享它?

elixir

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