This file contains hidden or 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
// 題目: | |
// 已知存在 random 可以使用 random(x:int,y:int) 會回傳 x~y 的正整數 | |
// 請寫一個 function, 傳入 為 n | |
// 回傳一個隨機的 n 位數, 其中每個位數都要不相等 | |
// e.x 101 => 不允許(1 重複) | |
// 12345=> 允許 | |
// ex, n=2, 10(o), 11(x) …. 98(o), 99(x) | |
function random(x, y) { | |
return Math.floor(Math.random() * (y - x + 1) + x) |
This file contains hidden or 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
// Best algo, minimiz memory usage. | |
// Q 1: | |
// 1. Fib | |
// 1st: 1, | |
// 2nd: 1 | |
// 2, 3, 5, 8, .. | |
// What is 100th Fib? | |
function fib(n) { | |
if (n < 0) throw new Error('Input shall be a non-negative int') |
This file contains hidden or 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
public setSelectedRow( | |
event: MouseEvent | KeyboardEvent, | |
rowTag: string, | |
// turnOffEditable: boolean = true | |
): void { | |
// 1. unselected if select again (this.selectedRow === rowTag) | |
this.selectedRow = this.selectedRow === rowTag ? null : rowTag; | |
// 2. refer to dicomEditModalShortcut component | |
this.selectedElement$.next(<HTMLElement>event.currentTarget); |
This file contains hidden or 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
function helloWord(arg1, collectionUID){ | |
console.log(collectionUID); // undefined | |
collectionUID = "222" | |
console.log(collectionUID); // 222 | |
try { | |
console.log(arg1) | |
console.log(collectionUID) | |
throw new Error("oh no") | |
} catch (error) { |
This file contains hidden or 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
const promise = new Promise((resolve, reject) => { | |
console.log(1); | |
resolve(5); | |
console.log(2); | |
}).then(val => { | |
console.log(val); | |
}); | |
promise.then(() => { | |
console.log(3); |
This file contains hidden or 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 socket | |
import struct | |
import telnetlib | |
HOST = "192.168.1.111" | |
PORT = 2994 | |
s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s1.connect((HOST, PORT)) |
This file contains hidden or 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
#!/usr/bin/env node | |
const { exec } = require("child_process"); | |
exec("code --list-extensions", (err, stdout) => { | |
if (err) { return; } | |
const markdown = stdout.split("\n").filter( e => e ).map(extension => | |
`* [${extension}](https://marketplace.visualstudio.com/items\?itemName\=${extension})` | |
).join("\n"); | |
console.log(markdown); | |
}); |
This file contains hidden or 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
export enum PreprocessStatus { | |
COMPLETE = 'complete', | |
INCOMPLETE = 'incomplete', | |
} | |
export type NA = 'NA'; | |
/** | |
* SeriesRemoteCacheStatus for Series level | |
*/ |
This file contains hidden or 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
using namespace System.Management.Automation.Host | |
Add-Type -AssemblyName System.Device #Required to access System.Device.Location namespace | |
function get-weather{ | |
$GeoWatcher = New-Object System.Device.Location.GeoCoordinateWatcher #Create the required object | |
$GeoWatcher.Start() #Begin resolving current locaton |
This file contains hidden or 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
/** | |
* Inner rounding | |
*/ | |
div { | |
outline: .6em solid #655; | |
box-shadow: 0 0 0 .4em #655; /* todo calculate max of this */ | |
max-width: 10em; | |
border-radius: .8em; |
NewerOlder