好的,这是如何非审查但列表的示例。
请注意,此示例是基于/访问本地文件系统的,但是可以轻松地重写/扩展到任何类型的层次/递归结构。
package stackoverflow.nonrecursivefilesearch;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.stream.Stream;
public class NonRecursiveFileSearch {
public static void main(final String[] args) throws IOException {
final File searchDir = new File("D:\\test\\maven-test"); // set one
System.out.println("\nOld Java");
printDirs(listFiles_old(searchDir, true, true), "OLD: Depth first, include dirs");
printDirs(listFiles_old(searchDir, true, false), "OLD: Breadth first, include dirs");
printDirs(listFiles_old(searchDir, false, true), "OLD: Depth first, exclude dirs");
printDirs(listFiles_old(searchDir, false, false), "OLD: Breadth first, exclude dirs");
System.out.println("\nNew java.io with streams");
printDirs(listFiles_newIO(searchDir, true), "Java NIO, include dirs");
printDirs(listFiles_newIO(searchDir, false), "Java NIO, exclude dirs");
}
/**
* this is the way to 'manually' find files in hierarchial/recursive structures
*
* reminder: "Depth First" is not a real depth-first implementation
* real depth-first would iterate subdirs immediately.
* this implementation iterates breadth first, but descends into supdirs before it handles same-level directories
* advantage of this implementation is its speed, no need for additional lists etc.
*
* in case you want to exclude recursion traps made possible by symbolic or hard links, you could introduce a hashset/treeset with
* visited files (use filename strings retrieved with canonicalpath).
* in the loop, check if the current canonical filename string is contained in the hash/treeset
*/
static public ArrayList<File> listFiles_old(final File pDir, final boolean pIncludeDirectories, final boolean pDepthFirst) {
final ArrayList<File> found = new ArrayList<>();
final ArrayList<File> todo = new ArrayList<>();
todo.add(pDir);
while (todo.size() > 0) {
final int removeIndex = pDepthFirst ? todo.size() - 1 : 0;
final File currentDir = todo.remove(removeIndex);
if (currentDir == null || !currentDir.isDirectory()) continue;
final File[] files = currentDir.listFiles();
for (final File file : files) {
if (file.isDirectory()) {
if (pIncludeDirectories) found.add(file);
// additional directory filters go here
todo.add(file);
} else {
// additional file filters go here
found.add(file);
}
}
}
return found;
}
static private void printDirs(final ArrayList<File> pFiles, final String pTitle) {
System.out.println("====================== " + pTitle + " ======================");
for (int i = 0; i < pFiles.size(); i++) {
final File file = pFiles.get(i);
System.out.println(i + "\t" + file.getAbsolutePath());
}
System.out.println("============================================================");
}
/**
* this is the java.nio approach. this is NOT be a good solution for cases where you have to retrieve/handle files in your own code.
* this is only useful, if the any NIO class provides support. in this case, NIO class java.nio.file.Files helps handling local files.
* if NIO or your target system does not offer such helper methods, this way is harder to implement, as you have to set up the helper method yourself.
*/
static public Stream<Path> listFiles_newIO(final File pDir, final boolean pIncludeDirectories) throws IOException {
final Stream<Path> stream = Files.find(pDir.toPath(), 100,
(path, basicFileAttributes) -> {
final File file = path.toFile(); // conversion to File for easier access (f.e. isDirectory()), could also use NIO methods
return (pIncludeDirectories || !file.isDirectory() /* additional filters go here */ );
});
return stream;
}
static private void printDirs(final Stream<Path> pStream, final String pTitle) {
System.out.println("====================== " + pTitle + " ======================");
pStream.forEach(System.out::println);
System.out.println("============================================================");
}
}
而且,必须添加 java.nio.file.files.find()
可以递归地实现。但这只是一个电话,这也许也可以算作“非恢复性”。
另外,正如OP在评论中所说的那样,人们可能会使用堆栈或其他FIFO/LIFO收集。 Lifo是混合深度第一,FIFO,用于广度优先的方法。
它应该是 message.Reply({embeds:[testembed]})
{content:“”}
仅适用于常规消息,因此应该是:
client.on('messageCreate', (message) => {
const testEmbed = new DiscordJS.MessageEmbed().setTitle('Topic')
if (message.content === '%topic') {
message.reply({
embeds: [testEmbed]
})
}
})
Bootstrap在他们的CSS课程中使用!将覆盖您的自定义课程。尝试在CSS声明中添加!重要的是或尝试将其添加为内联或ID。在特异性层次结构中,ID和内联样式更高。
如果那不起作用,请尝试使用开发工具来确保您正在设计正确的元素。
您可以使用定义样式
属性。
格式字符串有两个等效语法:
“ plain_text {{code}}”
(aka jinja-style)和“ plain_text#{code {code}”
(aka)红宝石风格)。
示例:
继承销售订单模板并在 H2
标签上设置保证金
<template id="report_saleorder_document_inherit" inherit_id="sale.report_saleorder_document">
<xpath expr="//h2" position="attributes">
<attribute name="t-attf-style">margin:{{doc.margin}}cm</attribute>
</xpath>
</template>
作为键入整体函数的替代方法,这很方便,因为它键入参数和返回类型,您可以单独键入这些函数并保留导出异步函数
语法。
但是,参数类型没有名称,因此您需要从 handle
手动提取它。请注意,实际上只有一个参数正在破坏。例如,
// Maybe export this from elsewhere to not repeat it
type HandleParams = Parameters<Handle>[0];
export async function handle({ event, resolve }: HandleParams) : Promise<Response> {
// ...
}
原始返回类型使用 maybepromise&lt; t&gt;
允许同步和异步返回。您只能仅使用 Promise
,如果该功能实际上是 async
。
还有另一种诸如参数
的助手类型,它可以使您从 handle
:
type HandleResult = ReturnType<Handle>;
问题
您将 myFolder
作为您在代码中未定义的函数的变量,因此提高了名称。
解决方案
只需将其替换为'myFolder'
[将其传递为字符串]。
CreateCorpusFromDataFrame('myfolder',mydf)
我不会出于两个原因将移动应用程序作为消费者成为消费者
- - 您需要在客户端
- 缩放性上保存信用 - 每个移动都将充当消费者,这将使主题的吞吐量随着用户数量的增长而增长,
我建议您编写一个新的组件,该组件会消耗来自Kafka的消息,并通过套接字数据发布给移动客户端。
查看socket.io,支持打字稿以及易于使用的库。
祝你好运!
如果有人想要解决方案(怀疑),我设法在这样的中间件中检索了cookie:
callbacks: {
authorized: ({ req }) => {
const cookie = req.headers.get('cookie');
const accessToken = cookie.split('accessToken=')[1].split(';')[0];
console.log(accessToken);
// Do your logic
return !!accessToken
},
},
如果语句,您不需要。使用
:has()
选择器可以使用此后代选择元素。
:contains()
是个体敏感的,因此您需要 red
而不是 red
那里。
jQuery(document).ready(function($) {
$('.taxonomy-list-item:has(.tax-desc:contains("Red"))').addClass("red");
});
.red {
color: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="taxonomy-list-item">
<div class="tax-details">
<div class="tax-name">
<div class="tax-title">
<a href="#">Category 1</a>
</div>
</div>
<div class="tax-desc">Red</div>
</div>
</div>
<div class="taxonomy-list-item">
<div class="tax-details">
<div class="tax-name">
<div class="tax-title">
<a href="#">Category 2</a>
</div>
</div>
<div class="tax-desc">Blue</div>
</div>
</div>
要更改Q1,Q3等的颜色和值,您可以使用以下更新的代码。更改 myq1
, myq3
和其他数组中的值以更改值。可以使用 Marker_Color
更改颜色。但是,基础数据点不可见。希望这会有所帮助。
from plotly.subplots import make_subplots
import plotly.graph_objects as go
#fig = go.Figure()
myq1=[ 2, 3, 4 ]
myq3=[ 8, 9, 10 ]
mymedian=[ 4, 5, 6 ]
mymean=[ 2.2, 2.8, 3.2 ]
mylowerfence=[ 0, 1, 2 ]
mynotchspan=[ 0.2, 0.4, 0.6 ]
mysd=[ 0.2, 0.4, 0.6 ]
mylowerfence=[ 0, 1, 2 ]
myupperfence=[9, 10, 11]
trace0 = go.Box( y=[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], name="Quartile1", marker_color='#3D9970', q1=[myq1[0]],
median=[mymedian[0]], q3 = [myq3[0]], lowerfence=[mylowerfence[0]], upperfence=[myupperfence[0]],
mean=[mymean[0]],sd=[mysd[0]], notchspan=[mynotchspan[0]])
trace1 = go.Box( y=[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], name="Quartile2", marker_color='#FF4136', q1=[myq1[1]],
median=[mymedian[1]], q3 = [myq3[1]], lowerfence=[mylowerfence[1]], upperfence=[myupperfence[1]],
mean=[mymean[1]],sd=[mysd[1]], notchspan=[mynotchspan[1]])
trace2 = go.Box( y=[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], name="Quartile3", marker_color='#FF851B', q1=[myq1[2]],
median=[mymedian[2]], q3 = [myq3[2]], lowerfence=[mylowerfence[2]],upperfence=[myupperfence[2]],
mean=[mymean[2]],sd=[mysd[2]], notchspan=[mynotchspan[2]])
fig=go.Figure(data=[trace0, trace1, trace2])
fig.update_traces(orientation='v')
fig.update_layout(boxmode='group')
fig.show()
output
我设法解决了这个问题,但我的传说分为两个部分:
fig, ax = plt.subplots()
# your code with your plots
ax.legend(['A'], fontsize=15)
ax.right_ax.legend(['B'], fontsize=15)
有两种方法可以这样做,使用 dayjs 通过使用它,您可以处理日期并转换为许多不同的形状信息检查它们的文件)。 如果您想将日期和时间与时间戳分开
/*
other your imports and codes
*/
let timestamp = moment(item.starts_on);
let date = timestamp.format('L');
let time = timestamp.format('LT');
/*
other your codes
*/
例如, 日期,您可以:
/*
other your imports and codes
*/
let d = new Date(item.starts_on);
let date = `${d.getMonth() + 1}/${d.getDate()}/${d.getFullYear()}`;
let time = `${d.getHours()}:${d.getMinutes()}`;
/*
other your codes
*/
更新答案
对于将日期转换为“ 2022年3月19日星期六”,您想要的,以下内容以下内容:
//fill in Months array
const Months = ["Jan", "Feb", ..., "Dec"];
//fill in Days of week array
const Days = ["Sun", "Mon", ..., "Sat"];
/*
other your codes
*/
let d = new Date(item.starts_on);
let monthIndex = d.getMonth();
let month = Months[monthIndex];
let dayIndex = d.getDay();
let day = Days[dayIndex];
let date = `${day} ${d.getDate()} ${month} ${d.getFullYear()}`;
/*
other your codes
*/
您可以将其用作您想做的事情的蓝图,重要的是Runspace看不到表单的控件。如果您希望您的Runspace与控件进行交互,则必须通过 sessionStateProxy.setVariable(...)
或用 .addparameters(..)例如。
using namespace System.Windows.Forms
using namespace System.Drawing
using namespace System.Management.Automation.Runspaces
Add-Type -AssemblyName System.Windows.Forms
[Application]::EnableVisualStyles()
try {
$form = [Form]@{
StartPosition = 'CenterScreen'
Text = 'Test'
WindowState = 'Normal'
MaximizeBox = $false
ClientSize = [Size]::new(200, 380)
FormBorderStyle = 'Fixed3d'
}
$listBox = [ListBox]@{
Name = 'myListBox'
Location = [Point]::new(10, 10)
ClientSize = [Size]::new(180, 300)
}
$form.Controls.Add($listBox)
$runBtn = [Button]@{
Location = [Point]::new(10, $listBox.ClientSize.Height + 30)
ClientSize = [Size]::new(90, 35)
Text = 'Click Me'
}
$runBtn.Add_Click({
$resetBtn.Enabled = $true
if($status['AsyncResult'].IsCompleted -eq $false) {
# we assume it's running
$status['Instance'].Stop()
$this.Text = 'Continue!'
return # end the event here
}
$this.Text = 'Stop!'
$status['Instance'] = $instance
$status['AsyncResult'] = $instance.BeginInvoke()
})
$form.Controls.Add($runBtn)
$resetBtn = [Button]@{
Location = [Point]::new($runBtn.ClientSize.Width + 15, $listBox.ClientSize.Height + 30)
ClientSize = [Size]::new(90, 35)
Text = 'Reset'
Enabled = $false
}
$resetBtn.Add_Click({
if($status['AsyncResult'].IsCompleted -eq $false) {
$status['Instance'].Stop()
}
$runBtn.Text = 'Start!'
$this.Enabled = $false
$listBox.Items.Clear()
})
$form.Controls.Add($resetBtn)
$status = @{}
$rs = [runspacefactory]::CreateRunspace([initialsessionstate]::CreateDefault2())
$rs.ApartmentState = [Threading.ApartmentState]::STA
$rs.ThreadOptions = [PSThreadOptions]::ReuseThread
$rs.Open()
$rs.SessionStateProxy.SetVariable('controls', $form.Controls)
$instance = [powershell]::Create().AddScript({
$listBox = $controls.Find('myListBox', $false)[0]
$ran = [random]::new()
while($true) {
Start-Sleep 1
$listBox.Items.Add($ran.Next())
}
})
$instance.Runspace = $rs
$form.Add_Shown({ $this.Activate() })
$form.ShowDialog()
}
finally {
($form, $instance, $rs).ForEach('Dispose')
}
demo
在颤抖中
请参见此文档。
Flutter使用a 单个Pass AlgorithM 渲染您的申请。这是确保性能的技术选择,但它具有限制。
其中之一是,当您构建小部件树时,您只能访问父级的约束,而不访问任何小部件的大小(因为它们尚未渲染)。
因此,对您的问题的简短答案是:
不,您无法做自己想做的事情(如果某些小部件不合适在屏幕上,则显示某些内容),因为您无法访问构建方法中的任何尺寸。
另一种解决方案是使用
Wrap
包装芯片或在水平轴上使用ListView
,以使芯片列表水平滚动。无论如何,如果您真的想这样做,则可以用
MediaQuery.of(context).Size
或使用LayoutBuilder 使用
contrapts.maxwidth
作为父宽度。然后,您可以检查numberofchips * chipsize&lt; = maxWidth
。但是我不建议这样做,因为设计不会响应:In flutter
See this documentation.
Flutter uses a single pass algorithm to render your application. This is a technical choice to ensure performance but it comes with limitations.
One of them is that, when you are building the widget tree, you only have access to the constraints of the parent, and not any size of any widget (since they are not rendered yet).
So a short answer to your question is:
No, you cannot do what you are trying to do (displaying something if some widgets are not fitting on the screen) since you don't have access to any sizes in the build method.
An alternative solution would be to use
Wrap
to wrap your chips or use aListView
on the horizontal axis to make the list of chips horizontally scrollable.Anyway, if you really want to do this, you can hardcode the sizes of your chip and access the device size with
MediaQuery.of(context).size
or by using theLayoutBuilder
and usingcontraints.maxWidth
as the parent's width. Then you can check whether or notnumberOfChips * chipSize <= maxWidth
. But I wouldn't recommend it as the design wouldn't be responsive:有没有办法计算动态尺寸的小部件?