Skip to content

Instantly share code, notes, and snippets.

View budioktaviyan's full-sized avatar
🇸🇬

Budi Oktaviyan budioktaviyan

🇸🇬
View GitHub Profile
@vzsg
vzsg / RxAlamofire+Multipart.swift
Created July 26, 2017 09:28
Alamofire+RX multipart encoding
import Foundation
import Alamofire
import RxSwift
extension Reactive where Base: SessionManager {
func encodeMultipartUpload(to url: URLConvertible, method: HTTPMethod = .post, headers: HTTPHeaders = [:], data: @escaping (MultipartFormData) -> Void) -> Observable<UploadRequest> {
return Observable.create { observer in
self.base.upload(multipartFormData: data,
to: url,
method: method,
@radityagumay
radityagumay / NetworkBuilder.swift
Created September 10, 2020 15:57
Network Builder in Swift based on Android Retrofit Builder Pattern
protocol Dao {
func insert(key: String, value: Any) -> Bool
func find(key: String) -> Any?
}
protocol StoreAdapterFactory {
func create() -> Dao
}
class StoreMemoryAdapter : Dao {
@micer
micer / RealPathUtil.kt
Last active April 18, 2021 01:21
Utility class to get real path from URI object - all API versions
import android.content.ContentUris
import android.content.Context
import android.database.Cursor
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.provider.DocumentsContract
import android.provider.MediaStore
import android.support.v4.content.CursorLoader
import android.text.TextUtils
//
// MazeViewController.swift
//
import UIKit
import Foundation
import RxSwift
class MazeViewController: UIViewController {
var currentDisposable: Disposable? = nil
@reline
reline / AsyncGeocoder.java
Last active April 18, 2021 02:14
Async RxAndroid wrapper for Android's Geocoder
import android.content.Context;
import android.location.Address;
import android.location.Geocoder;
import java.io.IOException;
import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
@ManuelPeinado
ManuelPeinado / MainActivity.java
Created October 19, 2014 20:02
Fading action bar effect using the new Toolbar class from the support library
package com.github.manuelpeinado.toolbartest;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.View;
@mikesteele
mikesteele / unescape.swift
Last active May 27, 2022 14:36
Unescape HTML special characters of String in Swift
func convertSpecialCharacters(string: String) -> String {
var newString = string
var char_dictionary = [
"&amp;": "&",
"&lt;": "<",
"&gt;": ">",
"&quot;": "\"",
"&apos;": "'"
];
for (escaped_char, unescaped_char) in char_dictionary {
@romyilano
romyilano / appleSearchBarSample.swift
Last active June 15, 2022 17:14
Various search bar implementations. Including an RxSwift / reactive swift version too
//https://developer.apple.com/library/content/samplecode/TableSearch_UISearchController/Introduction/Intro.html
// MARK: - UISearchResultsUpdating
func updateSearchResults(for searchController: UISearchController) {
// Update the filtered array based on the search text.
let searchResults = products
// Strip out all the leading and trailing spaces.
let whitespaceCharacterSet = CharacterSet.whitespaces
@jonasz-baron
jonasz-baron / RxAlamofire+Codable.swift
Created October 11, 2017 14:09
RxAlamofire usage with Codable protocol for object mapping. Inspired by: https://gist.github.com/kciter/e6f13119cbf8ad0963a68a5ebc421069
// Model
import Foundation
class Post: Codable {
var id = 0
var userId = 0
var title = ""
var body = ""
}
@wrburgess
wrburgess / updating_ruby_with_rvm_on_a_mac.md
Last active April 6, 2023 15:12
Updating Ruby with rvm or rbenv on a Mac

RBENV

  • rbenv install -l
  • rbenv install 2.6.5
  • rbenv local 2.6.5
  • gem install bundler
  • bundle install

RVM