Skip to content

Instantly share code, notes, and snippets.

@selmanon
selmanon / introrx.md
Created December 6, 2015 22:34 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
//
// Find contact based on name.
//
ContentResolver cr = getContentResolver();
Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null,
"DISPLAY_NAME = '" + NAME + "'", null, null);
if (cursor.moveToFirst()) {
String contactId =
cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
//
@selmanon
selmanon / genymotionwithplay.txt
Created July 27, 2016 09:47 — forked from wbroek/genymotionwithplay.txt
Genymotion with Google Play Services
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 6.0 (https://www.androidfilehost.com/?fid=24052804347835438 - benzo-gapps-M-20151011-signed-chroma-r3.zip)
Google Apps for Android 5.1 (https://www.androidfilehost.com/?fid=96042739161891406 - gapps-L-4-21-15.zip)
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)
Google Apps for Android 4.4.4 (https://www.androidfilehost.com/?fid=23501681358544845 - gapps-kk-20140606-signed.zip)
Google Apps for Android 4.3 (https://www.androidfilehost.com/?fid=23060877490000124 - gapps-jb-20130813-signed.zip)
Native Browser JavaScript
>>> abc
=> undefined
@selmanon
selmanon / app.js
Created November 1, 2016 17:19 — forked from mirkonasato/app.js
Example of Angular service using ngCordova GeoLocation
(function() {
var app = angular.module('app', ['ionic', 'ngCordova']);
app.factory('GeoService', function($ionicPlatform, $cordovaGeolocation) {
var positionOptions = {timeout: 10000, enableHighAccuracy: true};
return {
getPosition: function() {
@selmanon
selmanon / mvp.java
Created November 3, 2016 22:00 — forked from deveshmittal/mvp.java
Clean Architecture
//BasePresenter.java
public interface BasePresenter<V extends BaseView> {
/**
* Set or attach the view to this presenter
*/
public void attachView(V view);
/**
* Will be called if the view has been destroyed. Typically this method will
@selmanon
selmanon / Lifecycle change
Last active February 1, 2017 22:27
An organised draft of my time investment learning RxJava
@Override
protected void onDestroy() {
super.onDestroy();
if (mSubscription != null) mSubscription.unsubscribe();
}
@selmanon
selmanon / onError
Created February 1, 2017 22:33
onError
@Override
public void onError(Throwable e) {
getMvpView().hideProgressIndicator();
if (e instanceof IOException || e instanceof HttpException) {
mDataManager.getProfiles().subscribe(new Action1<List<Profile>>() {
@Override
public void call(List<Profile> profiles) {
renderProfilesUi(profiles);
@selmanon
selmanon / Caching
Last active February 1, 2017 23:12
An organised draft of my time investment learning RxJava
public Observable<List<Profile>> reloadProfiles() {
return mJobAppApiService.getAllProfiles().subscribeOn(Schedulers.io())
.concatMap(new Func1<List<Profile>, Observable<List<Profile>>>() {
@Override
public Observable<List<Profile>> call(List<Profile> profiles) {
return mRealmProfileRepo.setProfiles(profiles);
}
});
}