This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
AssetDefinition, | |
UrlParams, | |
UrlQueryParams, | |
AssetReference, | |
} from './lazy-load-assets.interface'; | |
import { LazyLoadAsset } from './lazy-load-constants'; | |
import { LazyLoadAssetEnum } from './lazy-load-assets.enum'; | |
function attachDom(dom: any, selector: string = 'head'): Promise<any> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// Dummy icons. | |
// TODO: please replace by correct svg icon. | |
var circle = | |
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><defs><style>.a{fill:#4d4d4d;}</style></defs><title>circle</title><path class="a" d="M17.15,7.15a2.83,2.83,0,0,0-1.62.51L12.32,4.44a2.8,2.8,0,0,0,.51-1.61,2.83,2.83,0,1,0-5.66,0,2.8,2.8,0,0,0,.51,1.61L4.47,7.66a2.83,2.83,0,1,0,0,4.62l3.21,3.21a2.83,2.83,0,1,0,4.62,0l3.21-3.21a2.78,2.78,0,0,0,1.63.52,2.83,2.83,0,0,0,0-5.65ZM10,14.29a2.81,2.81,0,0,0-1.6.5L5.18,11.58A2.87,2.87,0,0,0,5.68,10a2.78,2.78,0,0,0-.51-1.61L8.38,5.14a2.83,2.83,0,0,0,3.24,0l3.21,3.22A2.78,2.78,0,0,0,14.32,10a2.87,2.87,0,0,0,.5,1.61L11.61,14.8A2.8,2.8,0,0,0,10,14.29ZM10,1A1.84,1.84,0,1,1,8.16,2.83,1.84,1.84,0,0,1,10,1ZM2.85,11.81A1.84,1.84,0,1,1,4.69,10,1.83,1.83,0,0,1,2.85,11.81ZM10,19a1.84,1.84,0,1,1,1.84-1.84A1.85,1.85,0,0,1,10,19Zm7.15-7.15A1.84,1.84,0,1,1,19,10,1.84,1.84,0,0,1,17.15,11.81Z"/></svg>'; | |
var nebula = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"> | |
<title>ma |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
try: | |
user_path = os.path.expanduser('~') | |
if not os.path.exists(os.path.join(user_path, 'test_dir')): | |
os.makedirs(os.path.join(user_path, 'test_dir')) | |
else: | |
print(f'{os.path.join(user_path, "test_dir")} is exists.') | |
except Exception as e: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import os.path | |
# batch rename | |
def batch(work_path, old_ext, new_ext, recursive=False): | |
if os.path.isdir(work_path): | |
for file in os.listdir(work_path): | |
full_path = os.path.join(work_path, file) | |
if os.path.isdir(full_path) and recursive: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
message = 'Hi, 這是我針對不同編碼所做的小程序.' | |
# 字串轉 unicode | |
message_unicode = [ord(c) for c in message] | |
message_unicode_chr = [chr(c) for c in message_unicode] | |
print(message_unicode) | |
print(message_unicode_chr) | |
# unicode 轉 2 進制 | |
message_bin = [bin(c) for c in message_unicode] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python練習題問題如下: | |
# 已知有一個已經排好序的數組。要求是,有一個新數據項,要求按原來的規律將它插入數組中。 | |
# Python解題思路分析: | |
# 首先,判斷此數是否大於最後一個數; | |
# 然後再考慮插入中間的數的情況,插入後此元素之後的數,依次向後移動一個位置。 | |
def insert(n): | |
a = [1, 4, 6, 9, 13, 16, 19, 28, 40, 100, 0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Python練習題問題如下: | |
// 已知有一個已經排好序的數組。要求是,有一個新數據項,要求按原來的規律將它插入數組中。 | |
// Python解題思路分析: | |
// 首先,判斷此數是否大於最後一個數; | |
// 然後再考慮插入中間的數的情況,插入後此元素之後的數,依次向後移動一個位n置。 | |
function insert(n) { | |
var a = [1, 4, 6, 9, 13, 16, 19, 28, 40, 100, 0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Python練習題問題如下: | |
// 求一個3*3矩陣對角線元素之和 | |
// Python解題思路分析: | |
// 解此題要利用雙重for循環控制輸入二維數組; | |
// 再將a[i][i]累加後輸出。 | |
// [0][0] + [1][1] + [2][2] 之和 | |
function random() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python練習題問題如下: | |
# 求一個3*3矩陣對角線元素之和 | |
# Python解題思路分析: | |
# 解此題要利用雙重for循環控制輸入二維數組; | |
# 再將a[i][i]累加後輸出。 | |
# [0][0] + [1][1] + [2][2] 之和 | |
from random import randint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Python解題思路分析: | |
// 首先可以利用選擇法,即從9個數據進行比較過程中,先選擇一個最小的與第一個元素交換。之後以此類推,即用第二個元素與後8個進行比較,並進行交換。 | |
function random() { | |
return Math.floor(Math.random() * 1000 + 1); | |
} | |
var l = Array(10).fill('').map(() => random()); | |
console.log(`Before: [${l.join(', ')}]`); | |
l.sort(); |
NewerOlder