gaiety / date-time-bash.sh
0 likes
0 forks
1 files
Last active
Simple variables for the current date and time, great to include in logs for small scripts
1 | currentDate=$(date +"%m_%d_%Y") |
2 | currentTime=$(date +"%T") |
3 | |
4 | echo "Hello! It is $currentTime on the $currentDate" >> my-log.log |
gaiety / userIsTypingStuff.js
0 likes
0 forks
1 files
Last active
Hack for JavaScript check to see if the user might be typing somewhere
1 | let userIsTypingStuff = document.querySelectorAll('input:focus, textarea:focus').length !== 0; |
gaiety / JS Map, easier than hash, reduces loops
0 likes
0 forks
1 files
Last active
1 | let myHugeArray = [...Array(10000).keys()].map(id => { return {id}; }); |
2 | let listIWant = [1010, 2020, 3030, 4040, 5050, 6060, 7070, 8080, 9090]; |
3 | |
4 | // INSTEAD OF: |
5 | myHugeArray.filter(obj => listIWant.includes(obj.id)); |
6 | |
7 | // TRY: |
8 | let mapIWant = new Map(); |
9 | listIWant.forEach(id => mapIWant.set(id)); |
10 | myHugeArray.filter(obj => mapIWant.has(obj.id)); |
Newer
Older