Skip to content

Instantly share code, notes, and snippets.

View TuenTuenna's full-sized avatar
😍
Happy coding 👏

개발하는 정대리 TuenTuenna

😍
Happy coding 👏
View GitHub Profile
@mortezashojaei
mortezashojaei / OrdersComponent.tsx
Last active April 12, 2024 19:57
Using laravel-echo in reactjs
import React, { FC } from 'react';
import { useSocket } from '@myapp/hooks';
import {Order} from '@myapp/models';
export const OrdersComponent: FC = () => {
const [orders,setOrders] = useState<Order[]>();
function addNewOrder(neworder:Order) {
@tsuharesu
tsuharesu / rotation.kt
Created July 2, 2019 15:01
Rotate image after saving with CameraX
/** Define callback that will be triggered after a photo has been taken and saved to disk */
private val imageSavedListener = object : ImageCapture.OnImageSavedListener {
override fun onError(error: ImageCapture.UseCaseError, message: String, exc: Throwable?) {
exc?.printStackTrace()
}
override fun onImageSaved(photoFile: File) {
lifecycle.coroutineScope.launch {
rotateImageCorrectly()
}
import Combine
struct ZipMany<Element, Failure>: Publisher where Failure: Error {
typealias Output = [Element]
private let underlying: AnyPublisher<Output, Failure>
init<T: Publisher>(publishers: [T]) where T.Output == Element, T.Failure == Failure {
let zipped: AnyPublisher<[T.Output], T.Failure>? = publishers.reduce(nil) { result, publisher in
if let result = result {
@iamchiwon
iamchiwon / UIPickerController+Rx.swift
Last active November 30, 2022 10:46
DelegateProxy example
// MARK:- UIImagePickerController.rx
import UIKit
import RxSwift
import RxCocoa
// picker.rx.didFinishPickingMediaWithInfo
// ~~~~~~ ~~
// Base Reactive
@matteocrippa
matteocrippa / flutter.md
Last active October 26, 2023 05:47
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:

@godrm
godrm / swift_api_guideline.md
Last active May 10, 2024 16:14
스위프트 API 가이드라인

1. 스타일/문법 리뷰

1-1 스위프트 API 디자인 가이드라인

https://swift.org/documentation/api-design-guidelines/

  • 사용할 때 기준으로 명확하게 작성하는 게 가장 중요한 지향점이다. 메소드나 프로퍼티 같은 개발 요소는 한 번만 선언하고 반복적으로 사용한다. API를 만들 때는 사용하기 명확하고 편하게 만들어야 한다. 설계를 검증할 때 선언 부분을 읽는 것만으로는 부족하다. 그 대신 사용하는 상황에서 맥락에 맞고 명확한 지 늘 고려해야 한다.

  • 명확한 표현이 압축한 간결성보다 더 중요하다. 스위프트 코드는 압축해서 간결하게 작성할 수 있지만, 단지 글자수를 줄여서 가장 짧은 코드를 만드는 게 목표는 아니다. 스위프트 코드의 간결성은 자연스럽게 반복적으로 재사용하는 코드(boilerplate)를 줄이는 기능과 강한 타입 시스템의 부수효과로 드러날 뿐이다.

@WrathChaos
WrathChaos / UriToBitmap.md
Last active July 6, 2023 19:29
Android: How to convert Bitmap to Uri?
fun getImageUriFromBitmap(context: Context, bitmap: Bitmap): Uri{
    val bytes = ByteArrayOutputStream()
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes)
    val path = MediaStore.Images.Media.insertImage(context.contentResolver, bitmap, "Title", null)
    return Uri.parse(path.toString())
 }
@falsy
falsy / nvm_quick_start.md
Last active February 25, 2024 09:06
NVM(Node Version Manager) 맥OS에서 설치 & 사용하기

NVM(Node Version Manager) Quick Start

맥OS에서 NVM 사용하기

NVM 설치

1. 설치

$ sudo curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
@nolanw
nolanw / URLRequest+FormURLEncoded.swift
Last active May 11, 2023 20:38
Swift x-www-form-urlencoded
// Public domain - https://gist.github.com/nolanw/14b277903a2ba446f75202a6bfd55977
import Foundation
extension URLRequest {
/**
Configures the URL request for `application/x-www-form-urlencoded` data. The request's `httpBody` is set, and values are set for HTTP header fields `Content-Type` and `Content-Length`.
- Parameter queryItems: The (name, value) pairs to encode and set as the request's body.
@juzooda
juzooda / structToDic.playground
Created March 9, 2017 14:40
Simple Protocol to convert swift structs to dictionaries
import UIKit
struct Person: DictionaryConvertor {
let name: String
let job: [Job]?
let errors: [String]?
}
struct Job: DictionaryConvertor {
let title: String