鍍金池/ 問答/ Linux問答
眼雜 回答

思路:

  1. 確認(rèn)matchArr在oddEven的位置,比如1,10,20
  2. 根據(jù)上面獲取的位置,取出number里的數(shù)據(jù),最后拼接

實現(xiàn):

$numbers = ['17', '38', '12', '40', '20', '47', '45', '22', '02', '19', '29', '10', '27', '41', '26', '47', '18', '24', '22', '27', '33', '47', '25', '09', '16', '32', '01', '28', '18', '38'];


// 單雙數(shù)組
$oddEven = ['1', '2', '2', '2', '2', '1', '1', '2', '2', '1', '1', '2', '1', '1', '2', '1', '2', '2', '2', '1', '1', '1', '1', '1', '2', '2', '1', '2', '2', '2'];
$oddEvenStrs = implode("", $oddEven);

// 匹配數(shù)組
$matchArr = ['1', '2', '2', '2'];
$matchArrStrs = implode("", $matchArr);

var_dump($oddEvenStrs);
var_dump($matchArrStrs);

    var_dump(count($numbers));

function findIt($from, $find, $numbers, $pos) 
{
    $result = '';
    $pos = strpos($from, $find, $pos);
    if ($pos !==  false) {
        $result .= implode(",", array_slice($numbers, $pos, 4));
        $pos += 4;
    }
    
    if (count($numbers) > $pos)
    {
        return $result . "," . findIt($from, $find, $numbers, $pos);
    }
    
    return $result;
}

$result = findIt($oddEvenStrs, $matchArrStrs, $numbers, 0);

echo $result;

var_dump(explode(",", $result));
入她眼 回答

mounted window.addEventListener("scroll", func)
destroyed window.removeEventListener("scroll", func)

久愛她 回答

問題的原因找到了:

  • 首先是要排除代碼中的基本警告和錯誤,確保基本的邏輯運(yùn)行;
  • 然后就是檢查代碼有無 死循環(huán)遞歸導(dǎo)致的棧溢出;

我的代碼是因為存在 遞歸導(dǎo)致的棧溢出,進(jìn)而導(dǎo)致視圖布局出錯。我的項目中存在一個側(cè)邊菜單,我使用當(dāng)前路由對象的 matched 數(shù)組進(jìn)行菜單比對,結(jié)果導(dǎo)致了棧溢出。

最終的解決辦法是:在比對菜單的時候優(yōu)先比對路徑(path),如果路徑一致,則繼續(xù)比對參數(shù)(query),修改后的代碼僅有10幾次循環(huán)操作,頁面在沒出現(xiàn)嵌套出錯的情況了。類似查找某人,先排除姓、再排除名,最后確認(rèn)性別,逐漸縮小循環(huán)的層級。

寫榮 回答

已解決:

import threading

import time

def test1():
    while True:
        print '111111111111'
        time.sleep(2)

def test2():
    while True:
        print '22222222222'
        time.sleep(10)
        print '222222222222end'
        break
    return

def test3():
    thread_list_all = threading.enumerate()
    while True:
        thread_list1 = threading.enumerate()
        thread_list_number = len(thread_list1)
        if thread_list_number < 4:
            dead_thread = list(set(thread_list_all).difference(set(thread_list1)))
            for item_thread in dead_thread:
                fun_name = item_thread.getName()
                if fun_name == 'test1':
                    t1 = threading.Thread(target=test1,name='test1')
                    t1.start()
                    t1.join()
                elif fun_name == 'test2':
                    t2 = threading.Thread(target=test2,name='test2')
                    t2.start()
                    t2.join()
        time.sleep(1)

t1 = threading.Thread(target=test1,name='test1')
t2 = threading.Thread(target=test2,name='test2')

while True:
    if t1.isAlive() is False:
        t1 = threading.Thread(target=test1,name='test1')
        t1.start()
        # t1.join()
    if t2.isAlive() is False:
        t2 = threading.Thread(target=test2,name='test2')
        t2.start()
        # t2.join()
乖乖噠 回答

監(jiān)聽127.0.0.1就好了。ddos和這個沒關(guān)系,要看具體是ddos什么

風(fēng)畔 回答

圖片描述

crtl + shift + p 輸入liveReload 點(diǎn)擊下是看看,我之前也是這個問題

清夢 回答

應(yīng)用創(chuàng)建的文件并不繼承應(yīng)用程序本身的所有者和所有組,而是繼承進(jìn)程的所有者。
一般來說,誰啟動這個程序,那么程序創(chuàng)建的文件的所有者就是誰。
當(dāng)然有個別程序為了安全,在啟動以后會降權(quán),比如nginx。通俗的說,就是使用root啟動nginx以后,nginx會在獲取到需要的資源以后,把自己設(shè)置為普通用戶權(quán)限,因此nginx創(chuàng)建的文件的所有者應(yīng)該也是普通用戶。

PS: 查看進(jìn)程的所有者可以使用top或者ps

top:
clipboard.png

ps:

clipboard.png

假灑脫 回答
>&2 echo "error"

意思是將標(biāo)準(zhǔn)錯誤重定向到標(biāo)準(zhǔn)輸入.

六扇門 回答

svn diff -r ?

陌璃 回答

ifconfig eth0 |grep -i hwaddr|sed "s/.*HWaddr[[:space:]]\+\([a-z0-9\:]*\).*/\1/"

茍活 回答

你源碼根目錄不是有個server.js 文件嗎,把他仍在服務(wù)器才可以。。。。github pages 不能跑node,我這個可能會對你有幫助https://github.com/forzeny/Mu...

假灑脫 回答

JS文件加載完畢后,
第一步,文件中root級的、并且沒有使用任何關(guān)鍵字定義的變量 ,被當(dāng)做全局變量優(yōu)先賦值。
第二步,所有單獨(dú)定義的function xxx()聲明生效
第三步,其他部分按照js中寫的代碼邏輯,開始順序執(zhí)行

文件加載過程中,內(nèi)容還不全,不涉及到變量和函數(shù)聲明的處理。

吃藕丑 回答

ubuntu可以讀取ntfc格式的分區(qū),所以可以操作(我之前有一些windows下的頑固文件實在ubuntu下刪除的),但是windows默認(rèn)不識別ext文件系統(tǒng)

尛曖昧 回答

如果用匿名代理的話,你肯定拿不到攻擊者真實IP的,我覺得用匿名代理應(yīng)該是黑客的基本素質(zhì)吧。

真難過 回答

:hi SpellBad ctermbg=yellow

還可以設(shè)置下劃線,前景色什么都可以,如果設(shè)置亂了,可以用
:hi clear SpellBad
清掉從頭來過

陪妳哭 回答

首先 json_decode($data, TRUE),之后直接取$data['restaurant']['dishes-select']['options'], 如果你非要循環(huán),那就用遞歸函數(shù)

離殤 回答

nginx 可以由一個特殊的 X-Accel-Redirect 頭部控制資源訪問。

所以可以直接 proxy_pass 到 upstream, upstream 根據(jù)請求動態(tài)生成文件路徑,添加到X-Accel-Redirect: /path/to/file 頭部,nginx取回上游返回后,內(nèi)部跳轉(zhuǎn)/path/to/file, 這是一個內(nèi)部跳轉(zhuǎn),外部不可見的,你還可以添加 internal 指令控制該文件不可直接訪問。

網(wǎng)妓 回答

服務(wù)端加上一個允許跨域的響應(yīng)頭就好了