小编Ste*_*ker的帖子

Perl regex one line file

I'm using cat to get content of the file, and then I use regex to get what I want. When I change order of if's in example i put PASSWORD as a second one, IP will be empty.

#!/usr/bin/perl
my $param = $ARGV[0];

my $IP;
my $PASSWORD;
my $MODEM;
my @cat = `cat file`;

 foreach my $line (@cat){
    if ($line =~ /$param/){
        if ($line =~ /MODEM:(\w+)/g){ $MODEM = $1; }
        if ($line =~ /IP:((\d{1,3}\.){3}\d{1,3})/g){ $IP = $1; }
        if ($line …
Run Code Online (Sandbox Code Playgroud)

regex perl file

2
推荐指数
2
解决办法
77
查看次数

$ /和本地$ /的区别

对于我的程序,我需要使用FASTA文件并对其进行一些计算。为了做到这一点,我使用local $/ = "^>来将我的文件切成标题行和序列行。虽然我的程序可以执行我想要的操作,但为什么我不能仅仅使用它$/ = "^>"呢?当我尝试它时,我的结果不是我所需要的,我很感兴趣为什么会这样。这是我的简化代码:

my @array;
while(<>){
    local $/ = "^>";
    chomp;
    push (@array, $_);
    if(eof){
        for(@array){
            ...
        }
    ...
    }
    if(eof){
        @array = ();
    }
Run Code Online (Sandbox Code Playgroud)

variables perl global-variables temp

2
推荐指数
2
解决办法
310
查看次数

让 axios 限制响应数量

我正在尝试对 API 进行 axios GET 调用以检索一些 JSON 数据。数据存储在具有多个对象的数组中,每个对象都包含相同的键。该数组中有数百个对象,但我只想返回前十个。我知道数据集返回后我可以将其截断,但我想知道是否有办法限制对 API 调用的响应量。

这是数据集的示例:

[
  {
    "userId": 1,
    "id": 1,
    "title": "The Great Gatsby",
    "author": "F. Scott Fitzgerald"
  },
  {
    "userId": 1,
    "id": 2,
    "title": "1984",
    "author": "George Orwell"
  },
  {
    "userId": 1,
    "id": 3,
    "title": "The Count of Monte Cristo",
    "author": "Alexandre Dumas"
  },
]
Run Code Online (Sandbox Code Playgroud)

我的 axios 请求也很简单:

router.get('/', (req, res) => {
    axios.get(`https://jsonwebsit.info.com/posts`)
        .then( response => {
            res.send(response.data)
        })
        .catch(err => {
            console.log('Error getting all data from API', err)
        })
});
Run Code Online (Sandbox Code Playgroud)

api reactjs axios

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

如何在本地网络上共享laravel项目

我有一个 laravel 项目,它的用户有一个虚拟域,我如何仅在本地网络中发布它

这是我在 httd.vhosts.conf 文件中的配置

<VirtualHost *:80>
    ServerName  smarts.local
    DocumentRoot "C:/xampp/htdocs/smarts/public"
    SetEnv APPLICATION_ENV "development"
    <Directory "C:/xampp/htdocs/smarts/public">
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

这是在我的主机文件中

127.0.0.1     smarts.local
Run Code Online (Sandbox Code Playgroud)

目前它仅适用于我的电脑,但不适用于网络中的其他设备。

php laravel

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

MySQL Query返回"空集",为什么?

为什么以下查询返回空集?

SELECT * 
   FROM null_test_tab 
   WHERE col1 = NULL
   ORDER BY id
Run Code Online (Sandbox Code Playgroud)

结果:

Empty set
Run Code Online (Sandbox Code Playgroud)

mysql sql

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

如何解决perl中"标量的实验值现在被禁止"的问题

在Perl 5.26.2中我得到:

Experimental each on scalar is now forbidden at a.plx line 67.
Type of arg 1 to each must be hash or array (not private variable) at a.plx   
line 67, near "$val)"
Execution of a.plx aborted due to compilation errors.
Run Code Online (Sandbox Code Playgroud)

第67行是其中的

 67 while (my ($ip, $val2) = each($val))
 68 {
       ......
    }
Run Code Online (Sandbox Code Playgroud)

perl

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

图片上传需要大量时间才能保存在数据库中

我遇到一个问题,当我上传图像时,即使只有 1MB,也需要很长时间才能上传。

我的上传过程是首先使用a <input type='file'>,然后将上传的图像转换为base64,将其转换为字节,然后将其以数据类型保存到数据库中image

这是我的 SQL(存储过程):

IF EXISTS(SELECT * FROM VisitationLogs_BVL where UserIdx = @UserIdx and OutletIdx = @OutletIdx and convert(varchar, DateVisited, 23) = convert(varchar, getdate(), 23))
    BEGIN
        SELECT 0 'Result'
    END
ELSE
    BEGIN
        INSERT INTO VisitationLogs_BVL(UserIdx,OutletIdx,CashierUser,IPAddress,Remarks,[Image])
        VALUES(@UserIdx,@OutletIdx,@CashierUser,@IPAddress,@Remarks,@image)
        SELECT @@ROWCOUNT Result, SCOPE_IDENTITY() AssignIdx
    END
Run Code Online (Sandbox Code Playgroud)

html javascript sql-server

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

任务类型不能执行的c#async / await能做什么?

我是C#异步/等待功能的新手,经过研究,我认为我已经很好地理解了这些关键字想要完成的工作。但是我想到这个问题:有些事情使async / await使使用Task类型无法完成的事情成为可能?考虑以下示例:

static async Task<int> jobAsync()
{
    // I could be writing here "await someTask()"
    await Task.Delay(2000);
    return 1;
}

static async void simpleAsync()
{
    int i = await jobAsync();
    Console.WriteLine("Async done. Result: " + i.ToString());
}

static void simpleTask()
{
    var t = Task.Run(() => { 
    //I could be writing here "return someTask();"
    Thread.Sleep(2000); return 1; });
    t.ContinueWith(tsk => { Console.WriteLine("Task done. Result: " + tsk.Result); });
}
Run Code Online (Sandbox Code Playgroud)

现在,两个函数“ simpleTask()”和“ simpleAsync()”给出相同的结果,例如,如果调用Main方法:

static void Main(string[] args)
{
    simpleTask();
    //simpleAsync(); …
Run Code Online (Sandbox Code Playgroud)

c# asynchronous async-await

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