2023年12月4日 星期一

2023年12月1日 星期五

javascript, python

package的入口>>

js:

index.js

py:

__init__.py
-------------------------------------------
import 的差異>>

js:

impot {...} from '...'

import XX as XX from '...'

py:

import package as nickName

import dir.package

from package import component

-------------------------------------------

 檔案當前路徑>>

py:

os.getcwd() 

php:

$_SERVER['PHP_SELF'], __FILE__

-------------------------------------------

專案當前路徑>>

-------------------------------------------

數值類型>>

js:

typeof(...)

py:

type(...)

php:

gettype()

-------------------------------------------

undefined, null>>

js:

... == null

typeof(...) == 'undefined'

py:

... is None

php:

isset(...), empty(...), is_null(...)

-------------------------------------------

2023年11月4日 星期六

game

http://www.k73.com/down/psp/3854.html http://www.k73.com/down/psp/2049.html http://www.k73.com/down/psp/1810.html http://www.k73.com/down/psp/1726.html http://www.k73.com/down/psp/1700.html http://www.k73.com/down/psp/971.html http://www.k73.com/down/psp/975.html http://www.k73.com/down/psp/866.html http://www.k73.com/down/psp/821.html http://www.k73.com/down/psp/755.html http://www.k73.com/down/psp/754.html http://www.k73.com/down/psp/717.html http://www.k73.com/down/psp/467.html http://www.k73.com/down/psp/4148.html http://www.k73.com/down/psp/4257.html http://www.k73.com/down/psp/4252.html http://www.k73.com/down/psp/4373.html http://www.k73.com/down/psp/4370.html http://www.k73.com/down/psp/4405.html http://www.k73.com/down/psp/4399.html http://www.k73.com/down/psp/4442.html http://www.k73.com/down/psp/4451.html http://www.k73.com/down/psp/4703.html -http://www.k73.com/down/psp/4632.html -http://www.k73.com/down/psp/4483.html http://www.k73.com/down/psp/7097.html http://www.k73.com/down/psp/6919.html http://www.k73.com/down/psp/7078.html http://www.k73.com/down/psp/7304.html http://www.k73.com/down/psp/7327.html http://www.k73.com/down/psp/7089.html http://www.k73.com/down/psp/7077.html http://www.k73.com/down/psp/7357.html http://www.k73.com/down/psp/8385.html http://www.k73.com/down/psp/8150.html -http://www.k73.com/down/psp/8519.html -http://www.k73.com/down/psp/9191.html http://www.k73.com/down/psp/11817.html http://www.k73.com/down/psp/11872.html http://www.k73.com/down/psp/12524.html http://www.k73.com/down/psp/13217.html http://www.k73.com/down/psp/13038.html http://www.k73.com/down/psp/13459.html http://www.k73.com/down/psp/15474.html http://www.k73.com/down/psp/14921.html -http://www.k73.com/down/psp/17799.html -http://www.k73.com/down/psp/19344.html http://www.k73.com/down/psp/25980.html http://www.k73.com/down/psp/29341.html http://www.k73.com/down/psp/37114.html http://www.k73.com/down/psp/29400.html http://www.k73.com/down/psp/47660.html --------------------------------------------- http://www.k73.com/down/psp/160153.html http://www.k73.com/down/psp/66468.html http://www.k73.com/down/psp/66580.html

2023年10月20日 星期五

atom keybind

 # Your keymap
#
# Pulsar keymaps work similarly to style sheets. Just as style sheets use
# selectors to apply styles to elements, Pulsar keymaps use selectors to associate
# keystrokes with events in specific contexts. Unlike style sheets however,
# each selector can only be declared once.
#
# You can create a new keybinding in this file by typing "key" and then hitting
# tab.
#
# Here's an example taken from Pulsar's built-in keymap:
#
# 'atom-text-editor':
#   'enter': 'editor:newline'
#
# 'atom-workspace':
#   'ctrl-shift-p': 'core:move-up'
#   'ctrl-p': 'core:move-down'
#
# You can find more information about keymaps in these guides:
# * https://pulsar-edit.dev/docs/launch-manual/sections/using-pulsar/#customizing-keybindings
# * https://pulsar-edit.dev/docs/launch-manual/sections/behind-pulsar#keymaps-in-depth
#
# If you're having trouble with your keybindings not working, try the
# Keybinding Resolver: `Cmd+.` on macOS and `Ctrl+.` on other platforms. See the
# Debugging Guide for more information:
# * https://pulsar-edit.dev/docs/launch-manual/sections/core-hacking/#check-your-keybindings
#
# This file uses CoffeeScript Object Notation (CSON).
# If you are unfamiliar with CSON, you can read more about it in the
# Pulsar Launch Manual:
# https://pulsar-edit.dev/docs/launch-manual/sections/using-pulsar/#configuring-with-cson

'atom-text-editor':
  "ctrl-space": "unset!"
  'alt-/': 'autocomplete-plus:activate'

2022年8月22日 星期一

php 命令模式(路徑問題)


// 校正命令模式的 dir
chdir(__DIR__);

function is_cli() {
  if (php_sapi_name() === 'cli') {
    return true;
  }
  if (defined("STDIN")) {
    return true;
  }
  if (!isset($_SERVER["REMOTE_ADDR"]) || empty($_SERVER["REMOTE_ADDR"])) {
    return true;
  }
  return false;
}

php include, require 路徑問題

 PHP中include和require絕對路徑、相對路徑問題
-Advertisement-
Play Games
在寫PHP程式時,經常要用到include或require包含其他文件,但是各文件里包含的文件多了之後,就會產生路徑問題。 如下目錄: <web>(網站根目錄) ├<A>文件夾 │ │ │ └1.php ├<B>文件夾 │ │ │ └2.php └index.php 現在根目錄下的index.php ...

在寫PHP程式時,經常要用到include或require包含其他文件,但是各文件里包含的文件多了之後,就會產生路徑問題。

如下目錄:

<web>(網站根目錄)  
 ├<A>文件夾  
 │ │  
 │ └1.php  
 ├<B>文件夾  
 │ │  
 │ └2.php  
 └index.php

現在根目錄下的index.php要包含A文件夾內的1.php文件,則用include "./A/1.php"即可

而1文件夾內的1.php又包含了B文件夾內的2.php,則1.php內寫上include "../B/2.PHP"即可

可是要知道,當index.php包含了1.php之後,編譯是在index.php里進行的

也就是index.php所包含文件里的include都是相對於index.php的

那麼1.php被包含進index.php里了,那麼就要相對於index.php尋找2.php了
而上面說了,1.php里寫的是include "../B/2.php",現在編譯文件已經相對於網站根目錄了(即相對於index.php)
"../"則意味著還要再返回上一級目錄尋找,那麼怎麼會找得到。

在網上也尋找過一些方法,最好的辦法還是都採用絕對路徑方法較妥。
可以定義一個單入口文件,將要包含的文件包含進來
定義一個常量define("__ROOT__",dirname(__FILE__));,那麼在寫後面的文件過程中,只需要採用絕對方式,加上__ROOT__就行了。

require dirname(__FILE__) . '/library/Zend/Loader.php';

2021年8月14日 星期六

(node.js impoet)__filename, __dirname

import { dirname } from 'path';
import { fileURLToPath } from 'url';

const  __filename = fileURLToPath(import.meta.url);

const  __dirname = dirname(__filename)
 

2020年5月28日 星期四

project 對 dom.tree 先廣域搜索指定的節點,再排序

const getCommentLis = {
            main(root) {
                let commentList = [];

                let dataList = [{
                    level: [1],
                    node: root
                }];

                // 位數
                let digit = dataList[0].level.length;

                let i = 0;
                let data;
                while (null != (data = dataList[i++])) {
                    // debugger;

                    const level = data.level;
                    const node = data.node;

                    if (node.tagName != null) {
                        node.childNodes.forEach((child, i) => {
                            let _level = level.slice()
                            _level.push(i + 1);

                            if (_level.length > digit) {
                                digit = _level.length;
                            }

                            dataList.push({
                                level: _level,
                                node: child
                            });
                        });
                    } else {
                        if (node.nodeType == 8) {
                            let parent = node.parentNode;
                            commentList.push({
                                parent: parent,
                                node: node,
                                level
                            });
                        }
                    }
                } // endWhile
                // debugger;
                console.dir(commentList);

                commentList.sort((a, b) => {
                    if (Array.isArray(a.level)) {
                        a.level = this.getLevel(digit, a.level);
                    }

                    if (Array.isArray(b.level)) {
                        b.level = this.getLevel(digit, b.level);
                    }

                    return (a.level - b.level);
                });

                console.dir(commentList);
                return commentList;
            },
            getLevel(digit, level) {
                debugger;
                let j = digit - level.length;

                // debugger;
                // 基數
                let p = 1;
                for (let i = 0; i < j; i++) {
                    p *= 10;
                }

                // debugger;
                let res = 0;
                let num;
                while (null != (num = level.pop())) {
                    res = res + num * p;
                    // 十進位
                    p *= 10;
                }

                return res;
            }
        }