Skip to content

Instantly share code, notes, and snippets.

View junha1's full-sized avatar

Junha Yang(양준하) junha1

View GitHub Profile
@junha1
junha1 / rust_study.md
Last active May 22, 2024 22:59
Rust 공부하는법

Rust 공부하는법

2022년 9월 5일 양준하

왜 Rust를 배워야 하는가?

  • 2021년 4분기 기준 Github 점유율 15위 언어
  • C++ 암살자 포지션 (개인적으로 10년안에 C++ 넘어설 듯)
  • 블록체인, 임베디드, 시스템프로그래밍, 서버, 분산처리, WASM 등에서 활발히 사용되는 고성능 언어
  • 모던하고 깔끔한 언어 디자인, 훌륭한 개발툴과 패키지 매니저
  • 수준높은 사용자들과 커뮤니티, 독보적인 UX를 기반으로 한 철옹성 같은 팬덤들
@junha1
junha1 / cpp_exam.md
Created September 5, 2022 04:36
C++ exam

Problem 7 - Template Meta Programming 2

C++ provides a convenient STL container, tuple. This is an example of using tuple.

auto tuple1 = tuple<int, string, float> (5, "qwe", 0.4f);
auto tuple2 = make_tuple(1, 4, "qqq");

cout<<get<0>(tuple1)<<get<1>(tuple2)<<endl;
@junha1
junha1 / drop.rs
Created June 29, 2020 01:18
dropping
//
// Option1 - Explicit destruction
//
struct A;
struct B;
impl A {
fn shutdown(self) {
println!("Do some destruction");
}
@junha1
junha1 / main.rs
Last active November 26, 2020 05:58
Join thread with a timeout
use std::thread;
use std::sync::mpsc::{Receiver, channel};
use std::time::Duration;
struct MyJoin<T> {
handle: thread::JoinHandle<T>,
signal: Receiver<()>
}
impl<T> MyJoin<T> {
@junha1
junha1 / aaa.rs
Created April 3, 2020 10:03
Service handler using Rust async
use async_std::sync::{channel, Receiver};
use futures::future::FutureExt;
use rand::rngs::SmallRng;
use rand::FromEntropy;
use rand::Rng;
use std::thread;
use std::time;
use tokio::time::delay_for;
#[derive(PartialEq, Clone, Debug)]
@junha1
junha1 / asy.rs
Created April 3, 2020 07:59
Simple example of Rust's asynchronous and concurrent executions
use rand::Rng;
use std::thread;
use std::time;
use std::time::Instant;
use tokio::time::delay_for;
const MAX: usize = 1000;
async fn do_something(x: usize) -> usize {
let mut rng = rand::thread_rng();
@junha1
junha1 / Use-clauses_mering_script.py
Created January 6, 2020 05:32
Use-clauses merging script
path = '/home/junha/Projects/foundry/'
import os
def FindFile(path, format):
result = []
for f in os.listdir(path):
x = path + f
if os.path.isdir(x):