[컴] github CLI 를 이용해서 Github REST API 사용

Github REST API

Github CLI, gh

먼저 cli 를 설치하면 windows 의 경우 gh.exe 하나가 설치된다.

github CLI 는 REST API 만 사용할 수 있게 해주는 것이 아니다. github 와 관련된 다른 작업들도 CLI 에서 수행할 수 있게 command를 제공한다. 예를 들면, 현재 내 local git project 에서 gh issue list 를 하면, 해당 repository 의 issue 들을 보여준다. gh issue create 하면 github issue 를 새롭게 생성해준다.

이제 로그인을 해보자. gh auth login 을 하면 된다.

d:\a\apps\GitHub CLI>gh.exe auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? SSH
? Generate a new SSH key to add to your GitHub account? No
? How would you like to authenticate GitHub CLI? Login with a web browser

! First copy your one-time code: 3A69-3D32
Press Enter to open github.com in your browser...
✓ Authentication complete.
- gh config set -h github.com git_protocol ssh
✓ Configured git protocol
✓ Logged in as testuseraccount

gh api

auth 를 얻은 상황에서 gh api 를 사용하면 github 의 REST api 를 사용할 수 있다. 아래처럼 사용할 수 있다. 다음 문서의 example 을 가면 여러 예제들을 확인할 수 있다.

# list releases in the current repository
$ gh api repos/{owner}/{repo}/releases

# post an issue comment
$ gh api repos/{owner}/{repo}/issues/123/comments -f body='Hi from CLI'

# use a template for the output
$ gh api repos/{owner}/{repo}/issues --template \
  '{{range .}}{{.title}} ({{.labels | pluck "name" | join ", " | color "yellow"}}){{"\n"}}{{end}}'



$ gh api graphql --paginate

issue 내용 보는 법

현재 git repository 에서 아래 처럼 github issue 를 볼 수 있다. 그런데 이 방법은 그냥 view 를 위한 것이다.

  • gh issue list
  • gh issue view 24

실제로 markdown 으로 된 contents 를 확인하려면 아래처럼 하면 된다.

$ gh api repos/namhpro/my_server/issues/10
$ gh api repos/namhpro/my_server/issues/10/comments

관련 python packages

See Also

  1. 쿠…sal: [컴] ocktokit.js 를 이용해서 github issue 가져오기

[컴] Conda package manager

콘다 / 패키지 매니징 / 설치 자동화 /

Conda package manager

Conda 는 Anaconda 에서 만들었다. Anaconda 는 간략하게 이야기하면, python 이랑 여러 package 들을 묶어서 배포하는 배포판이다. 여기서 만든 package manager 가 Conda 이다. python 으로 만들어져 있다.

필자가 이해한 바를 간략하게 이야기하면, Conda 는 package manager 로 보면 된다. 일반적인 package manager 들이 하는 것처럼 package 를 다운받고 설치해준다. 그러면 다른 package manager 와 무엇이 다른가?

관련 글들은 아래에 있다.

pip VS Conda

기본적으로 python 에서 사용하는 pip 를 생각해 보자. 이 package manager 는 python package 를 설치할 때 쓰인다. 그래서 만약에 gcc compiler 를 설치하고 싶다면 pip 를 이용할 수 없다.

Conda 는 이런 것을 가능하게 해준다. 즉, 내가 하는 프로젝트에서 python 도 사용하고, R 도 사용하고 Ruby 도 사용한다고 하면, pip 로 설치하고, CRAN 을 써서 또 설치하고, gem 등을 이용해서 또 설치해야 한다. 물론 pytho, R, ruby 도 apt-get 등의 시스템 패키지 매니저를 이용해서 설치해야 한다. 이런 작업들이 귀찮고 번거롭다. 이런 것을 한번에 모아서 처리해 줄 수 있는 것이 Conda 이다.

Dockerfile VS Conda

그런데 여기서 다시 ’Docker 의 Dockfile 을 사용하면 간단할 것 같은데’라는 생각이 든다. Dockerfile 에 대비한 장점이 무엇이길래 Conda 를 쓸까?

그 장점은 OS 를 변경하게 되는 경우에 있다. OS를 변경하게 되면, 필요한 system package 를 설치하기 위한 command 를 다시 적어넣어야 한다. Conda 만 동작한다면 그런 번거로움을 없앨 수 있다.

miniconda

아래 글을 보면, conda 는 Anaconda 배포판, 또는 Miniconda 배포판에 묶여서 배포된다고 한다. miniconda 는 conda + python + 'conda 의 dependency package'들 로 구성된 녀석이다. 아래 경로에서 download 할 수 있다. 당연히 기본 python 만을 설치할 때보다 용량은 더 필요하다.

from Python Installation - Conda Install | Google Earth Engine | Google Developers

The Earth Engine Python API can be installed to a local machine via conda, a Python package and environment manager. Conda is bundled with Anaconda and Miniconda Python distributions. Anaconda is a data science programming platform that includes 1500+ packages, while Miniconda includes only conda and its dependencies.

[컴][웹] javascript 에서 홑따옴표, 느낌표, 괄호, 별표 에 대한 percentage encoding 하는 법

 

js 에서 percentage encoding 하는 / percent encoding

javascript 에서 홑따옴표, 느낌표, 괄호, 별표 에 대한 percentage encoding 하는 법

javascript 에서 encodeURIComponent 로 대부분의 사항에 대해 percentagee encoding 을 할 수 있다. 그런데 몇가지 안되는 녀석이 있다.

관련해서 MDN 에 관련 내용이 있다.

To be more stringent in adhering to RFC 3986 (which reserves !, ’, (, ), and *), even though these characters have no formalized URI delimiting uses, the following can be safely used:

function fixedEncodeURIComponent(str) {
  return encodeURIComponent(str).replace(
    /[!'()*]/g,
    (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`,
  );
}

Reference

  1. fixedEncodeURIComponent | encodeURIComponent() - JavaScript | MDN

[컴] java driver 를 사용하는 경우, mongodb 에서 $merge 를 하면, resturn 이 오지 않게 하는 방법

 

reactor stream return nothing when merge / mongodb / mongo $merge 에서 결과가 너무 많이 온다.

java driver 에서 mongo $merge 를 하면, resturn 이 오지 않게 하는 방법

java driver(Reactor) 를 사용하는 경우, aggregation 마지막에 $merge 를 사용하면, return 으로 collection 내용을 전부 가져온다. ref. 2 에 적힌 issue 를 보면, backward compatibility 때문인듯 하다.(대충봐서 불확실)

방법은 다음과 같다.

MongoClient client = MongoClients.create("mongodb://localhost:27017");
MongoDatabase database = client.getDatabase("my-collection");
MongoCollection<Document> model = database.getCollection(collectionName);

val bsonListOfAggregationPipeline = listOf(Document(), ...)
AggregateIterable<Document> aggregateResult = model.aggregate(bsonListOfAggregationPipeline);

aggregateIterable.toCollection(); // 이렇게 하면 결과로 empty 가 온다.

aggregateIterable.toCollection()$out, $merge 에서만 사용가능한 듯 하다. ref. 3, ref. 4 참고

Reference

  1. java - Spring Data MongoDB: MergeOperation returns the whole collection. Why? - Stack Overflow
  2. java - Execute MongoTemplate.aggregate without row retrival - Stack Overflow
  3. spring-data-mongodb/MongoTemplate.java at 56115a263c77396700031540c1f4a2522220e0cd · spring-projects/spring-data-mongodb · GitHub
  4. AggregatePublisher (driver-reactive-streams 4.1.0 API)

[컴] AI 가 그려주는 그림을 얻는 사이트

AI 가 그림 그려주는 사이트 / 공짜 이미지 / 이미지 사용 / image how to get free / AI 로 그림 그리는 사이트

AI 가 그려주는 그림을 얻는 사이트

로그인 없이 이용가능한 사이트:

로그인 필요한 사이트:

See Also

  1. https://www.autodraw.com/ : 그림을 대충 그리면, 그림에 대한 candidate 가 뜬다.

References

  1. 10 Best AI Art Generators (2022) - Unite.AI

[컴] 프로그래밍 언어 선호도 순위

language rank / top programming language / 언어 순위 / Trending / jobs /spectrum

언어 선호도 순위

  • ref.1을 가면, chart 를 볼 수 있다.

  • Trending 의 1위는 python(100), 2위는 Java(74.19) 이다.
  • Jobs 의 1위는 SQL(100), 2위는 Java(95.07), 3위는 Python(88.22) 이다.

PYPL

구글의 검색량으로 인기도를 측정하는 index, 2006년부터의 추세를 확인할 수 있다.

See Also

  1. 쿠…sal: [컴] 컴퓨터 관련 유용한 survey 정보

References

  1. Top Programming Languages 2022 - IEEE Spectrum, 2022-08-23