Skip to content

Instantly share code, notes, and snippets.

sealed trait NaturalNumber
sealed trait _0 extends NaturalNumber
sealed trait _1 extends _0
sealed trait _2 extends _1
sealed trait _3 extends _2
sealed trait _4 extends _3
sealed trait _5 extends _4
sealed trait _6 extends _5
sealed trait _7 extends _6
sealed trait _8 extends _7
@hmm-umm
hmm-umm / types-and-manifests.md
Created April 6, 2021 08:39 — forked from curry-ing/types-and-manifests.md
[Scala] Types And Manifests

Types and Manifests

  • Scala도 다른 JVM언어와 마찬가지로 런타임에 타입을 소거

    • 컴파일시에는 가능한 타입 정보에 대한 접근이 런타임에는 불가능
  • Scala.reflect.Manifest, TypeTags: 컴파일타임에 접근 가능한 타입 정보를 런타임에 전달

    • TypeTag[T]는 컴파일 타임의 타입T의 런타임 타입 표현을 캡슐화.
    • TypeTag는, 2.10 이하 버전에서 사용되었던, 더 많은 기능을 내포한 Manifest의 대안이며, Scala reflection에 통합됨

세 가지 타입의 TypeTags

@hmm-umm
hmm-umm / gist:666dccef11beed9f21cd6f1614779b36
Created December 23, 2020 18:30 — forked from brantfaircloth/gist:260331
Python multiprocessing.JoinableQueue()
import os
import subprocess
import multiprocessing
def q_runner(n_procs, list_item, function, *args):
'''generic function used to start worker processes'''
task_queue = multiprocessing.Queue()
results_queue = multiprocessing.JoinableQueue()
if args:
arguments = (task_queue, results_queue,) + args
@hmm-umm
hmm-umm / ThumbnailActivity.kt
Created February 19, 2019 06:17 — forked from prongbang/ThumbnailActivity.kt
Android RecyclerView StaggeredGridLayoutManager Example
val thumbnails = ArrayList<String>()
thumbnails.add("http://www.hotel-r.net/im/hotel/pl/hotel-simple-1.jpg")
thumbnails.add("https://media-cdn.tripadvisor.com/media/photo-s/0e/20/6a/59/simple-patagonia-hotel.jpg")
thumbnails.add("https://mir-s3-cdn-cf.behance.net/project_modules/disp/65daa813704049.5627720c3ae61.jpg")
thumbnails.add("http://www.hotel-r.net/im/hotel/lt/hotel-simple-12.jpg")
thumbnails.add("https://images.trvl-media.com/hotels/7000000/6450000/6441600/6441512/6441512_56_z.jpg")
thumbnails.add("http://interiii.com/wp-content/uploads/2013/03/Latest-Caro-Hotel-Design-by-Francesc-Rif%C3%A9-Studio-Decoration-Ideas1.jpg")
thumbnails.add("https://media-cdn.tripadvisor.com/media/photo-s/05/07/33/ba/smart-and-simple-hotel.jpg")
thumbnails.add("https://c1.hiqcdn.com/images/property/resortimg/431680_w85.jpg")
thumbnails.add("https://www.cabinn.com/sites/default/files/CabInn_Aalborg_029_0.jpg")

Note

Apple will reject apps that are using private url schemes (Ugh, Apple....) if they are pretty much obvius. Some apps are rejected and others are not, so, be aware of this issue before implementing any of those URL's in your app as a feature.

Updates

  • [UPDATE 4] iOS 10 update: apparently settings now can be reached using App-Pref instead of prefs
  • [UPDATE 3] For now you just can use url schemes to open your apps's settings with Swift 3.0 (Xcode 8). I'll keep you informed when OS preferences can be reached
  • [UPDATE 2] The openURL() method of UIApplication is now deprecated. You should use application(_:open:options:) instead
  • [UPDATE 1] Not yet tested in iOS 10. It will fail because of policies changes in URL scheme handling.
import android.view.Choreographer
import io.reactivex.subjects.PublishSubject
import java.util.concurrent.TimeUnit
object FpsObserver {
private val choreographer = Choreographer.getInstance()
private val countSubject = PublishSubject.create<Unit>()
init {
@hmm-umm
hmm-umm / GuardUtil.kt
Last active November 5, 2018 08:56
half like swift guard
fun guard(predicate: () -> Boolean) : GuardClass {
return GuardClass(predicate)
}
data class GuardClass(val checkFunc: () -> Boolean) {
inline infix fun `else`(elseFunc: () -> Nothing) {
if (!checkFunc()) { elseFunc() }
}
}
@hmm-umm
hmm-umm / README.md
Created December 6, 2017 23:56 — forked from phatak-dev/README.md
Functional Programming in C++

#Compilng You need g++ 4.9 to compile this code. Follow these steps to install g++-4.9

After installing run the following command to compile

/usr/bin/g++-4.9 -std=c++11 lambda.cpp

#Running

./a.out
@hmm-umm
hmm-umm / monad-in-java.md
Created May 28, 2017 13:42 — forked from jooyunghan/monad-in-java.md
한글번역 - Functor and monad examples in plain Java

Functor and monad examples in plain Java

이 글은 우리가 쓴 책, 'Reactive Programming with RxJava' 의 부록이었다. Reactive programming과 관련이 깊은 주제긴 하지만 모나드를 소개한다는 게 책과 썩 어울리지는 않았다. 그래서 나는 따로 블로그에 올리기로 했다. 프로그래밍을 다루는 블로그에서 *"반은 맞고 반은 틀릴 지 모르는 나만의 모나드 설명"*이란 것이 새로운 *"Hello World"*라는 점을 나도 잘 안다. 하지만 이 글은 펑터(functor)와 모나드(monad)를 자바 자료 구조와 라이브러리라는 각도에서 바라보고 있으며, 이는 공유할 정도의 가치는 있을거라 생각했다.