小编Lew*_*wis的帖子

如何使原子更像WebStorm IDE?

所以我喜欢WebStorm,它可以在放入"."后做出惊人的自动完成功能.我喜欢所有的代码完成和linting.Webstorm资源非常庞大且非常难看.有了原子,我无法弄清楚如何做到这一点.我可以安装或自定义哪些插件以使其适合我的喜好?

atom-editor

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

使用 React Router 在 Django 中排除某些路由?

我目前正在构建一个带有 Django REST 后端的 React。我遇到了一个我无法解决的与路由有关的小问题。

这是我的urls.py文件。

urlpatterns = [
    url(r'^api/', include(router.urls)),
    url(r'^admin/', admin.site.urls),
    url(r'^djangojs/', include('djangojs.urls')),
    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
    url(r'^$', TemplateView.as_view(template_name='exampleapp/itworks.html')),
    url(r'^(?:.*)/?$', TemplateView.as_view(template_name='exampleapp/itworks.html')),
]
Run Code Online (Sandbox Code Playgroud)

使用这个,它让反应路由器在前端做它的事情。例如,如果我想去,127.0.0.1:8000/mentors它将带我到我为 React Router 设置的页面。

但是,因此在前端进行 API 调用也会返回反应页面而不是 API 端点。因此,每当我删除上面代码中的最后一行时:url(r'^(?:.*)/?$', TemplateView.as_view(template_name='exampleapp/itworks.html')),,它就会成功获取以 JSON 格式返回的 API。现在的问题是,当我尝试转到链接时,它将返回 Django 404 页面,而不是我在 React Router 中设置的 React 页面。

无论如何,我可以两全其美吗?

python django reactjs react-router

7
推荐指数
0
解决办法
397
查看次数

IntegrityError:使用praw在Python中的数据类型不匹配

我正在尝试编写一个reddit机器人,它接受"fuck"这个词,看看有多少人在reddit上说这个.这是代码:

import praw
import time
import re
import sqlite3

username = "LewisTheRobot"
password = "lewismenelaws"

conn = sqlite3.connect('reddit')
c = conn.cursor()
r = praw.Reddit(user_agent = "Reddit bot")

word_to_match = [r'\bfuck\b', r'\bfucking\b', r'\bfucks\b']

storage = []

r.login(username, password)

def run_bot():
    subreddit = r.get_subreddit("all")
    print("Grabbing subreddit!")
    comments = subreddit.get_comments(limit=200)
    print("Grabbing comments!")
    for comment in comments:
        comment_text = comment.body.lower()
        isMatch = any(re.search(string, comment_text) for string in word_to_match)
        if comment.id not in storage and isMatch and comment.author not in storage:
            print("We have found a …
Run Code Online (Sandbox Code Playgroud)

python sqlite praw

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

未捕获的类型错误:无法读取未定义的 Google 地图的属性“应用”

我正在使用谷歌地图在地图上制作标记,我正在尝试使用以下代码将地址转换为地理编码:

<script src="https://maps.googleapis.com/maps/api/js?key=&callback=initialize" async defer></script>

<script type="text/javascript">
var map;

 function initialize() {
   var chamberLocation = {lat: 43, lng: -82};
   var geocoder = new google.maps.Geocoder();
   map = new google.maps.Map(document.getElementById('map'), {
     center: {lat: 42.9745, lng: -82.4066},
     zoom: 14,
     styles: [{"featureType":"road","elementType":"geometry","stylers":[{"visibility":"simplified"}]},{"featureType":"road.arterial","stylers":[{"hue":149},{"saturation":-78},{"lightness":0}]},{"featureType":"road.highway","stylers":[{"hue":-31},{"saturation":-40},{"lightness":2.8}]},{"featureType":"poi","elementType":"label","stylers":[{"visibility":"off"}]},{"featureType":"landscape","stylers":[{"hue":163},{"saturation":-26},{"lightness":-1.1}]},{"featureType":"transit","stylers":[{"visibility":"off"}]},{"featureType":"water","stylers":[{"hue":3},{"saturation":-24.24},{"lightness":-38.57}]}],
     zoomControl: false,
     scaleControl: false,
     mapTypeControl: false,
     disableDefaultUI: false,
     streetViewControl: false,
     rotateControl: false,
     scrollwheel: false,
     draggable: false
   });
   codeAddress(geocoder, map);

   }

   function codeAddress(geocoder, map) {
       var address = 'place';
       geocoder.geocode({ 'address' : address }), function(results, status) {
           if (status == google.maps.GeocoderStatus.OK) {
               var …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps

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

无法为拆分''生成资源表

我正在尝试创建一个Android应用程序.目前它不会运行,它会给我2个错误.

在此输入图像描述

我不确定如何让第一个错误消失以及第二个错误消失.当我检查控制台时,这就是我得到的.

[2015-01-29 16:16:48 - TipCalculator] Failed to generate resource table for split ''
[2015-01-29 16:16:48 - TipCalculator] /Users/lewismenelaws/Documents/workspace/TipCalculator/res/values/dimens.xml:7: error: Error: String types not allowed (at 'textview_margin8dp' with value 'textview_margin 8dp').
[2015-01-29 16:16:48 - TipCalculator] 
[2015-01-29 16:17:04 - TipCalculator] Failed to generate resource table for split ''
[2015-01-29 16:17:04 - TipCalculator] /Users/lewismenelaws/Documents/workspace/TipCalculator/res/values/dimens.xml:7: error: Error: String types not allowed (at 'textview_margin8dp' with value 'textview_margin 8dp').
[2015-01-29 16:17:04 - TipCalculator] 
[2015-01-29 16:18:05 - TipCalculator] Failed to generate resource table for split '' …
Run Code Online (Sandbox Code Playgroud)

android

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

Gatsby GraphQL 错误:变量“$slug”从未用于操作“BlogPostQuery”

我无法使用 Gatsby 提取我的 Ghost 博客的数据。我使用 Ghost 作为我的后端,我使用一个包来获取 Ghost 博客作为源。问题只是获取页面上的单个帖子。这是blog-post.js

import React from "react";

export default ({ data }) => {
//   const post = data.allGhostPost.edges;
  return (
    <div>
      {/* <h1>{post.title}</h1> */}
      {/* <div dangerouslySetInnerHTML={{ __html: post.html }} /> */}
    </div>
  );
};

export const query = graphql`
  query BlogPostQuery($slug: String!) {
    allGhostPost {
        edges {
          node {
            id
            slug
            title
            html
            published_at
          }
        }
      }
  }
`;
Run Code Online (Sandbox Code Playgroud)

这是我的 gatsby 节点文件:

exports.createPages = ({ graphql, boundActionCreators}) => {
    const …
Run Code Online (Sandbox Code Playgroud)

reactjs graphql gatsby

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

Meteor教程之后如何继续前进?

所以我刚刚在https://www.meteor.com/install上完成了待办事项申请的教程.我在网上找不到任何可以做任何教程的地方,以进一步推动我对流星的了解.是否有任何教程或书籍可以帮助推动我对Meteor的了解?我应该走哪个方向?

meteor

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

"TypeError:字节索引必须是整数或切片,而不是str"将字节转换为整数

我正在使用不同的程序(ffmpeg)来获取下载的YouTube视频的长度,以便随机化视频中的特定点.但是,当我尝试执行此代码时,我收到此错误:

def grabTimeOfDownloadedYoutubeVideo(youtubeVideo):
    process = subprocess.Popen(['/usr/local/bin/ffmpeg', '-i', youtubeVideo], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    stdout, stderr = process.communicate()
    matches = str(re.search(b"Duration:\s{1}(?P<hours>\d+?):(?P<minutes>\d+?):(?P<seconds>\d+\.\d+?),", stdout, re.DOTALL).groupdict()).encode()
    print(matches)
    hours = int(matches['hours'])
    minutes = int(matches['minutes'])
    seconds = int(matches['seconds'])
    total = 0
    total += 60 * 60 * hours
    total += 60 * minutes
    total += seconds
    print(total)
Run Code Online (Sandbox Code Playgroud)

匹配变量打印出来:

b"{'minutes': b'04', 'hours': b'00', 'seconds': b'24.94'}"
Run Code Online (Sandbox Code Playgroud)

因此,所有输出在其开头都带有'b'.如何删除'b'并获取号码?

完整的错误消息:

Traceback (most recent call last):
  File "bot.py", line 87, in <module>
    grabTimeOfDownloadedYoutubeVideo("videos/1.mp4")
  File "bot.py", line 77, in grabTimeOfDownloadedYoutubeVideo
    hours = int(matches['hours'])
TypeError: byte …
Run Code Online (Sandbox Code Playgroud)

python ffmpeg

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