Skip to content

Instantly share code, notes, and snippets.

View harryhan24's full-sized avatar

harry han harryhan24

View GitHub Profile
@didil
didil / asyncConcat.js
Created July 16, 2018 11:14
asyncConcat lambda handler
const jsonResponse = require("../lib/jsonResponse");
const asyncConcatService = require("../lib/asyncConcatService");
module.exports.handler = async (event, context) => {
let { a, b } = event.queryStringParameters;
if (!a || !b) {
return jsonResponse.error({
message: "Please specify 2 strings a and b to concatenate"
});
@matteocrippa
matteocrippa / flutter.md
Last active April 20, 2025 03:41
Flutter Cheatsheet

Flutter

A quick cheatsheet of useful snippet for Flutter

Widget

A widget is the basic type of controller in Flutter Material. There are two type of basic Widget we can extend our classes: StatefulWidget or StatelessWidget.

Stateful

StatefulWidget are all the widget that interally have a dynamic value that can change during usage. It can receive an input value in the constructor or reference to functions. You need to create two classes like:

@rlarla245
rlarla245 / 1. 순서
Last active August 4, 2018 10:19
Firebase 11 - Remote Config
11. Firebase – Remote Config(Change Value)
● 원격으로 앱의 배경색, 프로레스 작동 및 종료가 가능합니다.
1. 문서로 이동합니다. 원격 구성 탭으로 이동합니다.
- compile 코드를 붙여넣습니다.
- 작동 원리 부분의 mFirebaseRemoteConfig 코드를 가져옵니다. HomeActivity로 이동하여 remoteConfig() 메소드를 생성해 바디 부분으로 붙여넣습니다. 에러는 스스로 잡습니다.
해당 코드는 디버깅 테스트를 할 때 에러를 잡아주는 기능입니다.
- 문서 내 하단의 디폴트 설정 값을 입력하는 코드도 복사해 해당 메소드 하단에 붙여넣습니다.
해당 코드는 서버에 해당되는 값이 없을 때 참조하는 기능입니다.
@drewwiens
drewwiens / rxjs-operators.ts
Last active September 8, 2024 06:11
Handy custom RxJS operators for Angular etc
import { AbstractControl, FormArray, FormGroup } from '@angular/forms';
import { map, toPairs, fromPairs, differenceWith, isEqual, isNull, isUndefined } from 'lodash';
import { Observable, OperatorFunction, defer, empty, of, merge, pipe } from 'rxjs';
import { distinctUntilChanged, filter, map, shareReplay, pairwise } from 'rxjs/operators';
/**
* Convenience RxJS operator that filters out undefined & null and modifies the downstream type
* appropriately.
*/
export function exists<T>(): OperatorFunction<T | undefined | null, T> {
@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 = () => {
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) }
}
}
}
@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

@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;
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();
import {
DynamoDBClient,
PutItemCommand,
GetItemCommand,
UpdateItemCommand,
DeleteItemCommand,
} from '@aws-sdk/client-dynamodb';
import {
marshall,
unmarshall