const id = "id1"
const results = { "aaa": { id: "id1", name: "111" }, "bbb": { id: "id1", name: "222" }, "ccc": { id: "id2", name: "333" }}
const array = Object.values(results).filter(result => result.id == id)
console.log(array)
> Array [Object { id: "id1", name: "111" }, Object { id: "id1", name: "222" }]
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
function get(){ | |
const response = UrlFetchApp.fetch("https://www.tranbi.com/buy/list/?prill=&priul=2500000&srl=&sru=&proll=&proul=&sd=1&sin=1&ft=&sort=-open_datetime&page_size=30"); | |
const entries = Parser.data(response.getContentText()).from('<div class="buyListContents">').to('<div class="buyListBtn">').iterate(); | |
const sheet = SpreadsheetApp.getActiveSheet(); | |
const range = sheet.getRange('A2'); | |
const currentID = range.getValue(); | |
const newEntries = [] | |
entries.some(entry => { |
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
// 1.昇順の順番に沿って挿入する | |
const a = [11, 22, 33, 44, 55, 66, 77, 88, 99] | |
let b = 50 | |
let index = a.findIndex(v => v > b) | |
index < 0 ? a.push(b) : a.splice(index, 0, b) | |
console.log(a) | |
// output: | |
// > Array [11, 22, 33, 44, 50, 55, 66, 77, 88, 99] |
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
// 順番の乱れたobjectをkeyでsortする | |
const object1 = { | |
a: 'somestring', | |
c: false, | |
b: 42 | |
}; | |
console.log(Object.keys(object1)); | |
// expected output: Array ["a", "c", "b"] | |
// これをa,b,cの順で処理したい |
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
/** | |
* @param {String} uid firebase/authentication のユーザーID | |
*/ | |
checkStatus ({ commit, state }, uid) { | |
return new Promise(resolve => { | |
firestore.collection('users').doc(uid) | |
.onSnapshot(doc => { | |
// usersコレクションにレコードがあるかチェック | |
const user = doc.exists ? doc.data() : null | |
// もし管理者権限が無ければログイン画面に飛ばす |
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
<script> | |
const url1 = 'https://www.facebook.com/profile.php?id=100012461591178' // has number id | |
const url2 = 'https://www.facebook.com/takmurat' // has string id | |
const url3 = 'https://www.facebook.com/groups/155076295120010' // has group id | |
const url4 = 'https://www.facebook.com' | |
const url5 = 'https://www.facebook.com/' | |
const url6 = 'https://www.facebook.com//' | |
// split | |
console.log(url1.split('/')) |
sudo rm -rf node_modules
npm lsでエラーが出るとき
ex.
/Users/cometqp
├── vue@2.6.10
├── UNMET PEER DEPENDENCY webpack@^2.0.0 || ^3.0.0 || ^4.0.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
# 重複しないよう_をプリフィックス、ファイル名にスペースがあると失敗する | |
for i in *.png;do mv $i _$i;done | |
# リネーム | |
# 0.png,1.png,...となるようリネーム | |
CNT=0;for i in *.png;do mv $i $CNT.png;CNT=$((CNT+1));done | |
# ファイル作成日yyyy-mm-dd-hh:mm:ss.pngにリネーム | |
for i in *.png;do stat $i | grep 'Access: 20.*' | cut -d' ' -f2,3| cut -d'.' -f1 | sed 's/ /-/g' | xargs -I{} mv $i {}.png;done | |
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 java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.util.*; | |
import java.math.*; | |
/* | |
sample input |
NewerOlder