Skip to content

Instantly share code, notes, and snippets.

View godjooyoung's full-sized avatar
🌴
On vacation

신주영 godjooyoung

🌴
On vacation
View GitHub Profile
@godjooyoung
godjooyoung / Header.jsx
Created July 25, 2023 05:52
SSE를 통한 실시간 알림을 구현했습니다. 헤더에 토큰을 담기 위해 EventSourcePolyfill을 사용했습니다.
// 알람 창을 열었으면 신규 알람 아이콘 없앤다.
useEffect(() => {
if (isAlarmWindowOpen) {
console.log("[INFO] 알람 확인")
setIsNewNotification(0)
} else if (!isAlarmWindowOpen && isNewNotification === 0) {
//클린
dispatcher(__alarmClean())
}
}, [isAlarmWindowOpen])
@godjooyoung
godjooyoung / user.js
Created July 25, 2023 05:46
전역 스토어를 통해 사용자 주소를 저장할때 미들웨어를 사용해서 외부 api 요청을 구현하여 반복되는 코드 사용을 줄였습니다.
import { createSlice } from '@reduxjs/toolkit'
import { getAddress } from '../../axios/api/kakao'
// 초기상태 설정 (사용자 위치 정보가 없을 경우 지도에 보여줄 기본 위치)
const initialState = {
userLatitude: 37.5561332,
userLongitude: 126.8656449,
userTown: '서울특별시 강서구 염창동',
}
const userSlice = createSlice({
@godjooyoung
godjooyoung / ChartWeekly.jsx
Created July 25, 2023 05:42
Chart.js를 사용해서 사용자 주간 학습 일자를 시각화 하여 구현하였습니다.
import React, { useEffect, useState } from 'react';
import { styled } from 'styled-components';
function ChartWeekly(props) {
const [weeklyAttend, setWeeklyAttend] = useState([10.0, 0, 0, 0, 0, 0, 0])
const [wkTotTm, setWkTotTm] = useState('00H00M')
useEffect(() => {
// 초기화
return () => {
// 클린
@godjooyoung
godjooyoung / Tutorial.jsx
Last active July 25, 2023 05:40
BBC 코로나 뉴스를 참고하여서 인터렉티브한 튜토리얼 페이지를 구현했습니다.
import React, { useEffect, useRef, useState } from 'react';
import { useQueryClient, useQuery, useMutation } from 'react-query';
import { useNavigate } from 'react-router-dom';
import { styled } from 'styled-components';
import { checkTutorial } from '../axios/api/tutorial'
import { getCookie } from '../cookie/Cookie';
function Tutorial() {
const navigate = useNavigate();
const stepRefs = useRef([])
@godjooyoung
godjooyoung / AndroidManifest.xml
Created June 19, 2020 01:07
좌표값 가져오기 권한 추가
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.location">
<!-- 사용권한-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
@godjooyoung
godjooyoung / build.gradle
Created June 19, 2020 01:06
좌표값 가져오기 그리들
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.location"
minSdkVersion 16
targetSdkVersion 29
@godjooyoung
godjooyoung / MainActivity.java
Created June 19, 2020 01:06
좌표값 가져오기
package com.example.location;
import android.annotation.SuppressLint;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
@godjooyoung
godjooyoung / activity_main.xml
Created June 19, 2020 01:06
안드로이드 좌표값 가져오기 레이아웃 뷰
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<Button
@godjooyoung
godjooyoung / activity_volley.xml
Created June 17, 2020 01:13
안드로이드 리퀘스트 뷰
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Volley">
<TextView
android:id="@+id/textview"
@godjooyoung
godjooyoung / build.gradle
Created June 17, 2020 01:12
안드로이드 리퀘스트 그리들
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.volley"
minSdkVersion 16
targetSdkVersion 29