Skip to content

Instantly share code, notes, and snippets.

import UIKit
import RxSwift
import RxAlamofire
import ObjectMapper
class Post: Mappable {
var id: Int = 0
var title: String = ""
required init?(_ map: Map) {
@bear2u
bear2u / AppDatabse.kt
Created December 1, 2017 03:54 — forked from tinmegali/AppDatabse.kt
Android Room @TypeConverter using Kotlin
@Database(entities = arrayOf(Note::class, User::class), version = 1)
@TypeConverters(Converters::class)
abstract class AppDatabse : RoomDatabase() {
abstract fun userDAO(): UserDAO
abstract fun noteDAO(): NoteDAO
}
@bear2u
bear2u / gist:1dcb29d4e5cbd3f52b1a2322d667571f
Created December 24, 2017 17:35
firebase_function_making_thumnail_when_upload_img
/**
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@bear2u
bear2u / logging
Created January 4, 2018 09:23
Rx코틀린 로깅 유틸
@file:Suppress("NOTHING_TO_INLINE")
import android.util.Log
import io.reactivex.*
inline fun <reified T> printEvent(tag: String, success: T?, error: Throwable?) =
when {
success == null && error == null -> Log.d(tag, "Complete") /* Only with Maybe */
success != null -> Log.d(tag, "Success $success")
error != null -> Log.d(tag, "Error $error")
@bear2u
bear2u / MimeType.java
Created January 15, 2018 02:45
MimeType Enum 리스트
/**
*
* the code:
* tr -s ' ' < /etc/mime.types |while read; do z=$( echo $REPLY|cut -f1 -d'#' |cut -f1 -d ' ' );for j in $( echo $REPLY|cut -f1 -d'#' |cut -f2- -d ' '); do [[ "$j" =~ "/" ]] || echo $j '("'$z'"),' ; done; done|sort
*
*
* User: jim
* Date: May 21, 2009
* Time: 2:42:05 AM
*/
@bear2u
bear2u / quickstart-exam.sol
Created February 12, 2018 13:50
QuickStart 솔리디티 예제 연습 코드 #1
pragma solidity ^0.4.17;
contract Compaign {
struct Request {
string description;
uint value;
address recipient;
bool complete;
uint approvalCount;
mapping(address => bool) approvals;
@bear2u
bear2u / MainActivity.java
Created March 6, 2018 09:12 — forked from nowke/MainActivity.java
Retrofit - OkHTTP Connect to Self signed SSL Enabled Server: (Fix for CertPathValidatorException: Trust Anchor for certificate path not found) - Self Signing Client Bulider for Retrofit OkHTTP
public class MainActivity extends AppCompatActivity {
Retrofit retrofit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/*
Rest
*/
@bear2u
bear2u / RxJavaCollectExample.java
Created March 24, 2018 06:01 — forked from bowmanb/RxJavaCollectExample.java
RxJava collect() example. Converting a list of phrases into a list of their IDs only.
@Override
public void onNext(ArrayList<Phrase> phrases) {
ArrayList<Integer> phraseIDs = new ArrayList<>();
Observable
.from(phrases)
.collect(phraseIDs, new Action2<ArrayList<Integer>, Phrase>() {
@Override
public void call(ArrayList<Integer> integers, Phrase phrase) {
integers.add(phrase.getId());
}
@bear2u
bear2u / gist:e43c536a7af0b435d483a5e158bd59f8
Created June 7, 2018 01:19
몽고 db에서 Point를 노드에서 핸들링
const mapItemSchema = new mongoose.Schema({
name: String,
location: {
// It's important to define type within type field, because
// mongoose use "type" to identify field's object type.
type: {type: String, default: 'Point'},
// Default value is needed. Mongoose pass an empty array to
// array type by default, but it will fail MongoDB's pre-save
// validation.
coordinates: {type: [Number], default: [0, 0]}
@bear2u
bear2u / random.js
Created June 12, 2018 02:05
자바스크립트로 랜덤 함수 빨리 만들기
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);