小编Pap*_*nho的帖子

在您的服务器上未正确配置Cakephp 2.x URL重写

我想我们大多数人都遇到麻烦.htaccess我想知道是否有人可以帮助我.Opensuse 12.3:代码:

Linux linux-hyo0.site 3.7.10-1.16-desktop #1 SMP PREEMPT Fri May 31 20:21:23 UTC 2013 (97c14ba) x86_64 x86_64 x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)

我喜欢在我的机器上安装Cakephp,但我的网页上有一个错误,上面写着"代码: 你的服务器上没有正确配置URL重写 ".

我的/ etc/sysconfig/apache2文件如下:代码:

APACHE_MODULES="authz_host actions alias auth_basic authz_groupfile authn_file authz_user autoindex cgi dir include log_config mime negotiation setenvif status userdir asis imagemap php5 reqtimeout authz_default rewrite"
Run Code Online (Sandbox Code Playgroud)

并将/etc/apache2/sysconfig.d/loadmodule.conf作为最后一行代码:

LoadModule rewrite_module                 /usr/lib64/apache2/mod_rewrite.so
Run Code Online (Sandbox Code Playgroud)

我也改变了我的文件etc/apache2/defaul-server.conf

<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>
<Directory "/srv/www/htdocs">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride ALL
    Order Allow,Deny
    Allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)

有帮助吗?

在app/webroot上

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond …
Run Code Online (Sandbox Code Playgroud)

.htaccess mod-rewrite cakephp

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

如何使用pdb的post_mortem方法?

我试图了解如何使用pdb .post_mortem() 方法。

对于这个给定的文件

# expdb.py
import pdb
import trace

def hello():
  a = 6 * 9
  b = 7 ** 2
  c = a * b
  d = 4 / 0
  print(c)

tracer = trace.Trace()
Run Code Online (Sandbox Code Playgroud)

命令提示符

'''
# first Try

? python -i expdb.py
>>> pdb.post_mortem()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Anaconda3\lib\pdb.py", line 1590, in post_mortem
    raise ValueError("A valid traceback must be passed if no "
ValueError: A valid traceback …
Run Code Online (Sandbox Code Playgroud)

python pdb

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

在Ruby中读取一个json文件

这是我工作场所的一棵树。尝试读取我的resume.json文件时出现错误。

.
??? lib
?   ??? resume.json
?   ??? resume.rb
??? spec
    ??? resume_spec.rb
    ??? spec_helper.rb
Run Code Online (Sandbox Code Playgroud)

此文件(resume.rb)在此调用(ruby resume.rb)上运行良好

文件resume.rb

require "json"

class Resume
  attr_accessor :name, :tel, :email, :experience, :education, :company

  def initialize
    file = File.read("resume.json")
    data = JSON.parse(file)
    @name = data.first.last
  end

end

resume = Resume.new
puts resume.name.size
Run Code Online (Sandbox Code Playgroud)

但是当我运行规范时,出现此错误

.../resume.rb:7:in `read': No such file or directory @ rb_sysopen - resume.json (Errno::ENOENT)
Run Code Online (Sandbox Code Playgroud)

文件resume_spec.rb

require "spec_helper"
require_relative "../lib/resume"


describe Resume do 

  before :each do
    @resume = Resume.new 
  end

  it "#Resume" …
Run Code Online (Sandbox Code Playgroud)

ruby rspec

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

如何从JSON文件中删除反斜杠

我想创建一个像这样的json文件:

{"946705035":4,"946706692":4 ...}
Run Code Online (Sandbox Code Playgroud)

我正在使用仅包含Unix时间戳的列并将它们分组.

result = data['Last_Modified_Date_unixtimestamp_no_time'].value_counts()

In [21]: result.head()
Out[21]: 
1508284800    131
1508716800    106
1508371200    101
1508457600     99
1508630400     96
Name: Last_Modified_Date_unixtimestamp_no_time, dtype: int64
Run Code Online (Sandbox Code Playgroud)

变成一个字典

result = result.to_dict()
result
'''
{1507161600: 1,
 1507852800: 1,
 1508198400: 64,
 1508284800: 131,
 ...
 1535155200: 1,
 1535241600: 1}
'''

import json
result = json.dumps(result)

with open('result.json', 'w') as fp:
    json.dump(result, fp, indent=4)
Run Code Online (Sandbox Code Playgroud)

结果 在此输入图像描述 这是我期望的数据结构

{"946705035":4,"946706692":4}
Run Code Online (Sandbox Code Playgroud)

python json python-3.x

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

如何在 Django 的表单中添加 GenericRelation 字段

我有以下错误:

django.core.exceptions.FieldError: 'pictures' cannot be specified for Building model form as it is a non-editable field
Run Code Online (Sandbox Code Playgroud)

我有很多模型可以有很多图像。所以我使用了 django 的 GenericRelation。但只要我添加了“照片在”字段forms.py。我收到一个错误

表格.py

class BuildingForm(ModelForm):
    class Meta:
        model = Building
        fields = ['landlord', 'address', 'pictures']
Run Code Online (Sandbox Code Playgroud)

模型.py

from stdimage.models import StdImageField

class Image(TimeStampedModel, models.Model):
    picture = StdImageField(upload_to='pictures/%Y/%m/%d',
                            verbose_name="pics", null = True, blank = True, variations={
        'large': (600, 400),
        'thumbnail': (250, 250, True),
        'medium': (300, 200),
    }, default='default.jpg')
    # Generic Foreign Key
    content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
    object_id = models.PositiveIntegerField()
    content_object …
Run Code Online (Sandbox Code Playgroud)

python django django-1.10

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

howler.js在特定位置播放声音

嗨,我想开始在一个奇妙的位置播放声音.api说我可以使用.pos但它不会从我希望它开始的地方开始

  <p>This sound last 13 sec.</p>
  <h1>Audio</h1>
  <h3><a href="#" class="val2">2:00</a></h3>
  <h3><a href="#" class="val3">3:00</a></h3>
  <h3><a href="#" class="val4">4:00</a></h3>
  <h3><a href="#" class="val20">10:00</a></h3>
Run Code Online (Sandbox Code Playgroud)

我的javascript.

var son = [false, "0000"]

sound = new Howl({
    urls: ['http://goldfirestudios.com/proj/howlerjs/sound.mp3'],
    autoplay: false
    });

function playSequence(events,valeur){

  //if there is no sound play the track at a certain position
  var playSound = function(valeur){
    if(son[0] == true){
      sound.stop();
      son[0] = false;
    }else{
      son[0] = true;
      sound.pos = parseInt(valeur[0]); // position at 2 sec
      sound.play();
    }
  }
   playSound(valeur);
}

//play the sound on …
Run Code Online (Sandbox Code Playgroud)

javascript howler.js

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