我有2个语句如下绘制图表.
public static List<KeyValuePair<int, double>> entries = new List<KeyValuePair<int, double>>();
entries.Add(new KeyValuePair<int, double>(j, min));
Run Code Online (Sandbox Code Playgroud)
我想要的是,如果min值小于或等于min列表中的每个其他值,则仅将值添加到List .怎么能实现这一目标?谢谢.
所以我试图绘制关于时间的加速度计数据,我的 csv 读起来像这样(列 -> 时间,x,y,z):
1518999378635,2.275090217590332,8.601768493652344,3.691260576248169
1518999378653,2.38462495803833,8.633491516113281,4.0964789390563965
1518999378658,2.449866771697998,8.506000518798828,4.082113742828369
1518999378667,2.4372973442077637,8.166622161865234,4.016273498535156
1518999378675,1.8381483554840088,8.848969459533691,4.086902141571045
1518999378681,1.1402385234832764,8.762179374694824,4.225766181945801
1518999378688,1.7818846702575684,8.652046203613281,3.6110546588897705
1518999378694,2.076371431350708,8.80467700958252,4.0527849197387695
1518999378700,2.3720552921295166,8.471882820129395,4.120420932769775
Run Code Online (Sandbox Code Playgroud)
我最初的赌注(如下所示!)是使用带有时间的散点作为颜色,但是输出不是很明显。
from numpy import genfromtxt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
if __name__ == "__main__":
print("Plotting Accelerometer Data")
acm_data = genfromtxt("acm_data.csv", delimiter=',', names="time, acc_x, acc_y, acc_z")
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x = acm_data["acc_x"]
y = acm_data["acc_y"]
z = acm_data["acc_z"]
c = acm_data["time"]
ax.scatter(x, y, z, c=c, cmap=plt.hot())
plt.show()
Run Code Online (Sandbox Code Playgroud)
输出看起来即:
并且不太容易解释。处理这个问题的最佳方法是什么?谢谢。
我正在 ubuntu docker 映像中安装 pihole。但是,安装程序在“重新启动 lighttpd 服务”时停止并存在。
这是我的 base.docker 文件:
FROM ubuntu:latest
ENV term=xterm
ENV DEBIAN_FRONTEND=noninteractive
RUN \
apt-get update --fix-missing\
&& apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# Pihole commands
RUN mkdir /etc/pihole
COPY pihole/setupVars.conf /etc/pihole
RUN apt-get update && apt-get install -y apt-transport-https
RUN apt-get install -y dialog
RUN apt-get install -y dhcpcd5
RUN apt-get install -y apt-utils
RUN apt install git -y
RUn apt-get install -y iproute2
RUN apt-get install -y whiptail
RUN apt-get …Run Code Online (Sandbox Code Playgroud) 我做了一个非常简单的合并排序实现,但我继续得到java.lang.NullPointerException.这是我的代码:
public class MergeSort {
private int[] c;
private int i = 0, j = 0, k = 0;
public MergeSort(int[] a, int[] b){
while( i < a.length && j < b.length){
if(a[i] > b[j])
c[k++] = b[j++];
else
c[k++] = a[i++];
}
while(i < a.length){
c[k++] = a[i++];
}
while(j < b.length){
c[k++] = b[j++];
}
i = 0;
while(i < c.length){
System.out.print(c[i++] + " ");
}
}
}
Run Code Online (Sandbox Code Playgroud)
我正在从主类调用构造函数,如下所示:
public class MainRun {
public static void main(String[] args) …Run Code Online (Sandbox Code Playgroud) 所以,在我发布我的问题之前,我会为它添加一些前提.我已经为学术目的写了很多代码,但从来没有用于生产或实际客户.我总是这样做:
private void button1_Click(object sender, EventArgs e)
{
//Do all the programming here
}
Run Code Online (Sandbox Code Playgroud)
但是,现在当我必须为客户端(一个小的)构建实际软件时,我觉得这个过程繁琐且难以处理,因为代码变长了.
我仍然创建单独的类并在这里和那里做一些工作,但我认为这不是正确的方向.
我错过了什么?专业开发人员如何做到 谢谢.
编辑:这不是一个编码问题,但我仍然选择StackOverflow,因为我真的想要在这里出现的高超专业人士的不同观点.我只是一个行业新手,所以我真的需要开始朝着正确的方向学习.
我正在阅读多个 JSON 文件:
using (var fbd = new FolderBrowserDialog())
{
DialogResult result = fbd.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
{
IEnumerable<string> allJSONFiles = GetFileList("*.json", fbd.SelectedPath);
txtOutput.Clear();
txtOutput.Text = "Number of files found: " + allJSONFiles.ToList().Count + "\n";
foreach (string filename in allJSONFiles)
{
txtOutput.Text += filename + "\n";
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在 JSON 文件或多或少看起来像这样,有多个对象:
[{
"Domain": "example.com",
"A": ["50.63.202.28"],
"MX": ["0 example-com.mail.protection.outlook.com."],
"NS": ["ns48.example.com.", "ns47.example.com."],
"SOA": ["ns47.example.com. dns.jomax.net. 2017062304 28800 7200 604800 600"],
"TXT": ["\"MS=ms94763887\"", "\"google-site-verification=example-f0KFEgl-HnJF4_Gk\"", "\"v=spf1 include:spf.protection.outlook.com -all\""], …Run Code Online (Sandbox Code Playgroud) 我试图创建一个基本上创建一些二进制数据/转换它的函数,并根据存储它的方程修改它并将输出导出为HTML.这是截断的代码:
/*
* Initialising list/list of list to store data strings.
*/
List<string> BitValues = new List<string>();
List<List<string>> DataList = new List<List<string>>();
/*
* Some Code.
*/
/*
* +=+=+=+=+=+=+=+=+=+=+=+=+=++=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
* Mathematical Code Begins.
* =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
*/
List<string> strVal = new List<string>();
double avgVal = 0;
for (; ; )
{
foreach (string randBit in BitValues)
{
double decVal = Convert.ToDouble(Conversions.ToDecimal(randBit));
/*
* Implementing mathematical equation.
*/
double eqnValue = (0.52359) + (((1.04719) / Math.Pow(2.0, Convert.ToDouble(txtBitSize.Text)) * decVal));
avgVal += …Run Code Online (Sandbox Code Playgroud) 我正在使用以下代码将文件写入桌面。
string submittedFilePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
int i = 0;
StreamWriter sw = null;
sw = new StreamWriter(submittedFilePath, false);
for (i = 0; i < PSOLib.table.Columns.Count - 1; i++)
{
sw.Write(PSOLib.table.Columns[i].ColumnName + ";");
}
sw.Write(PSOLib.table.Columns[i].ColumnName);
sw.WriteLine();
foreach (DataRow row in PSOLib.table.Rows)
{
object[] array = row.ItemArray;
for (i = 0; i < array.Length - 1; i++)
{
sw.Write(array[i].ToString() + ";");
}
sw.Write(array[i].ToString());
sw.WriteLine();
}
sw.Close();
Run Code Online (Sandbox Code Playgroud)
但是,每当我尝试调用该方法时,我都会得到:
Access to the path 'C:\\Users\\User\\Desktop' is denied.
System.UnauthorizedAccessException.
Run Code Online (Sandbox Code Playgroud) 所以我在一个按钮内部有一个函数,我想在应用程序启动时立即触发,我这样做:
public partial class App : Application
{
private void App_OnStartup(object sender, StartupEventArgs e)
{
//get button reference
Button btn = ((MainWindow)Current.MainWindow).btnJSON;
//programmatically simulate button click
ButtonAutomationPeer peer =
new ButtonAutomationPeer(btn);
IInvokeProvider invokeProv =
peer.GetPattern(PatternInterface.Invoke)
as IInvokeProvider;
invokeProv.Invoke();
}
}
Run Code Online (Sandbox Code Playgroud)
然而,这导致了一个nullReferenceExeption.我如何实现这一点,即在App stratup上调用功能或模拟按钮点击?
这是按钮签名:
public void btnJSON_Click(object sender, RoutedEventArgs e)
{
...
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
这是我的简单动态数组的工作代码.这必须是非常入门级数据结构实现的示例代码:
#include <iostream>
using namespace std;
class AdvancedArray {
public:
AdvancedArray();
~AdvancedArray();
int get_size() const; // get the number of elements stored
double& at(int idx) const; // access the element at idx
void push_back(double d); // adds a new element
void remove(int idx); // remove the element at idx
void clear(); // delete all the data stored
void print() const;
private:
double* elements;
int size;
};
int main()
{
AdvancedArray* arr = new AdvancedArray();
cout << "The Array Size is: …Run Code Online (Sandbox Code Playgroud) 所以我编写了一个小函数来从输入域字符串中删除子域(如果有):
def rm(text):
print(text.replace(text, '.'.join(text.split('.')[-2:])), end="")
print("\n")
if __name__ == "__main__":
rm("me.apple.com")
rm("not.me.apple.com")
rm("really.not.me.apple.com")
# problem here
rm("bbc.co.uk")
Run Code Online (Sandbox Code Playgroud)
一切都很好,直到你有.something.somethingtld., like.co.uk或.co.in。
所以我的输出是:
apple.com
apple.com
apple.com
--> co.uk
Run Code Online (Sandbox Code Playgroud)
它应该在的地方,
apple.com
apple.com
apple.com
bbc.co.uk
Run Code Online (Sandbox Code Playgroud)
如何以优雅的方式修复/创建该函数,而不是检查所有可能的双重顶级域名? 编辑:如果这很重要的话,我将不得不检查数百万个域名。所以我要做的就是将一个域传递给我的函数并获得一个干净的、无子域的域。
设置均值flag value = 1和未设置均值flag value = 0
现在我了解有几种方法可以在MASM中设置和取消设置标志,如下所示:
test al,0 ; set Zero flag
and al,0 ; set Zero flag
or al,1 ; clear Zero flag
Run Code Online (Sandbox Code Playgroud)
同样适用于Sign flag:
or al,80h ; set Sign flag
and al,7Fh ; clear Sign flag
Run Code Online (Sandbox Code Playgroud)
要设置Carry flag,我们使用STC指令; 要清除Carry标志,我们使用CLC:
stc ; set Carry flag
clc ; clear Carry flag
Run Code Online (Sandbox Code Playgroud)
要设置Overflow flag,我们添加两个产生负和的正值.要清除Overflow flag,我们OR操作数为0:
mov al,7Fh ; AL = +127
inc al ; AL = 80h (-128), …Run Code Online (Sandbox Code Playgroud) 所以我最初使用单例列表将数据传递给 Google Cloud API,如下所示:
inputInput.setCsvInstance(Collections.<Object>singletonList("Ear"));
Run Code Online (Sandbox Code Playgroud)
如何更改singletonList发送多个对象,如下所示:
inputInput.setCsvInstance(Collections.<Object>singletonList("5.656346", "2.43485744", ...));
Run Code Online (Sandbox Code Playgroud)
编辑:我不想保持单身。我需要将其更改为多个,单例不允许我这样做。我应该使用什么关键字而不是单例是我的问题。
谢谢。