小编fur*_*ins的帖子

使用Gulp在同一目录中的多个文件扩展名

所以我有一个gulpfile.js设置.

在图像文件夹中,我有一些图像,一些是png,一些是jpgs和一些GIF.

我想定位images文件夹中的所有png,jpgs和gif.

我可以使用**/*来定位文件夹中的所有内容,但我不想,我希望它特定于文件类型.

我也可以这样做并单独指定每种文件类型:

return gulp.src('./images/*.jpg', './images/*.png', './images/*.gif')
Run Code Online (Sandbox Code Playgroud)

但这是很多重复自己,似乎应该有一个更简单的方法.

我正在寻找这样的东西:

return gulp.src('./images/*.{png, gif, jpg}')
Run Code Online (Sandbox Code Playgroud)

但是,唉,上面不起作用(或者至少它只适用于列表中的第一个文件类型)

有人知道怎么做吗?

谢谢

javascript gulp

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

如何在Xcode中为UIView的宽度和高度设置动画?

我有这个子视图我想添加到我的主视图,但让它从原点扩展.我阅读了一些Apple文档,但我不明白我在哪里弄错了.我可以为框架的原点设置动画,即让它从任何地方滑入,但宽度/高度似乎没有动画.代码如下:

[UIView beginAnimations:@"animateAddContentView" context:nil];
[UIView setAnimationDuration:0.4];
customView.frame= CGRectMake(self.view.frame.origin.x +5, self.view.frame.origin.y +5, 0, 150);
[self.view addSubview:customView];

customView.frame= CGRectMake(self.view.frame.origin.x +5, self.view.frame.origin.y +5, 310, 150);
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)

我也试过在动画中只放置setFrame部分,如下所示:

customView.frame= CGRectMake(self.view.frame.origin.x +5, self.view.frame.origin.y +5, 0, 150);
[self.view addSubview:customView];
[UIView beginAnimations:@"animateAddContentView" context:nil];
[UIView setAnimationDuration:0.4];
customView.frame= CGRectMake(self.view.frame.origin.x +5, self.view.frame.origin.y +5, 310, 150);
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)

但它仍然不起作用!

编辑:

根据建议,我已将其移至基于块的动画解决方案,这是确切的代码:

NSLog(@"yourview : %@",customView);
customView.frame= CGRectMake(self.view.frame.origin.x +5, self.view.frame.origin.y +5, 0, 150);

NSLog(@"yourview : %@",customView);
[self.view addSubview:customView];
NSLog(@"yourview : %@",customView);

//    [customView setFrame:CGRectMake( 0.0f, 480.0f, customView.frame.size.width, customView.frame.size.height)];

[UIView animateWithDuration:0.4
                      delay:0
                    options:UIViewAnimationCurveEaseInOut …
Run Code Online (Sandbox Code Playgroud)

xcode animation uiview uiviewanimation ios

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

数据库设计:文件路径的首选字段长度

我要的文件路径存储在数据库字段(/tmp/aaa/bbb,C:\temp\xxx\yyy等).我无法确定它们可以存在多久.

鉴于此http://en.wikipedia.org/wiki/Comparison_of_file_systemshttp://msdn.microsoft.com/en-us/library/aa365247.aspx,根据文件系统,理论上可能没有长度限制一条路径.

我想将此字段定义为LONGBLOBVARCHAR(very high value)不明智.我已经考虑过VARCHAR(1024)哪些应该适合最频繁(即使不是全部)的情况,而不是像DB字段那么大.你会推荐什么 ?

谢谢.

database sql-server database-design

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

阻止PyCharm在KeyboardInterrupt和其他场合显示内置模块

在PyCharm中,当出现错误时,IDE会打开产生错误的模块(当按下产生错误时,这尤其令人讨厌Ctrl+C).

在打开调试模式时,它还会打开程序当前"正在"的模块.有没有办法禁用内置模块的这种行为?(最好以一种方式显示异常,以防您想要查看内置模块的来源)

python ide built-in pycharm

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

有没有办法在没有视图模型的情况下呈现html页面?

如果页面只显示静态html,有没有办法在django中没有视图模型的情况下呈现html页面?

另外,我可以重定向到HTML页面而不是网址吗?例如,而不是这样做:

return HttpResponseRedirect('form/success/')
Run Code Online (Sandbox Code Playgroud)

我可以这样做:

return HttpResponseRedirect('success.html')
Run Code Online (Sandbox Code Playgroud)

django

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

iOS - 使用"设置"和"取消"按钮打开"位置服务" - "如何捕获取消"按钮单击

当用户第一次启动应用程序并尝试登录时,会显示iOS对话框 - "打开位置服务".

我需要在用户点击"取消"时捕获.有Notification送吗?如果是这样,它的名字是什么?我一直无法找到它.

CLAUthorizationStatuskCLAuthorizationDenied,当位置服务被禁用或用户点击"不允许".当用户单击"取消"时,它不会触发该authorizationChange事件.当用户点击"取消"时,应用程序就会挂起.

cllocationmanager ios

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

添加中间表单后 Django 管理站点操作不起作用

我有一个 django 模型,我想为其添加自定义操作。在此操作中,我需要添加一个带有选择表单(下拉选择)的中间页面。我用下面的代码来得到这个。

模型类:

class VerificationAdmin(admin.ModelAdmin):
      list_display   = ('id','asset_code', 'scan_time','credential','status','operator','location','auth_code','product_details')
      list_filter    = ('status','operator','location')
      ordering       = ('-scan_time',)
      search_fields  = ('asset_code',)
      actions = ['set_interval']

      class AddScanningIntervalForm(forms.Form):
           _selected_action = forms.CharField(widget=forms.MultipleHiddenInput)
           period_choice=["4 hrs","6 hrs","8 hrs","10 hrs","12 hrs"]
           interval = forms.ChoiceField(choices=[(x, x) for x in period_choice])

      @csrf_exempt
      def set_interval(self, request, queryset):
           print "before action"
           form = None
           if 'apply' in request.POST:
               form = self.AddScanningIntervalForm(request.POST)
               print "action taken"
               if form.is_valid():
                   interval = form.cleaned_data['interval']
                   print interval
                   count = 0
                   for vObj in queryset:
                       print vObj.asset_code,vObj.status,interval                
                       at=AlertTable(asset_code=vObj.asset_code,
                       status=vObj.status,interval=interval) …
Run Code Online (Sandbox Code Playgroud)

django django-models django-admin

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

为什么拒绝连接?

我正在创建一个Web抓取脚本并将其分为四个部分.另外它们都完美无缺,但是当我把它们放在一起时我得到以下错误:urlopen错误[Errno 111]连接被拒绝.我已经看过类似的问题,并尝试用try-except来捕捉错误,但即使这样也行不通.我的所有代码都是:

from selenium import webdriver
import re
import urllib2
site = ""

def phone():
    global site
    site = "https://www." + site
    if "spokeo" in site:
        browser = webdriver.Firefox()
        browser.get(site)
        content = browser.page_source
        browser.quit()
        m_obj = re.search(r"(\(\d{3}\)\s\d{3}-\*{4})", content)
        if m_obj:    
            print m_obj.group(0)    
    elif "addresses" in site:
        usock = urllib2.urlopen(site)
        data = usock.read()
        usock.close()
        m_obj = re.search(r"(\(\d{3}\)\s\d{3}-\d{4})", data)
        if m_obj:    
            print m_obj.group(0)
    else :
        usock = urllib2.urlopen(site)
        data = usock.read()
        usock.close()
        m_obj = re.search(r"(\d{3}-\s\d{3}-\d{4})", data)
        if m_obj:    
            print m_obj.group(0)

def pipl(): …
Run Code Online (Sandbox Code Playgroud)

python https networking urllib2 web-scraping

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

Vanilla Django在日志记录中投射了一个ResourceWarning:"unclosed file"

我的Django 1.8/Python 3.4设置存在问题.跑步时

python -Wall ./manage.py runserver
Run Code Online (Sandbox Code Playgroud)

我收到以下警告:

/lib/python3.4/logging/config.py:763: 
ResourceWarning: unclosed file <_io.TextIOWrapper name='/Users/furins/logs/test-project.log' mode='a' encoding='UTF-8'>
  for h in logger.handlers[:]:
Run Code Online (Sandbox Code Playgroud)

这些是settings.py与日志记录相关的设置:

LOGGING_LEVEL = 'DEBUG'

LOG_DATE_FORMAT = '%d %b %Y %H:%M:%S'

LOG_FORMATTER = logging.Formatter(
    '%(asctime)s | %(levelname)-7s | %(name)s | %(message)s',
    datefmt=LOG_DATE_FORMAT)

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'formatters': {
        'standard': {
            'format': "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
            'datefmt': LOG_DATE_FORMAT
        },
    },
    'handlers': {
        'logfile': {
            'level': LOGGING_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': …
Run Code Online (Sandbox Code Playgroud)

python django logging python-3.x

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

如何在python中的表视图中显示数据库中的数据

我是python的新手并且遇到了问题,请任何人帮我解决这个问题.要求是我创建了一个sqlite数据库,并创建了一个表,并且还插入了值,但问题是我没有得到如何在python的表视图中显示数据库中的数据,所以请帮助我从这.....提前谢谢..

db_con = sqlite3.Connection
db_name = "./patientData.db"
createDb = sqlite3.connect(db_name)
queryCurs = createDb.cursor()
queryCurs.execute('''CREATE TABLE IF NOT EXISTS PATIENT
    (NAME TEXT NOT NULL, ID INTEGER PRIMARY KEY, AGE INTEGER NOT NULL, GENDER TEXT NOT NULL , EYE_TYPE TEXT NOT NULL)''')

pName = self.patientEdit.text()
pId =self.patientidEdit.text()
#pId1 = int(pId)
pAge = self.ageEdit.text()
#pAge1 = int(pAge)
pGender = self.patientgend.text()
pEye_type = self.eyeTypeEdit.text()
queryCurs.execute('''INSERT INTO PATIENT(NAME,ID,AGE, GENDER,EYE_TYPE) VALUES(?, ?, ?, ?, ?)''',(pName, pId, pAge, pGender, pEye_type))
print ('Inserted row')
createDb.commit()
Run Code Online (Sandbox Code Playgroud)

现在我如何在tableview/listview中显示数据,任何示例代码也都有帮助

python pyside

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

Python中的TypeError - 美丽的汤

我正在网页抓取这个页面http://www.crmz.com/Directory/Industry806.htm,我应该得到所有的

  • #
  • 公司名
  • 国家
  • 州/省

但是compnay名称旁边有一个rss链接,所以我没有得到结果并显示一个typeError.

这是我的代码:

#!/usr/bin/env python
from mechanize import Browser
from BeautifulSoup import BeautifulSoup

mech = Browser()
url = "http://www.crmz.com/Directory/Industry806.htm"
page = mech.open(url)

html = page.read()
soup = BeautifulSoup(html)
table = soup.find("table", {"border":"0", "cellspacing":"1", "cellpadding":"2"})

rows = table.findAll('tr')
for tr in rows:
    cols = tr.findAll('td')
    for td in cols:
        text = ''.join(td.find(text=True))
        print text+"|",
    print
Run Code Online (Sandbox Code Playgroud)

这是我的输出:

LRI$ python scrape.py

#| Company Name| Country| State/Province|
1.| 1300 Smiles Limited|

Traceback (most recent call last):
  File "scrape.py", …
Run Code Online (Sandbox Code Playgroud)

python beautifulsoup typeerror

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