小编T. *_*one的帖子

Perl的流行当代用途是什么?

Perl的流行当代用途是什么?

编辑

我应该更具体一点.我想知道更多关于大规模(流行)的人使用Perl的,而不是什么东西可以被用于在个人层面.

perl popularity

7
推荐指数
9
解决办法
1878
查看次数

Git可以通过互联网推送/拉动分布式回购吗?

我知道Git可以在没有中央存储库的情况下使用.但是,我和其他几个人一起开始了一个项目,我们在地理上分布.即我们永远不会在同一个局域网上同步回购.

所以我的问题是:是否有可能通过互联网推送/拉动每个其他回购的变化?如果是这样,我该怎么做呢?最轻松,最简单的方式.

Thanx提前.

git

6
推荐指数
2
解决办法
2058
查看次数

使用CompileAssemblyFromSource加载自定义程序集

我不太清楚该怎么做.总体目标是能够获取用户脚本,并在.NET环境中执行它.我已经编写了大部分代码并且工作正常,我不会尝试加载自己的程序集.但是,为了安全地让用户访问系统的内部部分,已经创建了代理DLL.这就是问题所在.

现在这个代理DLL有一个东西,一个接口.

CompilerParameters options = new CompilerParameters();
options.GenerateExecutable = false;
options.GenerateInMemory = true;
options.ReferencedAssemblies.Add("System.dll");
options.ReferencedAssemblies.Add("ScriptProxy.dll");

Microsoft.CSharp.CSharpCodeProvider provider = new Microsoft.CSharp.CSharpCodeProvider();
CompilerResults result = provider.CompileAssemblyFromSource(options, script);

// This line here throws the error:
return result.CompiledAssembly;
Run Code Online (Sandbox Code Playgroud)

运行上面的代码,它会抛出以下错误:

System.IO.FileNotFoundException:无法加载文件或程序集'file:/// C:\ Users ...\AppData\Local\Temp\scts5w5o.dll'或其依赖项之一.该系统找不到指定的文件.

当然我的第一个想法是,"......什么是scts5w5o.dll?"

这是ScriptProxy.dll不正确加载,还是ScriptProxy.dll本身试图加载依赖项,这些依赖项在某个临时文件中?或者它是完全不同的东西?

我应该提一下,我正在从NUnit测试运行器执行此代码.我不确定这是否有所作为.

c#

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

如何在SVG中居中90º旋转文本

使用D3,我希望Y轴标签旋转-90º并以Y轴为中心.我认为这将是一块蛋糕,并写了以下内容:

// Y Axis Label
svg.append('svg:text')
    .attr('class', 'y label')
    .attr('text-anchor', 'middle')
    .attr('y', 0)
    .attr('width', height)
    .attr('transform', 'translate(-' + yAxisSpacing + ',' + height + ') rotate(-90)')
    .text('Y Axis Label')
Run Code Online (Sandbox Code Playgroud)

height在这种情况下是图表的高度(svg占用的垂直区域).上面的代码将<text>在图表的左下角呈现一个元素,然后将文本相对于该左下角点居中.该width变化,因此,而不是为中心的它使用的是SVG的左下角.

我猜想如果它width等于height图表的那个,那么它里面的文本就会垂直居中.这似乎并没有这样的情况-或-有一些神奇的display:block类型属性,我需要在SVG设置,以便width于上工作<text>元素.

该怎么做?


基于回复,我使用了javascript路由并将上面的行修改为(height/2)...

.attr('transform', 'translate(-' + yAxisSpacing + ',' + height / 2 + ') rotate(-90)')
Run Code Online (Sandbox Code Playgroud)

svg d3.js

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

Django模板:列表"for"标签内的嵌套字典"for"标签

我希望能够在Django模板中的for循环内迭代字典.

为了这个示例,请考虑以下事项:

items_list = [ {'key1':'value1', 'key2':'value2'}, {'key1':'value5', 'key2':'value9'} ]
Run Code Online (Sandbox Code Playgroud)

方法#1:

{% for dict in items_list %}
    {% for key,value in dict %}
        <tr>
            <td>{{ key }}</td>
            <td>{{ value }}</td>
        </tr>
    {% endfor %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

方法#2:

{% for dict in items_list %}
    {% for node in dict.items %}
        <tr>
            <td>{{ node.0 }}</td>
            <td>{{ node.1 }}</td>
        </tr>
    {% endfor %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

问题

  • 方法#1为什么不起作用?这对我来说似乎很直观.
  • 我在方法#2中这样做的方式是好还是以后会引起问题?

django django-templates

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

在Django中同步devel/live数据库之间的数据

有了Django在开发版中的新的多数据库功能,我一直在尝试创建一个管理命令,让我将实时站点的数据同步到开发人员机器以进行扩展测试.(拥有实际数据,特别是用户输入的数据,可以让我测试更广泛的输入.)

现在我有一个"大部分"工作命令.它可以同步"简单"的模型数据,但我遇到的问题是它忽略了ManyToMany字段,我认为没有任何理由这样做.任何人都有任何想法如何解决或更好的想要处理这个?我应该首先将第一个查询导出到夹具然后重新导入吗?

from django.core.management.base import LabelCommand
from django.db.utils import IntegrityError
from django.db import models
from django.conf import settings

LIVE_DATABASE_KEY = 'live'

class Command(LabelCommand):
    help = ("Synchronizes the data between the local machine and the live server")
    args = "APP_NAME"
    label = 'application name'

    requires_model_validation = False
    can_import_settings = True

    def handle_label(self, label, **options):

        # Make sure we're running the command on a developer machine and that we've got the right settings
        db_settings = getattr(settings, 'DATABASES', {})
        if not …
Run Code Online (Sandbox Code Playgroud)

django django-orm

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

在jQuery中创建一个逃跑按钮

我想用一个简单的按钮来创建一个页面,当他试图点击它时,它会远离用户.我们称之为Run away按钮?

是否有一个简单的'jQuery'代码段允许我这样做?

此致,Karan Misra

jquery

5
推荐指数
2
解决办法
3890
查看次数

了解python导入

在学习Django和Python的过程中.我无法理解这一点.

(示例注释:'helloworld'是我项目的名称.它有一个名为'app'的应用程序.)

from helloworld.views import *          # <<-- this works
from helloworld import views            # <<-- this doesn't work
from helloworld.app import views        # <<-- but this works.  why?
Run Code Online (Sandbox Code Playgroud)

似乎第2行和第3行实际上是相同的.为什么#2不起作用?

编辑 - 添加了两个文件的来源. 您可能会从Django Book项目中识别此代码(http://www.djangobook.com/en/2.0)

的HelloWorld/views.py

from django.shortcuts import render_to_response
from django.http import HttpResponse, Http404
import datetime

def hello(request):
    return HttpResponse("Hello world")


def current_datetime(request):
    current_date = datetime.datetime.now()
    return render_to_response('current_datetime.html', locals())


def offset_datetime(request, offset):
    try:
        offset = int(offset)
    except ValueError:
        raise Http404()

    next_time = datetime.datetime.now() + datetime.timedelta(hours=offset)
    return render_to_response('offset_datetime.html', …
Run Code Online (Sandbox Code Playgroud)

python django import

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

django manage.py syncdb无法正常工作?

试图学习Django,我关闭了shell,当我调用python manage.py syncdb时,我现在遇到了这个问题,任何想法发生了什么?:

我已经建立了一个数据库.我在文件夹django_bookmarks中设置了manage.py.什么在这里?

Traceback (most recent call last):
  File "manage.py", line 2, in <module>
    from django.core.management import execute_manager
ImportError: No module named django.core.management
my-computer:~/Django-1.1.1/django_bookmarks mycomp$ export PATH=/Users/mycomp/bin:$PATH
my-computer:~/Django-1.1.1/django_bookmarks mycomp$ python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 2, in <module>
    from django.core.management import execute_manager
ImportError: No module named django.core.management
my-computer:~/Django-1.1.1/django_bookmarks mycomp$ 
Run Code Online (Sandbox Code Playgroud)

django django-syncdb manage.py

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

以编程方式设置CKEditor对话框的位置

我正在尝试找到一种方法,以便在打开新对话框时以编程方式设置CKEditor对话框的位置.位置部分的实际设置似乎很容易,但我似乎无法弄清楚如何捕获正在创建和显示的新CKEditor对话框的事件.

我假设它将是......

CKEDITOR.on('dialogCreated', function(e) { ... } );
Run Code Online (Sandbox Code Playgroud)

但似乎无法在文档中找到它.

ckeditor

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