我需要从 Android 手机的网页中读取二维码,为此我决定使用 ReactJS 编写一个页面,找到 react-qr-reader 库,从文档中的示例中获取代码 在我的 Chrome 浏览器中电脑,一切正常(连接网络摄像头时),在安卓设备上打开页面,我看到以下内容
如果你打开控制台
消息:“未找到视频输入设备”
名称:“NoVideoInputDevicesError”
请告诉我一个使用golang从winEventLog读取的工作包(最好有例子),我尝试使用gopkg.in/elastic/beats.v1/winlogbeat/eventlog
它,但是包的源代码和github.com/elastic/beats/winlogbeat
我用 ReactJS 写了一个客户端,我用 axios 进行 http 请求,我向服务器发出一个 post 请求,请求在服务器上处理并返回数据和一个 200 代码,但是浏览器中的错误是:
从源“ http://localhost:3000 ”访问“ https://Xxxxxx ”处的 XMLHttpRequest已被 CORS 策略阻止:请求的资源上不存在“Access-Control-Allow-Origin”标头。
和警告
xhr.js:166 跨域读取阻止 (CORB) 阻止了 MIME 类型 application/json 的跨域响应“ https://Xxxxxx ”。有关详细信息,请参阅 https://www.chromestatus.com/feature/5629709824032768 。
我阅读了浏览器的建议,但没有帮助
编码:
import axios from 'axios';
const baseIP = ''
const baseURL = 'x' + baseIP
const baseAPI = axios.create({
baseURL: baseURL,
});
const getConfig = (params) => {
return {
baseURL: baseURL,
headers: {
'Content-Type': 'application/json',
},
params: params,
};
};
const API = {
// isAuth: () => { return Auth.isAuthenticated(); },
// Login: (data, handler) => { return Auth.authenticate(data, handler); },
// Logout: (handler) => { return Auth.signout(handler); },
GET: (path, params) => baseAPI.get(path, getConfig(params)),
POST: (path, data) => baseAPI.post(path, data, getConfig()),
PUT: (path, data) => baseAPI.put(path, data, getConfig()),
DELETE: (path, params) => baseAPI.delete(path, getConfig(params)),
};
class BotService{
getFonds = () => API.POST('x')
};
export default BotService;
你能建议在哪里挖吗?
在golang中,在sqlx库中,有一个Get函数,长这样
func (db *DB) Get(dest interface{}, query string, args ...interface{}) error {
return Get(db, dest, query, args...)
}
我正在尝试在此 Get 上编写一个包装器:
func (i database) getDate(query string, args ...interface{}) {
var value sql.NullString
i.connection.DB.Unsafe().Get(&value, query, args...)
}
我向函数提交了类型请求SELECT MAX(?) FROM ? WHERE pointofcontrol = ? AND commandType = 8 OR commandType = 4
和请求的参数,但出现错误
错误 1064:您的 SQL 语法有错误;查看与您的 MariaDB 服务器版本相对应的手册,以了解在 '? 附近使用的正确语法。WHERE 控制点 = ? AND commandType = 8 OR commandType = 4' 在第 1 行
我在go中写了一个函数,提升与数据库的连接,取出数据并关闭连接,但是函数完成后,连接仍然存在,直到我暂停程序
func selectSites() (sites siteList, list string) {
connectSetting := fmt.Sprintf(
"%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=True",
config.AppConfig.DB.User,
config.AppConfig.DB.Pass,
config.AppConfig.DB.Host,
strconv.Itoa(config.AppConfig.DB.Port),
config.AppConfig.DB.Name,
)
db, err := sql.Open("mysql", connectSetting)
defer db.Close()
rows, err := db.Query(config.AppConfig.SQL.SelectList)
defer rows.Close()
if err == nil {
for rows.Next() {
err := rows.Scan(&list)
if err != nil {
config.InLog("selectSites list parse err %s", err.Error())
continue
}
}
} else {
config.InLog("selectSites list err %s", err.Error())
}
return
}
在不停止程序的情况下杀死第三个进程需要做什么
有一个 GSM 模块,您需要使用它来发送 SMS。我可以通过 minicom 使用 AT 命令发送 SMS,现在的任务是立即从 Linux 终端发送 SMS,为了将这些命令放入 Golang 程序,我找到了如何使用echo
,但没有任何反应:
echo -e 'AT+CMGS="89169478466"\n' > /dev/ttyAMA0
echo -e 'qwerty\n' > /dev/ttyAMA0
echo -e '^Z' > /dev/ttyAMA0
GSM模块连接到 /dev/ttyAMA0
我有一个 Pfx 文件(大小 7KB):22112018.pfx,其中有一个密钥对和 CA 颁发的证书。
密钥对和证书在令牌上,我从那里将它们导出到 pfx 文件,图片显示了我选择的导出配置 + 检查了所有项目:
我需要使用 pfx 文件签署文档,为此我使用以下命令将 pfx 文件转换为 pem 文件:
openssl pkcs12 -in 22112018.pfx -nocerts -out my_Pkey.pem -nodes
但是会弹出一个错误
输出密钥和证书时出错
073742524:错误:06074079:数字包络例程:EVP_PBE_CipherInit:未知的 pbe 算法:evp_pbe.c:162:TYPE=1.2.840.113549.1.12.1.80
3073742524:错误:23077073:PKCS12 例程:PKCS12_pbe_crypt:pkcs12 算法密码初始化错误:p12_decr.c:87:
签名命令在我之前找到并且可以 100% 工作,您只需要一个普通的 pem 文件
openssl smime -sign -signer *.pem -nodetach -binary -noattr -outform DER -in fileToSign -out
有必要使用 GoLang 在 Debian 中创建一个目录并在其中创建文本文件,为此我编写了以下程序:
package main
import(
"os"
"log"
)
func main(){
err := os.Mkdir("/home/log_mail/", 0644)
if err != nil {
log.Printf("%v", err)
}
_,err = os.Create("/home/log_mail/log_main.txt")
if err != nil {
log.Printf("%v", err)
}
}
程序只有在root下启动才能正常运行,很好,正常启动的时候会报错
$去运行main.go
2018/08/02 11:11:37 mkdir /home/log_mail/: 权限被拒绝
2018/08/02 11:11:37 打开/home/log_mail/log_main.txt:没有这样的文件或目录
需要在 Debian 上安装和配置 metacity
在安装 metacity 并删除 compiz 和 openbox 之后
sudo apt-get install metacity
sudo apt-get remove compiz-core
sudo apt-get remove openbox
你需要运行命令
metacity --replace
但抛出错误
Window manager error: Unable to open X display
您需要使用 go 运行 linux 的控制台命令
mail -s "Thema" mgeorgim33@gmail.com < f1
我不知道该怎么做
cmd := exec.Command( "mail","-s",`"Thema" mgeorgim33@gmail.com < f1` )
cmd.Run()
f1 - 消息文本文件
需要将Web应用程序转移到服务器上(服务器上安装了debian),在nginx上设置虚拟主机时出现问题
ls -l
目录的输出/etc/nginx/site-*
:
/etc/nginx/sites-available:
итого 8
-rw-r--r-- 1 root root 2662 июл 23 18:17 basism.zahp
-rw-r--r-- 1 root root 2977 июл 23 18:26 default
/etc/nginx/sites-enabled:
итого 0
lrwxrwxrwx 1 root root 38 июл 23 18:02 basism.zahp -> /etc/nginx/sites-available/basism.zahp
lrwxrwxrwx 1 root root 34 июл 23 15:18 default -> /etc/nginx/sites-available/default
文件basism.zahp
:
server {
listen 80;
listen [::]:80;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/basism.zahp;
#index index.html index.htm index.php;
index index.html index.htm;
server_name basism.zahp www.basism.zahp;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
#proxy_send_timeout 65s; #enable for old
#proxy_read_timeout 65s; #enable for old
}
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ { #php enable for old
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# # With php-cgi (or other tcp sockets):
# # fastcgi_pass 127.0.0.1:9000;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
location /login {
proxy_pass http://127.0.0.1:1323;
}
location /logout {
proxy_pass http://127.0.0.1:1323;
}
}
输出ls-l /var/www/basism.zahp/
:
-rw-r--r-- 1 root root 1788 июл 23 18:07 asset-manifest.json
-rw-r--r-- 1 root root 636 июл 23 18:07 dialog-polyfill.css
-rw-r--r-- 1 root root 25289 июл 23 18:07 dialog-polyfill.js
-rw-r--r-- 1 root root 96758 июл 23 18:07 favicon.ico
-rw-r--r-- 1 root root 660 июл 23 18:07 index.html
-rw-r--r-- 1 root root 293 июл 23 18:07 manifest.json
-rw-r--r-- 1 root root 4750 июл 23 18:07 service-worker.js
drwxr-xr-x 5 root root 4096 июл 23 18:07 static
在浏览器中输入时http://basism.zahp/
,无法访问该站点
在学习django的时候,我写了一个handler,根据一定的条件从数据库中选择信息,条件的数量可以从0到3,条件必须通过request
def get_washings(request):
washings = Washing.objects.all()
campus = request.GET.get('campus')
if campus is not None:
washings = washings.filter(campus_case = campus)
empty = request.GET.get('is_empty')
if empty is not None:
washings = washings.filter(is_empty = empty)
status = request.GET.get('status')
if status is not None:
washings = washings.filter(status = status)
return render(request, 'washing/washings.html', {'washings': washings})
对此处理程序的调用在url.py
urlpatterns = [
url(r'^washing/show/$', views.get_washings, name = 'washing'),
]
作为一个选项,记录被使用
url(r'^washing/show/<int:campus>/<int:status>/<int:is_empty>/$', views.get_washings, name = 'washing')
但我不能从浏览器调用这个处理程序,即 被叫时
http://127.0.0.1:8000/washing/?campus=1&is_empty=0&status=0/
或者
一个错误:
找不到页面 (404) 请求方法:GET 请求 URL: http: //127.0.0.1 :8000/washing/?campus=1&is_empty=0&status=0/ 使用 application.urls 中定义的 URLconf,Django 尝试了这些 URL 模式,在这个命令:
^调试/管理/ ^accounts/login/$ [name='login'] ^accounts/profile/$ ^washing/show/$ [name='washing'] ^washing/one/$ [name='one_washing']当前路径,washing/,与其中任何一个都不匹配。
您看到此错误是因为您的 Django 设置文件中有 DEBUG = True 。将其更改为 False,Django 将显示标准 404 页面
.
您需要解析字符串,为此您需要找到字符位置
^
我使用这段代码执行此操作
pos = 0;
if( pos = part.find( "^" ) != std::string::npos )
{
n = atoi( part.substr( pos + 1 ).c_str() );
}
输入字符串时
2*x
或者
x^2
此代码像时钟一样工作(充分找到标志的位置或缺失),但如果您输入
2*x^2
然后pos
变为等于 1,虽然它应该等于 3
有必要为Linux编写一个python脚本,脚本的任务之一是将受密码保护的档案解压到一个文件夹中,以便进一步处理这些文件(我刚刚拿起python)下面是脚本:
from subprocess import call
call( "unzip -P infected 'arch0.zip' -d all/" )
错误文字:
回溯(最后一次调用):文件“Clam.py”,第 6 行,在 z.extractall() 文件“/usr/lib/python2.7/zipfile.py”,第 1040 行,在 extractall self.extract(zipinfo , path, pwd) File "/usr/lib/python2.7/zipfile.py", line 1028, in extract return self._extract_member(member, path, pwd) File "/usr/lib/python2.7/zipfile. py”,第 1082 行,在 _extract_member 中,以 self.open(member, pwd=pwd) 作为源,\文件“/usr/lib/python2.7/zipfile.py”,第 990 行,打开“提取所需的密码” %name RuntimeError: 文件已加密,提取需要密码
回答
import zipfile
zipcheck = zipfile.is_zipfile('./test.zip')
if zipcheck == True:
z = zipfile.ZipFile('./test.zip', 'r')
z.extractall( pathToDir, pwd = 'password' )
z.close()
else:
print('Not valid ZIP')
在 UNIX 系统中,有一项关于 C 编程的任务:
只用fork创建一个并行进程,通过管道组织进程间的信息交换,父进程循环从管道读取,直到遇到文件末尾(子进程可以向管道写入信息)它从标准输入流中读取)。
这是程序的文本:
int main(int argc, char *argv[])
{
int fd[2];
pid_t pid;
char buf;
pipe( fd );
switch( fork() ){
case -1:
perror( "fork()" );
exit( 1 );
case 0:
close(fd[0]);
while (read(0, &buf, 1) > 0) {
write(fd[1], &buf, 1);
}
write(1, "Death child\n", 12);
close(fd[1]);
break;
default:
close(fd[1]);
while (read(fd[0], &buf, 1) > 0) {
write(1, &buf, 1);
}
write(1, "Death parent\n", 12);
close(fd[0]);
wait(NULL);
break;
}
}
我完全反汇编了它(在我看来,我做了一些改变,使代码更容易理解)。但我无法弄清楚 1.Why 在子循环的每次迭代之后:
while (read(0, &buf, 1) > 0) {
write(fd[1], &buf, 1);
}
在父母中:
while (read(fd[0], &buf, 1) > 0) {
write(1, &buf, 1);
}
我要切换到另一个进程(父进程或子进程)吗?2.如何避免无休止地等待父进程从空管道中读取?
如何在 servlet(Java 语言)中处理 html 页面上的按钮单击。在页面上显示一个按钮并尝试处理按下此按钮
case 2:
response.getWriter().println( " <p>\n" +
"<input type=submit value=\"Registration Car\">\n" +
" </p>" );
while( request.getParameter( "Registration Car" ) !=null )
response.sendRedirect( "/regCar" );
break;
结果,它不起作用...
当链接到 Java 中的数据库并使用getCriteriaBuilder
java.lang.IllegalArgumentException:不是实体:类 DataBase.entity.PlaceTable
这定义了一个类PlaceTable
:
@Entity
@Table( name = "place" )
public class PlaceTable {
@Id
@Column( name = "idplace" )
private int placeId;
@Column( name = "idparking")
private String parkingId;
@Column( name = "car" )
private boolean flagCar;
@Column( name = "bike" )
private boolean flagBike;
@Column( name = "truck" )
private boolean flagTruck;
@Column( name = "bus" )
private boolean flagBus;
@Column( name = "flag" )
private boolean empty;
@Column( name = "idcar" )
private String carId;
@Column( name = "timeBegin")
private int timeBegin;
这是对数据库的调用
public ArrayList<PlaceTable> getWithCriteria( String field, String value ) throws HibernateException{
CriteriaBuilder builder = session.getCriteriaBuilder();
CriteriaQuery<PlaceTable> query = builder.createQuery(PlaceTable.class);
Root<PlaceTable> root = query.from( PlaceTable.class );
query.select(root).where(builder.equal( root.get( field ), value ) );
Query<PlaceTable> q = session.createQuery(query);
return ( ArrayList<PlaceTable> )q.getResultList();
}
上线抛出这个异常Root<PlaceTable> root = query.from( PlaceTable.class );
使用以下方法连接到数据库:
private static final String hibernate_show_sql = "true";
private final SessionFactory sessionFactory;
private static final String DB_DIALECT = "org.hibernate.dialect.MySQL5Dialect";
private static final String DB_DRIVER = "com.mysql.jdbc.Driver";
private static final String DB_URL = "jdbc:mysql://localhost:3306/mydb?useSSL=false";
private static final String DB_USERNAME = "root";
private static final String DB_PASSWORD = "geo";
public DBService() {
Configuration configuration = getMySqlConfiguration();
sessionFactory = createSessionFactory(configuration);
}
@SuppressWarnings("UnusedDeclaration")
private Configuration getMySqlConfiguration() {
Configuration configuration = new Configuration();
configuration.addAnnotatedClass(ParkingTable.class);
configuration.addAnnotatedClass(CarTable.class);
configuration.setProperty("hibernate.dialect", DB_DIALECT );
configuration.setProperty("hibernate.connection.driver_class", DB_DRIVER );
configuration.setProperty("hibernate.connection.url", DB_URL );
configuration.setProperty("hibernate.connection.username", DB_USERNAME );
configuration.setProperty("hibernate.connection.password", DB_PASSWORD );
configuration.setProperty("hibernate.show_sql", hibernate_show_sql );
return configuration;
}
上有一个数据库localhost:3306
,当尝试连接时,抛出异常:
org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
连接创建:
public DBService()
{
Configuration configuration = getMySqlConfiguration();
sessionFactory = createSessionFactory(configuration);
}
获取MySqlConfiguration()
private Configuration getMySqlConfiguration() {
Configuration configuration = new Configuration();
configuration.addAnnotatedClass(ParkingTable.class);
configuration.addAnnotatedClass(CarTable.class);
configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
configuration.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
configuration.setProperty("hibernate.connection.url", "jdbc:mysql://localhost:3306/mydb");
configuration.setProperty("hibernate.connection.username", "root");
configuration.setProperty("hibernate.connection.password", "geo");
configuration.setProperty("hibernate.show_sql", hibernate_show_sql);
return configuration;
}
prom
列出了所有依赖项。