All Articles

Concat DataFrame if not exists def merge_df(df_left, df_right): """ 두 데이터 프레임을 존재하는지 확인 후 합쳐서 새로운 데이터 프레임을 생성 및 리턴 Args: df_left (DataFrame): _description_ df_right (DataFrame): _description_ Returns: DataFrame: _description_ """ if df_right is None: # log('DataFrame df_right is null') if df_left is None: # log('DataFrame df_left is null') return None df_new = None if df_left is None: df_new = df_right else: df_new = pd.conca..
[C#] 파이썬 프로세스 실행 public void Main() { Process process = new Process(); process.StartInfo.FileName = "cmd.exe"; process.StartInfo.CreateNoWindow = true; process.StartInfo.RedirectStandardInput = true; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.UseShellExecute = false; process.Start(); process.StandardInput.WriteLine("venv\\Scripts\\activate"); process.StandardInput.WriteLine("activate virt..
Dictionary Pair 실행 시간 측정
[C#] Enable Windows 10 Mobile HotSpot 아래 동작은 모바일 핫스팟에 적용이 안됨 netsh wlan set hostednetwork mode=allow ssid=YOUR_NETWORK_NAME key=YOUR_PASSWORD Windows Runtime(WinRT)를 적용해야 함 참고: https://stackoverflow.com/questions/45833873/enable-windows-10-built-in-hotspot-by-cmd-batch-powershell 적용법: Netcore3.0~ 또는 Net6.0으로 Nuget Package Microsoft.Windows.SDK.Contracts 적용 소스: public class MobileHotSpot { public static async void Start() { var conne..
Create User in Shell reference: https://stackoverflow.com/questions/18503770/how-to-create-user-from-django-shell user@host> manage.py shell >>> from django.contrib.auth.models import User >>> user=User.objects.create_user('foo', password='bar') >>> user.is_superuser=True >>> user.is_staff=True >>> user.save()
[Django Rest] Allow Empty String in CharField > CharField에 allow_blank 추가 class CustomDataSerializer(serializers.ModelSerializer): ID = serializers.IntegerField(allow_null=True) Name = serializers.CharField(allow_blank=True) Type = serializers.CharField(allow_blank=True) Desc = serializers.CharField(allow_blank=True) > 그 외 추가 옵션 Desc = serializers.CharField(allow_null=True, allow_blank=True, default=None, required=False)
[Django] ManyToManyField Rest Framework Create and Update 검색했던 것들 > Direct assignment to the forward side of a many-to-many set is prohibited. Use .set() instead > django manytomanyfield set > needs to have a value for field "id" before this many-to-many relationship can be used. 참조: https://stackoverflow.com/questions/61537923/update-manytomany-relationship-in-django-rest-framework #serializers.py class PackageSerializer(serializers.ModelSerializer): ..
[수정필요] NetCoreServer OnReceived 길이 읽기 저장용 샘플 protected override void OnReceived(byte[] buffer, long offset, long size) { _bufferedStream.Write(buffer, (int)offset, (int)size); _bufferedStream.Position = 0; _bufferedStream.Flush(); int readOffset = 0; byte[] length = new byte[4]; byte[] bufferToRead = new byte[65536]; while (_bufferedStream.CanRead) { if (size < readOffset + 4) { return; } int nReadLengthBytes = _bufferedStream.Read(length,..
PathHelper - 파일 생성 및 리드할 때 디렉토리 확인용 using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Common { public static class PathHelper { private static string numberPattern = "_{0:00000}"; public static string NextAvailableFilename(string path) { // Short-cut if already available if (!File.Exists(path)) return path; return NextAvailableIndexFilenam..
JsonHelper - Newtonsoft 이용 using Newtonsoft.Json; using System.IO; using System.Net.Http; using System.Threading.Tasks; namespace Common { public static class JsonHelper { public static T ReadFile(string filename) where T : class { if (File.Exists(filename)) { var json = File.ReadAllText(filename); if (!string.IsNullOrEmpty(json)) { return JsonConvert.DeserializeObject(json); } } return null; } public static async Task Re..
Sliding Stream Sliding Stream Buffer, Offset, Count 형태로 읽을 수 있을 경우에 읽고 쓰기 가능한 자료구조 구현 이유 - NetCoreServer를 이용해서 OnReceived할 때, 읽는 속도보다 쌓이는 속도가 빨라서, Receive 버퍼에 현재 데이터만 쌓이는 게 아니라 다음 데이터까지 읽게 되는 문제가 생김 - Send할때 길이를 지정해주고 Received쪽에서 읽기 위해 SlidingStream으로 해당 길이만큼 읽을 수 있을 때 읽게함 특징 - ArraySegment로 Write할때는 빠르게 Write하게함 - Read단에서 읽을 수 있는지 판단하여 반환하도록함 - Read가 가능할 때, 읽어서 반환 - Read가 불가능할 때, 스트림에 다시 Write하고 0 반환 - Write는..
Newtonsoft Nullable Json Property Read and Write public class Model { // required property 지정할 방법 고민할 것 private int? data1; private int? data2; public Model(int? data1, int? data2) { this.Data1 = data1; this.Data2 = data2; } public int? Data1 { // 기본값 할당이 필요할때 어떻게 할지 get => data1; set => data1 = value; } public int? Data2 { get => data2; set => data2 = value; } } public class Program { public static T ReadFile(string filename) where T : class ..
[Flutter] drawer and tab bar in same line Drawer and Tab bar in same line _scaffoldKey.currentState?.openDrawer() 로 Scaffold의 openDrawer를 호출 import "package:flutter/material.dart"; class TabBarWithDrawer extends StatefulWidget { @override _TabBarWithDrawerState createState() => new _TabBarWithDrawerState(); } class _TabBarWithDrawerState extends State { with SingleTickerProviderStateMixin, RestorationMixin { late TabController _tabContr..
Shape Classcification from tensorflow.keras.applications.inception_resnet_v2 import InceptionResNetV2 from tensorflow.keras.applications.inception_resnet_v2 import preprocess_input from tensorflow.keras.preprocessing.image import ImageDataGenerator from tensorflow.keras.models import Model from tensorflow.keras.layers import Input from tensorflow.keras.layers import Dropout from tensorflow.keras.layers import Dense f..
Unity GRPC https://shadabambat1.medium.com/basic-client-server-communication-using-unity-grpc-f4a3c2cf819c
Keras image resize raw bytes with size > 코드, Numpy를 이용해서 resize def resize_image_from_bytes(pre_image, original_size: tuple, target_size: tuple): img = np.frombuffer(pre_image, dtype=np.float32).reshape(original_size + (3,)) img = image.array_to_img(img) return img.resize(target_size) > 결과화면
DataFrame to json utf8 한글 실패 jsonData = json.loads(df.to_json(orient="records")) with open("data.json", "w", encoding=&#39;utf8&#39;) as json_file: json.dump(jsonData, json_file, indent=4) with open("data.json", "w") as json_file: json.dump(jsonData, json_file, indent=4) 성공 pandas DataFrame to json file UTF-8 한글 df = pd.DataFrame() jsonData = json.loads(df.to_json(orient="records")) with open("data.json", "w", encoding=&..
DOTween Sequence 분리하기 using System; using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using DG.Tweening; using UnityEngine; public class SequenceBase { protected bool isCompleted; protected bool isSuccessed; public event Action Completed; protected bool IsCompleted { get => isCompleted; set { isCompleted = value; OnCompleted(); } } protected bool IsSuccessed { get => isSuccesse..
Utilities.cs Use of unassigned out parameter 'guid' MRTK 이식하던 중 문제 발생 다음 릴리즈에는 이슈가 수정될것 같지만 현재 MSBuild에 문제가 생기면 아래 해결방법 참고 https://github.com/microsoft/MSBuildForUnity/pull/150 Update Utilities.cs by RyanMilligan · Pull Request #150 · microsoft/MSBuildForUnity This fixes a compile error that occasionally pops up and causes my Unity projects to stop building. github.com
Unity MRTK gitignore 2021-11-20 저장 참고: 1. https://github.com/github/gitignore/blob/master/Unity.gitignore 2. https://gist.github.com/julenka/b65ece128107ae7cbace92c70c285c8c 3. https://docs.microsoft.com/en-us/windows/mixed-reality/mrtk-unity/performance/large-projects # This .gitignore file should be placed at the root of your Unity project directory # # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitig..
[Unity] 한글 폰트 적용 - NotoSansKR 1. 폰트 다운로드 https://fonts.google.com/noto/specimen/Noto+Sans+KR Google Fonts Making the web more beautiful, fast, and open through great typography fonts.google.com 2. 유니티 Windows->TextMeshPro->Font AssetCreator
[MRTK] Custom Hand Input to MRTK TrackedHandJoint 진행 1. Quest 2와 MRTK 이용할때, Quest 2의 핸드트래킹과 글로브로 손가락 움직임을 추적하기로함. 2. Quest 2의 OVRHand, OVRSkeleton을 래핑하여 재구현 3. 글로브 손가락 데이터를 MRTK의 TrackedHandJoint 데이터로 바인딩 4. MRTK의 HandTrackingProfile을 수정하고 BaseHandVisualizer를 래핑하여 구현 자료 정리 TrackedHandJoint Enum이 dll로 감싸져있는 듯하여 코드로 정리함 public enum TrackedHandJoint { // 번호는 손가락 끝 부분에서부터 오름차순으로 지정함 None = 0, // 없음 Wrist = 1, // 손목 Palm = 2, // 손바닥 ThumbMetacarpalJ..
[우리동네 탐방 1] 블렌더로 맵데이터 그리기 1. 블렌더에서 add-ons로 BlenderGIS, Node Wrangler 추가 2. GIS 탭에서 맵데이터, OSM, RSTM 가져오기 3. 누락된 건물 추가하기
[WinUI] Card Design with SplitView WinUI의 GridView, SplitView를 이용해서 카드 디자인을 구현 // 레이아웃 // CardSplitView.cs
[WinUI] WindowsAppSDK 다크 테마 아래와 같이 xaml에 RequestedTheme="Dark" 속성 추가 결과 화면
std::string to std::wstring 한글 std::string to std::wstring 헤더 파일 // Util.h #pragma once #include namespace Util { #ifdef _UNICODE std::wstring to_wstring(const std::string& str); std::string to_string(const std::wstring& str); #endif } 소스 파일 // Util.cpp #include "Util.h" #ifdef _UNICODE std::wstring Util::to_wstring(const std::string& str) { std::wstring buf; const int strLength = MultiByteToWideChar(CP_ACP, NULL, str.c_st..
[WPF] 소스로 트레이 아이콘 - 2 (Forms 대신 Windows.Controls로) WPF xaml로 트레이 아이콘 메뉴에 붙일 context menu를 생성하게되면 xaml(Windows.Controls.ContextMenu)와 NotifyIcon(Windows.Forms.ContextMenu)가 일치하지 않아 문제가 발생하게된다. 따라서 변환을 하거나 WPF용으로 트레이 기능이 포함된 라이브러리를 사용해야되고 WPF용으로 찾아서 사용하게되었다. 또한 디자인으로 MaterialDesign in xaml을 사용하였다. WPF용 NotifyIcon: www.hardcodet.net/wpf-notifyicon 구현 구현 소스: github.com/dogzz9445/CSharpTestExamples/tree/main/TrayWithMaterialDesignApp // MainWindow.xa..
[WPF] 소스로 트레이 아이콘 - 1 (Windows.Forms) WPF에 트레이 기능을 넣어보려고 했고 소스로는 나오긴하는데 예쁘지가 않아서 이 게시글에는 소스로 짧게 구현해보고 다음 게시글에서 xaml로 MaterialDesign 라이브러리와 함께 ContextMenu에 대한 템플릿을 만들어보고자 한다. 아이콘은 인터넷에서 아무거나 받아 사용하였음 // MainWindow.xaml.cs using System.Windows; using System.Windows.Forms; namespace TrayApp { public partial class MainWindow : Window { public NotifyIcon notifyIcon; public MainWindow() { InitializeComponent(); this.Loaded += (o, r) => { ..
[C#] 백그라운드에서 키보드 입력 감지 이벤트 1 (HotKey Hooking) 백그라운드에서 키보드 입력감지를 위해서는 몇가지 방법이 있고, event-driven 구조의 windows를 이용하여 아래 그림의 구조로 Windows API에 접근해 키보드 디바이스로부터 키입력에 대한 메시지를 전달받을 수 있다. 현재 내가 아는 백그라운드에서 키보드 후킹 방법은 요렇게 있다. 정확하게 모르는 low-level에서의 DLL injection [user32.dll] SetWindowsHookEx 함수를 이용한 DLL injection [user32.dll] SetWindowsHookEx 함수 [user32.dll] RegisterHotKey 함수 [runtime library] presentationcore.dll 어플리케이션이 직접 루프를 돌면서 해당 키보드의 상태값을 확인하는 방법 위..
Nuget 패키지 오프라인으로 설치 (System.Windows.Form) System.Windows.Form이 없어 외부망 내부망 분리되어있는 상태로 Nuget 패키지를 설치하게 되었다. 1. 따로 Nuget 파일을 다운 받고 2. 개발PC에 따로 Local Nuget을 저장할 폴더를 만들어서 Nuget 파일을 저장해두었다. 3. Visual Studio에 Nuget 폴더를 등록해주고 4. Package Manager로 설치 ( Install-Package System.Windows.Forms ) 5. Solution의 솔루션용 Nuget 패키지 관리 6. 패키지 소스로부터 Nuget 패키지를 설치 7. 오프라인으로 설치되서 정상적으로 포함되는걸 확인