Skip to content

Instantly share code, notes, and snippets.

View TuenTuenna's full-sized avatar
๐Ÿ˜
Happy coding ๐Ÿ‘

๊ฐœ๋ฐœํ•˜๋Š” ์ •๋Œ€๋ฆฌ TuenTuenna

๐Ÿ˜
Happy coding ๐Ÿ‘
View GitHub Profile
@mjm
mjm / LinkedText.swift
Created May 21, 2020 03:56
Tappable links in SwiftUI Text view
import SwiftUI
private let linkDetector = try! NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue)
struct LinkColoredText: View {
enum Component {
case text(String)
case link(String, URL)
}
@mortezashojaei
mortezashojaei / OrdersComponent.tsx
Last active March 19, 2025 12:42
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) {
//
// RxDataSources+SkeletonView.swift
//
// Created by mack on 4/7/20.
//
import Foundation
import UIKit
import RxSwift
import RxDataSources
@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
@oozoofrog
oozoofrog / gist:07d7eec63750c4992b09e2709f180497
Last active July 23, 2024 09:52
ํ•œ๊ธ€ ์œ ๋‹ˆ์ฝ”๋“œ ๋‹ค๋ฃจ๊ธฐ
import Cocoa
var str = "๊ถ‰ํ† abcd์Šค234๊พนํƒ€ใ…Žํ•˜ํ›„ํ›ผ์˜"
extension Collection {
var toArray: [Element] {
return Array(self)
}
}
protocol UnicodeScalarCreatable {
@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:

@godrm
godrm / swift_api_guideline.md
Last active July 14, 2025 15:44
์Šค์œ„ํ”„ํŠธ 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())
 }