Skip to content

Instantly share code, notes, and snippets.

View sorie's full-sized avatar
💭
I may be slow to respond.

lala sorie

💭
I may be slow to respond.
View GitHub Profile
@sorie
sorie / gist:46c437f0400d9dad8d598731e8c6ae05
Created July 1, 2021 09:00
navigator.mediaDevices.enumerateDevices() will return an empty label
/**
navigator.mediaDevices.enumerateDevices() will return an empty label attribute value
if the permission for accessing the mediadevice is not given.
Try using it after getUserMedia.
**/
(async () => {
await navigator.mediaDevices.getUserMedia({audio: true, video: true});
let devices = await navigator.mediaDevices.enumerateDevices();
console.log(devices);
@sorie
sorie / gist:ac2a8acf106e3b4387955289aec7385c
Created July 2, 2021 05:14
ES6 (2015) ~ ES11(2020) 핵심정리
//Shorthend property names
//변수명과 키값이 같은 경우 생략이 가능하다.
const name = 'Sori';
const age = '32';
const sori = {
name: name,
age: age
};
let constraints = {video: true};
(async () => {
try{
await navigator.mediaDevices.getUserMedia(constraints).then(function (param, streams) {
throw error
if (getLocalStream) {
/*mediaDevices체크 */
let videoTracks = streams.getVideoTracks();
let audioTracks = streams.getAudioTracks();
console.log('dev test selected camera : ' + videoTracks[0].label);
@sorie
sorie / gist:7f48c8b83184bec68f47da7e458ab031
Created July 10, 2021 09:26
vs code powershell 에서 PSSecurityException에러를 만났을 때
에러이유 : 관리자가 아닌 ms 계정으로 로그인한 윈도우10에서 Visual Studio Code 에서 Vue 개발환경을 설정하던 중 보안 오류가 발생함.
해결방법 :
d:\sori> Get-ExecutionPolicy -Scope CurrentUser
d:\sori> Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
d:\sori> Get-ExecutionPolicy -List
관련문서
https://docs.microsoft.com/ko-kr/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7
@sorie
sorie / nullish-coalescing.js
Last active August 12, 2021 00:51
javascript : nullish-coalescing
//nullidh coalescing operator ?? is only case null, undefined check.'
//do not confusing to Logical OR operator || is only case false(0, undefined, null, "",'',``) or true check.
//bad code
function printMessage(test){
let message = text;
if(text == null || text == undefined) {
message = 'Nothing to display';
}
console.log(message);
@sorie
sorie / ternary-operator.js
Created August 12, 2021 00:41
javascript tip : ternary operator
//bad code
function getResult(score) {
let result;
if(score > 5) {
result = 'up';
} else if (score <= 5) {
result = 'down';
}
return result;
}
@sorie
sorie / object-destructuring.js
Created August 12, 2021 00:57
javascript tip : object destructuring
//Object Destructuring
const person = {
name = 'Julia',
age = 20,
phone: '0102222222'
};
//bad code
function displayPerson(person){
displayAvatar(person.name);
@sorie
sorie / spread-syntax.js
Created August 12, 2021 01:10
javascript tip : Spread Syntax - Object,array
//Spread Syntax - Object
const item = { type: 'shirts', size : 'M' };
const detail = { price: 20, made: 'Kores', gender: 'M' };
//bad code
item['price'] = detail.price;
//bad code
const newObject = new Object;
newObject['type'] = itme.type;
@sorie
sorie / optional-chaining.js
Created August 12, 2021 01:39
javascript tip : optional chaining
const bob = {
name: 'Julia',
age: 20,
};
const anna = {
name: 'Julia',
age: 20,
job: {
title: 'Software Engineer'
}
@sorie
sorie / template-literals.js
Created August 12, 2021 01:44
javascript tip : template-literals.
//Template Literals (Template String)
const person = {
name: 'Julia',
score: 4,
};
//bad code
console.log(
'Hello ' + person.name + ', Your current score is: ' + person.score
);