的WebPack提供了多种方法来异步加载模块(require([], resolve)
,import('...')
,require.ensure
).使用这些函数可以使webpack自动将生成的bundle拆分为包含所需模块的块.
问题是 - 每当webpack尝试加载另一个bundle chunk并显示一些加载动画(例如nprogress.start()
),然后nprogress.done()
在加载chunk时隐藏这个动画(),我该如何挂钩?
我试图搜索webpack钩子,但我找到的只是编译阶段而不是运行时(例如这个)
我想使用单个注释文本来注释几个带有几个箭头的数据点.我做了一个简单的解决方法:
ax = plt.gca()
ax.plot([1,2,3,4],[1,4,2,6])
an1 = ax.annotate('Test',
xy=(2,4), xycoords='data',
xytext=(30,-80), textcoords='offset points',
arrowprops=dict(arrowstyle="-|>",
connectionstyle="arc3,rad=0.2",
fc="w"))
an2 = ax.annotate('Test',
xy=(3,2), xycoords='data',
xytext=(0,0), textcoords=an1,
arrowprops=dict(arrowstyle="-|>",
connectionstyle="arc3,rad=0.2",
fc="w"))
plt.show()
Run Code Online (Sandbox Code Playgroud)
产生以下结果:
但我真的不喜欢这个解决方案,因为它是......好吧,一个丑陋的黑客.
除此之外,它还会影响注释的外观(主要是使用半透明的bbox等).
所以,如果有人得到了实际的解决方案或者至少知道如何实现它,请分享.
使用gatsby-node.js
和createPages
我可以查询一些使用graphql,并使用该页面的东西作为页面的上下文。所以这些页面可以在他们的查询中使用这些东西作为参数。
我面临的问题是我不想使用createPages
. 我完全罚款与默认情况下(从创建的页面gatsby-plugin-page-creator
),我只希望他们都具有一些从graphql作为上下文。
基本上我想要一个全局上下文(我从 gatsby graphql 获得)可用于所有页面。
有onCreatePage
钩子,但不幸的是,根据https://github.com/gatsbyjs/gatsby/issues/3121#issuecomment-348781341,graphql在那里不可用。
我正在尝试使用matplotlib
带有空格的线条来实现图形,这些点在这一点附近:
graph.png http://simplystatistics.org/wp-content/uploads/2013/01/Beijingair.png
我知道set_dashes
函数,但是它从起点设置了周期性破折号而没有控制终点破折号.
编辑:我做了一个解决方法,但结果图只是一堆平常的线,它不是一个单一的对象.它还使用另一个库pandas
,奇怪的是,它的工作方式并不像我预期的那样 - 我想要相等的偏移量,但不知怎的,它们显然与长度有关.
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
def my_plot(X,Y):
df = pd.DataFrame({
'x': X,
'y': Y,
})
roffset = 0.1
df['x_diff'] = df['x'].diff()
df['y_diff'] = df['y'].diff()
df['length'] = np.sqrt(df['x_diff']**2 + df['y_diff']**2)
aoffset = df['length'].mean()*roffset
# this is to drop values with negative magnitude
df['length_'] = df['length'][df['length']>2*aoffset]-2*aoffset
df['x_start'] = df['x'] -aoffset*(df['x_diff']/df['length'])
df['x_end'] = df['x']-df['x_diff']+aoffset*(df['x_diff']/df['length'])
df['y_start'] = df['y'] -aoffset*(df['y_diff']/df['length'])
df['y_end'] = …
Run Code Online (Sandbox Code Playgroud) 我使用组织模式来计算我的工作时间,有时我会在午夜工作几个小时.
所以,例如,我的时间从03.06.2013开始,晚上10点到凌晨04.06.2013凌晨2点.
org-mode将它分为凌晨0点,开始新的一天.但是如果那个时间早上0点到凌晨2点被记录在03.06.2013而不是04.06.2013那么对我来说会更方便.
所以我希望能够指定在什么时间(例如,凌晨4点)org-mode决定新的一天开始.
我可以通过改变emacs进程的时区来使用解决方法,但是我需要记住所有记录的时间都被移动...不是很方便.
如何在没有任何"技术"内容的情况下从org-mode标题中获取笔记?我的意思是,我想要那样的东西
* Some project
- some note 1
- some note 2
** some chapter
- another note
- noooote
** TODO some big todo
- something to note for the task
- another thing
** some chapter
Run Code Online (Sandbox Code Playgroud)
而不是那个
* Some project
- some note 1
- some note 2
** some chapter
- another note
- noooote
** TODO some big todo
CLOSED: [2011-11-10 Thu 19:51]
- State "DONE" from "STARTED" [2011-11-10 Thu 19:51]
CLOCK: [2011-11-10 Thu 19:33]--[2011-11-10 Thu …
Run Code Online (Sandbox Code Playgroud) 通过'type function argument'我的意思是这个
> newtype Wrapper f a = Wrapper (f a)
> :kind Wrapper
Wrapper :: (* -> *) -> * -> *
Run Code Online (Sandbox Code Playgroud)
所以f
这是一个类型函数参数,所以我可以像这样构造类型
> :kind Wrapper Maybe Int
Wrapper Maybe Int :: *
Run Code Online (Sandbox Code Playgroud)
现在我的问题是我实际使用f
的是值Wrapper
,我想忽略它:
> newtype Wrapper f a = Wrapper a
> :kind Wrapper
Wrapper :: * -> * -> *
Run Code Online (Sandbox Code Playgroud)
你猜怎么着!f
不再是类型函数,导致我以前的类型构造失败:
> :kind Wrapper Maybe Int
<interactive>:1:9: error:
• Expecting one more argument to ‘Maybe’
Expected a type, …
Run Code Online (Sandbox Code Playgroud) emacs ×2
matplotlib ×2
org-mode ×2
python ×2
annotate ×1
asynchronous ×1
gatsby ×1
haskell ×1
linestyle ×1
webpack ×1