小编Rit*_*esh的帖子

如何在Ubuntu中的localhost上安装SSL?

我想在Ubuntu环境中的本地主机上安装SSL证书,因为我不能直接在生产服务器上工作.我必须根据页面是HTTP还是HTTPS在我的代码中加入一些条件.

我怎样才能做到这一点?

ubuntu ssl localhost

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

如何在MAMP中创建虚拟主机?

我是Mac的新手,但是很长一段时间都在使用Ubuntu进行开发.我知道如何在Ubuntu中创建虚拟主机,但不知道Mac.我创建了hosts如下条目:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost mysite.loc
255.255.255.255 broadcasthost
::1             localhost
Run Code Online (Sandbox Code Playgroud)

但接下来该怎么办?

macos mamp virtualhost

19
推荐指数
3
解决办法
3万
查看次数

为什么字符串在PHP 5.3中的行为类似于数组?

我有这个代码:

$tierHosts['host'] = isset($host['name']) ? $host['name'] : $host;
Run Code Online (Sandbox Code Playgroud)

它在PHP 5.5中运行良好,但在PHP 5.3中,条件返回true,同时$host包含类似的字符串pjba01.它返回的第一个字母$tierHosts['host'],即p.

我的代码出了什么问题?

php arrays string php-5.3 php-5.4

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

'IntrinsicAttributes & { children?: ReactNode; 类型不存在属性 }'

我通过Create-React-App以下包(提及与我的问题相关的包)创建了反应项目:

"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.1",
"typescript": "^3.9.2",
"@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^2.33.0"
Run Code Online (Sandbox Code Playgroud)

我创建了一个简单的 HOC(现在什么都不做,但我稍后会添加我的逻辑),如下所示:

type Props = {
    [key: string]: any;
};


const connect = function (Component: FunctionComponent): FunctionComponent {
    const ComponentWrapper = function (props: Props): ReactElement {
        return <Component {...props} />;
    };

    return ComponentWrapper;
};
Run Code Online (Sandbox Code Playgroud)

并像这样导出我的组件:

    const Test: FunctionComponent<Props> = function ({ message }: Props) {
        return (
            <div>{message}</div>
        );
    };


export default connect(Test);
Run Code Online (Sandbox Code Playgroud)

并像这样使用这个组件:

<Test message="Testing message" />
Run Code Online (Sandbox Code Playgroud)

但是在编译器中出错:

Type '{ message: string; …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs create-react-app react-hoc intrinsicattributes

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

如何在jquery中动态更改旋钮值..?

我已经应用了一个具有readonly功能的jquery旋钮,如下所示:

<style>
.test{
    background: #292929;
    margin:50px;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://raw.github.com/aterrien/jQuery-Knob/master/js/jquery.knob.js"></script>
<body>

<input type="text" value="45%" class="dial"><button id="change">Change</button>
</body>
<script>
$(".dial").knob({
    readOnly: true,
    fgColor: "#00ABC6",
    bgColor: "#666666",
    thickness: 0.2
                });

$(document.body).on('click', 'button#change', function(){
    $("input.dial").val('80%');
    })
</script>
Run Code Online (Sandbox Code Playgroud)

现在,当我点击更改按钮时,它只会更改输入标签的值,但无法更改旋钮填充区域的百分比.

html jquery jquery-knob

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

如何在firefox中禁用content_script.js ..?

到目前为止我还没有在我的firefox中安装任何插件,直到现在还没有使用任何额外的js脚本,但我没有从这里content_script.js启用它并在控制台中打印不必要的消息,如下所示:

 content script runtime.onMessage: update_shortcuts
content_script.js (line 91)
<System>

2 content script runtime.onMessage: tabupdate
content_script.js (line 91)
<System>
Run Code Online (Sandbox Code Playgroud)

当我试着查看这个脚本的路径时,它显示了firefox任何插件的一部分:

在此输入图像描述

资源://gre/modules/ExtensionContent.jsm - > moz-extension://22d1d103-e4d1-431c-bc5e-e2fe1cd8d902/javascripts/content_script.js

任何人都可以告诉我这个剧本到底在做什么,我怎么能解除这个......

我在FireFox中使用这些扩展: 在此输入图像描述

任何帮助将不胜感激..!!

javascript firefox

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

如何在不使用ZF2 ..中任何控制器对象的情况下访问module.php中的控制器插件?

我想添加错误处理module.php以在Flash Messenger中添加所有错误消息并重定向到特定页面(根据我的要求):

public function handleError(MvcEvent $e) {
        $exception = $e->getParam('exception');
        $controller = $e->getTarget();
        //echo $exception->getMessage(); exit;
        if (!$e->getApplication()->getServiceManager()->get('AuthService')->hasIdentity()) {
            $controller->flashMessenger()->addErrorMessage("Session Expired..!!");
            return $e->getTarget()->plugin('redirect')->toRoute('auth', array('action' => 'login'));
        }

        switch ($exception->getCode()) {
            case "2003" :
                $controller->flashMessenger()->addErrorMessage("Unable to connect database..!!");
                break;

            default :
                $controller->flashMessenger()->addErrorMessage($exception->getMessage());
                break;
        }

        $e->getApplication()->getServiceManager()->get('AuthService')->clearIdentity();
        return $e->getTarget()->plugin('redirect')->toRoute('auth', array('action' => 'login'));
    }
Run Code Online (Sandbox Code Playgroud)

但是在某些错误中,它会抛出对未定义方法插件的调用,$e->getTarget()因为在某些情况下,错误是在插件绑定之前生成的。我想要一种redirect and flash messenger plugins无需引用任何控制器即可访问的方法。

php zend-controller-plugin zend-framework2

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

记录列表未在 Django REST 框架中获取更新的记录..?

在 Django REST Framework API 中,直到 API 重新启动或 Python 文件(例如模型、序列化程序或视图)中的任何代码更改之前,数据库表记录列表不会更新。我尝试过事务提交,但没有成功。以下是我的看法:

class ServiceViewSet(viewsets.ModelViewSet):
    #authentication_classes = APIAuthentication,
    queryset = Service.objects.all()
    serializer_class = ServiceSerializer
    def get_queryset(self):
        queryset = self.queryset
        parent_id = self.request.QUERY_PARAMS.get('parent_id', None)
        if parent_id is not None:
           queryset = queryset.filter(parent_id=parent_id)
        return queryset   
    # Make Service readable only
    def update(self, request, *args, **kwargs): 
        return Response(status=status.HTTP_400_BAD_REQUEST)    
    def destroy(self, request, *args, **kwargs):
        return Response(status=status.HTTP_400_BAD_REQUEST)
Run Code Online (Sandbox Code Playgroud)

序列化器看起来像这样:

class ServiceSerializer(serializers.ModelSerializer): 

    class Meta:
        model = Service
        fields = ('id', 'category_name', 'parent_id')
        read_only_fields = ('category_name', 'parent_id')
Run Code Online (Sandbox Code Playgroud)

模型如下所示:

class Service(models.Model):
    class …
Run Code Online (Sandbox Code Playgroud)

django python-2.7 django-rest-framework

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

如何在路由参数中发送 URL?

我已经定义了这样的路线:

$app->map(['GET', 'POST'],'/abc/[{url}]', function ($request, $response, $args) {

    return $response;
})->add(new CustomMiddleware());
Run Code Online (Sandbox Code Playgroud)

当我传递一个 url 时它工作正常,http://但给了我一个404 page not found-Page with http://or https://。我也尝试过使用 url 编码的字符串,但给出了同样的错误:

$app->map(['GET', 'POST'],'/abc/[{url}]', function ($request, $response, $args) {

    return $response;
})->add(new CustomMiddleware());
Run Code Online (Sandbox Code Playgroud)

我正在使用 Slim 3.1 版。

php slim slim-3

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