小编Big*_*ger的帖子

Django Rest Framework - 缺少静态目录

我最近在Ubuntu 14.04上启动了一个带有预安装Django映像的Digital Ocean服务器.我想创建一个API,并决定使用Django Rest Framework.我根据http://www.django-rest-framework.org/完全安装了Django Rest Framework .

以下是我在服务器上访问教程网站时的样子.

在此输入图像描述

如您所见,它看起来不像其他框架教程网站上的网站.这是因为当我查看我的网站的源代码时,所有/static/rest_framework/*文件都给出了404错误.

这是Django'django_project根目录下的settings.py文件.

"""
Django settings for django_project project.

For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = …
Run Code Online (Sandbox Code Playgroud)

python django django-rest-framework

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

布拉德利自适应阈值算法

我目前正致力于实现一个名为的阈值算法Bradley Adaptive Thresholding.

我一直在主要关注两个链接,以便弄清楚如何实现这个算法.我也成功地实现了另外两种阈值算法,主要是Otsu的方法平衡直方图阈值处理.

以下是我为了创建Bradley Adaptive Thresholding算法而遵循的两个链接.

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.420.7883&rep=rep1&type=pdf

Bradley自适应阈值Github示例

以下是Python我运行算法并保存图像的源代码部分.我使用Python Imaging Library而不是其他工具来完成我想要做的事情.

def get_bradley_binary(inp_im):
    w, h = inp_im.size
    s, t = (w / 8, 0.15)

    int_im = Image.new('L', (w, h))
    out_im = Image.new('L', (w, h))

    for i in range(w):
        summ = 0
        for j in range(h):
            index = j * w + i

            summ += get_pixel_offs(inp_im, index)

            if i == 0:
                set_pixel_offs(int_im, index, summ)
            else:
                temp = get_pixel_offs(int_im, …
Run Code Online (Sandbox Code Playgroud)

python python-imaging-library adaptive-threshold

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

Firefox WebExtension - 如何获取和修改跨域iframe的内容

我想知道如何在Firefox WebExtension中访问和修改JavaScript中跨域iframe的内容.我理解普通JavaScript的局限性,修改跨域iframe会是一个XSS漏洞,但我相信在WebExtension中有一些我无法找到的方法.我相信这是因为旧版扩展清单具有允许权限部分中的跨域内容的选项.

查看旧版FireFox扩展的旧代码时,似乎有以下方式为某些网站提供跨域内容选项.虽然对于新的FireFox WebExtension,但这不是文档中列出的功能.

"cross-domain-content": ["https://www.example.com"]
Run Code Online (Sandbox Code Playgroud)

这是我的manifest.json档案.

{
  "manifest_version": 2,
  "name": "Test Extension",
  "version": "1.0",
  "content_scripts": [
    {
      "matches": ["*://*/*"],
      "all_frames": true,
      "js": [
        "js/main.js"
      ]
    }
  ],
  "permissions": [
    "*://*/*",
    "<all_urls>",
  ]
}
Run Code Online (Sandbox Code Playgroud)

这是我的main.js档案.

// Code is being run within an iframe ("all_frames": true)
if (window != window.top) {
  // Attempt to log the source of the parent iframe
  // If cross domain, met throws - Error: Permission denied to access property "frameElement"
  console.log(window.parent.frameElement.src);
} …
Run Code Online (Sandbox Code Playgroud)

javascript iframe firefox jquery firefox-addon-webextensions

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

编译C文件时不支持的x86-64指令集错误

我正在尝试按照链接中的教程.

当我开始编写test.c文件的部分时,我尝试运行第一个编译行.

gcc -c -g -Os -march=i686 -ffreestanding -Wall -Werror test.c -o test.o
Run Code Online (Sandbox Code Playgroud)

这是内容 test.c

__asm__(".code16\n");
__asm__("jmpl $0x0000, $main\n");

void main() {
}
Run Code Online (Sandbox Code Playgroud)

当我调用第一个编译行时,它会显示我的错误.

test.c:1:0: error: CPU you selected does not support x86-64 instruction set
 __asm__(".code16\n");
 ^
Run Code Online (Sandbox Code Playgroud)

谁能告诉我为什么会这样?如果可能的话,如何修复它?

我正在运行Ubuntu Desktop x64,请提前感谢您的帮助.

编辑:

我已将第一个编译行更改为:

gcc -c -g -Os -m32 -ffreestanding -Wall -Werror test.c -o test.o
Run Code Online (Sandbox Code Playgroud)

它似乎工作正常.但是,还有两条线路给我带来了麻烦.

ld -static -Ttest.ld -nostdlib --nmagic -o test.elf test.o
Run Code Online (Sandbox Code Playgroud)

objcopy -O binary test.elf test.bin
Run Code Online (Sandbox Code Playgroud)

第一个抛出了我的错误.

ld: i386 architecture of input file `test.o' is …
Run Code Online (Sandbox Code Playgroud)

c assembly gcc

8
推荐指数
2
解决办法
9019
查看次数

C++ - 使用g ++创建Makefile

我为我的CMSC 202课程项目'Blackjack'制作了一个Makefile.它做我需要的一切,它完美地运作.你可能会问我为什么发布在这里,这是因为我不知道它是如何工作的,我没有使用任何其他资源,而是我自己创建它.

这是我的Makefile代码.

# Object files to either reference or create                          
OBJECTS = Proj2.o Blackjack.o Deck.o Card.o Hand.o Player.o           
# The executable file that will be created at the end                 
EXEC = Proj2.out                                                      
# The flags to use for compilation                                    
FLAGS = -Wall                                                         
# The code compiler to use for compilation                            
CC = g++                                                              

# Perform action on all object files (May or may not exist)           
all: $(OBJECTS)                                                       
        $(CC) $(FLAGS) -o $(EXEC) $(OBJECTS)
Run Code Online (Sandbox Code Playgroud)

这是我make在终端呼叫时的终端输出.

g++    -c -o Proj2.o …
Run Code Online (Sandbox Code Playgroud)

c++ makefile g++

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

Bootstrap Validator - 实际上没有进行验证

我一直在研究Bootstrap验证器,我已经复制并格式化了它们的示例,并包含了所有必需的Bootstrap和Bootstrap验证器和jQuery代码,但是示例并没有像它暗示的那样工作.

这是我的代码.

<!DOCTYPE  html>
<html>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"/> <!-- Bootstrap 3 -->
<link rel="stylesheet" href="bootstrap_validator/css/bootstrapValidator.css"/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script> <!-- Bootstrap 3 -->
<script type="text/javascript" src="bootstrap_validator/js/bootstrapValidator.js"></script>

<form id="registerform" class="form-horizontal">
    <div class="form-group">
        <label class="col-lg-2 control-label">Account</label>
        <div class="col-lg-4">
            <input type="text" class="form-control" name="username" placeholder="Username" />
        </div>
        <div class="col-lg-4">
            <input type="text" class="form-control" name="email" placeholder="Email address" />
        </div>
    </div>
</form>

<script type="text/javascript">
    $(document).ready(function() {
    $('#registerform').bootstrapValidator({
        live: 'enabled',
        message: 'This value is not valid',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon …
Run Code Online (Sandbox Code Playgroud)

jquery twitter-bootstrap-3 jqbootstrapvalidation

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