Skip to content

Instantly share code, notes, and snippets.

@dstyle0210
dstyle0210 / media.json
Created September 27, 2024 00:07 — forked from deepakpk009/media.json
sample free video urls
{
"categories": [
{
"name": "Movies",
"videos": [
{
"description": "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources": [
"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
],
@dstyle0210
dstyle0210 / selectPidIExplore.js
Last active February 8, 2023 05:41
iexplore.exe 실행중인 pid 목록 가져오기
const exec = require("child_process").exec;
// 임시버전
const selectPidIExplore = () => {
return new Promise(() => {
exec(`tasklist | findstr "iexplore.exe"`,(err,stdout,stderr) => {
const pids = stdout.split(/\n/).map((row) => {
return row.trim().split(/\s+/)[1];
});
pids.pop(); // stdout 스플릿 상, 마지막 빈줄이 들어감. 제외처리
@dstyle0210
dstyle0210 / tts.css
Last active February 2, 2023 00:05
웹접근성 숨김처리 영역 CSS
/* .tts 라고도 하고, .sr-only 라고도 하고, .blind 라고도 하는 웹접근성 관련 TTS 프로그램 인식 CSS 코드 */
.blind{
position: absolute;
border: 0;
clip: rect(0 0 0 0);
clip-path: inset(50%);
width: 1px;
height: 1px;
margin: -1px;
overflow: hidden;
@dstyle0210
dstyle0210 / example.ejs
Created January 10, 2023 23:53
EJS 기초 API (?) 메모장
<%
const 변수1 = "변수값"; // 그냥 선언하기
// {string} 상수2 : 상수설명
const 상수2 = locals.상수2; // include options 로 땡겨올때 필수값
// {"변수옵션값1"|"변수옵션값2"} [변수3 = "변수옵션값1"] : 변수설명
let 변수3 = locals.변수3 ? locals.변수3 : "변수옵션값1"; // include options 로 땡겨올때 옵션값
const { 상수4 , 상수5 = "변수값" } = locals; // 객체분해할당 으로 include options 땡겨옴(이게 젤 많이 씀, 간단하니까)
%>
@dstyle0210
dstyle0210 / findPidFromPort.js
Last active February 6, 2023 01:58
포트번호 가져다가 pid 구하기
// 포트번호 기준해서, pid값 구하는거 (netstat 이용)
import { exec } from "child_process"; // 작으니까 exec
const splitStat = (stat) => stat.trim().split(/\s+/); // 띄어쓰기를 기준으로 스플릿
const findPidFromPort = (port_) => {
return new Promise((resolve,reject) => {
exec(`netstat -ano`,(err,stdout,stderr) => {
if(err) reject(err); // 에러가 존재 한다면 리턴해준다.
if(stderr) reject(stderr); // 표준에러가 존재 한다면 리턴해준다.
const _portReg = new RegExp(`:${port_}$`); // 포트번호가 딱 떨어져야함
@dstyle0210
dstyle0210 / nodeSpawn.ts
Last active January 6, 2023 06:50
윈도우,노드환경에서 스폰(spawn) 사용시 ENOENT 에러 지겹..
// node , windows 에서 spawn 사용 기초
// 스토리북 연동 중, global storybook이 없는 케이스 (로컬에서만 돌려야 하는경우)
// gulp 에서 즉시 실행이 불가함. (global에 없음 == storybook 다이렉트 실행 불가.)
import { task } from "gulp"; // gulp4
import { spawn } from "child_process";
// 부모프로세서에서 로그를 함께 볼때 (자식 -> 부모 로 log 전파됨)
@dstyle0210
dstyle0210 / createPlaywrightBrowser.ts
Last active January 18, 2023 07:48
playwright 프로세스 pid 구하기 ( launchServer )
// 참고 : https://playwright.dev/docs/next/api/class-browsertype#browser-type-launch-server
// v1.29.0 기준 정상동작 확인 됨.
import { chromium , device } from "playwright";
import type { Browser , Page } from "playwright";
// 기본형태 (간단버전?)
const createBrowserBasic = async () => {
let option = { // https://playwright.dev/docs/api/class-browsertype#browser-type-launch
@dstyle0210
dstyle0210 / makeProcess.js
Created January 5, 2023 02:04
[node] pid을 이용해서 node로 발생시킨 자식프로세스 닫기(연결끊기)
// 참고 : https://velog.io/@dev2820/nodejs%EC%9D%98-%EC%9E%90%EC%8B%9D%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4
const { spawn } = require("child_process");
const makeChildProcess = () => {
const child = spawn("커멘드",{
detached:true,
stdio:"ignore"
});
console.log( child.pid ); // (1) 나중에 닫을려고 일단 꺼내보기
child.unref(); // 자식프로세스와 연결끊기(부모프로세스 종료)
}
@dstyle0210
dstyle0210 / windowPerformanceNavigationType.js
Created August 1, 2019 04:41
뒤로가기 버튼을 통한 접근 체크 ( BFcache 제거하기 )
// 뒤로가기(type == 2)을 체크해서, 새로고침 처리한다.(BFcache 제거하기)
if(window.performance.navigation.type == 2){
setTimeout(function(){ // 임의 async을 위해 setTimeout 추가.
document.location.reload();
},10);
};
@dstyle0210
dstyle0210 / selenium-webdriver-chrome.js
Created July 29, 2019 06:16
selenium webdriver chrome setup
var webdriver = require('selenium-webdriver'), By = webdriver.By, until = webdriver.until;
var driver = new webdriver.Builder().forBrowser('chrome').build();