Skip to content

Instantly share code, notes, and snippets.

View harryhan24's full-sized avatar

harry han harryhan24

View GitHub Profile
""""""""""""""""""""""
" Leader
""""""""""""""""""""""
" let mapleader=,
" can't set leaders in Obsidian vim, so the key just has to be used consistently.
" However, it needs to be unmapped, to not trigger default behavior: https://github.com/esm7/obsidian-vimrc-support#some-help-with-binding-space-chords-doom-and-spacemacs-fans
unmap ,
" map ; to : in normal mode, so that I don’t rely on the shift key
" nmap ; :
@kayac-chang
kayac-chang / chain-or-else.ts
Created January 31, 2022 05:18
[learn FP with Kirby using `fp-ts`] TaskEither
/**
* chain and orElse
* ===
* sequential asynchronous processing can combined with chain and orElse
*/
import { pipe } from "fp-ts/lib/function";
import {
chain,
tryCatch,
@seovalue
seovalue / studylog.md
Last active July 9, 2022 12:38
level2 학습로그 정리

jwp-chess

@ExceptionHandler와 @ControllerAdvice

ExceptionHandler

  • what
    @ExceptionHandler 뒤에 작성한 예외가 발생했을 때, 그 예외를 잡아서 하나의 메서드에서 처리할 수 있게 해주는 어노테이션.
  • when
    예외를 처리할 때, 각 예외가 발생하는 시점에서 try-catch로 처리하거나 밖으로 throw해서 처리해야한다. 이렇게 하는 경우, 중복되는 코드도 많아지고 관리해야하는 포인트도 많아지게 된다. 따라서 @ExceptionHandler 어노테이션을 이용해 특정 예외에 대한 처리를 공통으로 처리할 수 있도록 책임을 넘겨주고 싶을 때 사용한다.
  • why
  1. 특정 예외에 대한 처리를 한 곳에서 담당하도록 할 수 있다.
#Have this script directly into your espanso/user.
# You can change and add some triggers too !
# To use it, it's simply the trigger (: or /) before all aliases for the admonition.
# For example : :faq or /faq will type the admonition question.
filter_title: "Obsidian"
matches:
#Title
- triggers: [":note", ":seealso"]
replace: |
import {
DynamoDBClient,
PutItemCommand,
GetItemCommand,
UpdateItemCommand,
DeleteItemCommand,
} from '@aws-sdk/client-dynamodb';
import {
marshall,
unmarshall
import AppError from '@shared/errors/AppError';
import FakeHashProvider from '../providers/HashProvider/fakes/FakeHashProvider';
import FakeUsersRepository from '../repositories/Fakes/FakeUsersRepository';
import CreateUserService from './CreateUserService';
describe('CreateUser', () => {
it('should be able to create a new user', async () => {
const fakeUsersRepository = new FakeUsersRepository();
const fakeHashProvider = new FakeHashProvider();
@Johnz86
Johnz86 / fetch.ts
Created July 15, 2019 15:45
RxJS implementation of fromFetch with node-fetch node module
import { Observable } from 'rxjs';
import fetch, { RequestInit, Request, Response } from 'node-fetch';
import AbortController from 'abort-controller';
export type RequestInit = RequestInit;
export function fromFetch(input: string | Request, init?: RequestInit): Observable<Response> {
return new Observable<Response>(subscriber => {
const controller = new AbortController();
const signal = controller.signal;
@vidanov
vidanov / step-functions.md
Last active November 28, 2021 10:16
AWS Step functions. InputPath, OutputPath, ResultPath

AWS Step functions

InputPath, OutputPath, ResultPath

  • InputPath -> the part of the original JSON payload to take to the step
  • OutPutPath -> the part of the original JSON payload to return after the step is completed
  • ResultPath -> here you can define a node to store the output you create in the step.

Please note "output" node is visible in the step function logs and here in the doc, but you do not have it in the function input. It means { "output": "1.05" } will be just

fun <T> backoff(times: Int = Int.MAX_VALUE, predicate: (Throwable, Int) -> Boolean = { _, _ -> true }): ObservableTransformer<T, T> {
return ObservableTransformer {
it.retryWhen { attempts ->
val counter = AtomicInteger()
attempts.takeWhile { e -> counter.getAndIncrement() < times && predicate(e, counter.get()) }
.flatMap { Observable.timer(counter.get().toLong(), TimeUnit.SECONDS) }
}
}
}
@DWboutin
DWboutin / directUploadToS3.js
Created March 31, 2019 22:33
Direct image url to S3 wiht axios and nodejs
import AWS from 'aws-sdk';
import stream from 'stream'
import axios from 'axios';
export default async (url, filename, callback) => {
const s3 = new AWS.S3({ params: { Bucket: process.env.STATIC_MAPS_BUCKET }});
let contentType = 'application/octet-stream'
let promise = null
const uploadStream = () => {