Skip to content

Instantly share code, notes, and snippets.

View soulduse's full-sized avatar
💭
🔥

Programming Zombie soulduse

💭
🔥
View GitHub Profile
@ShMcK
ShMcK / StableDiffusionUI_SageMaker.ipynb
Last active July 12, 2024 14:25
Config for running Automatic1111 Stable Diffusion WebUI on an AWS SageMaker Notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
package com.berider.app.common.utils
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.os.Parcelable
import android.view.inputmethod.InputMethodManager
import androidx.activity.OnBackPressedCallback
import androidx.appcompat.app.ActionBar
import androidx.appcompat.app.AppCompatActivity
@wangerekaharun
wangerekaharun / PostsDataSource.kt
Last active September 29, 2019 20:55
Reddit Data Source Class
class PostsDataSource(private val scope: CoroutineScope) :
PageKeyedDataSource<String, RedditPost>() {
private val apiService = ApiClient.getClient().create(ApiService::class.java)
override fun loadInitial(params: LoadInitialParams<String>, callback: LoadInitialCallback<String, RedditPost>) {
scope.launch {
try {
val response = apiService.fetchPosts(loadSize = params.requestedLoadSize)
when{
response.isSuccessful -> {
@vinhdn
vinhdn / RealmHelper.java
Created September 18, 2017 09:33
Realm Helper Android
public class RealmHelper {
public static <T extends RealmObject> void save(T object) {
Realm realm = Realm.getDefaultInstance();
try {
realm.beginTransaction();
realm.copyToRealmOrUpdate(object);
realm.commitTransaction();
} finally {
realm.close();
}
@babedev
babedev / ViewExt.kt
Last active February 16, 2018 12:15
Show image with Glide and start intent with Anko
fun ImageView.show(imageUrl: String = "") {
if (imageUrl.isBlank()) return
if (context == null) return
if (context is Activity && ((context as Activity).isFinishing || (context as Activity).isDestroyed)) return
Glide.with(context)
.load(imageUrl)
.crossFade()
@ethauvin
ethauvin / AndroidPreferences.kt
Last active January 18, 2018 14:04
Android SharedPreferences shorthands for Kotlin
import android.content.Context
import android.content.SharedPreferences
import android.preference.PreferenceManager
fun Context.getDefaultSharedPreferences(): SharedPreferences {
return PreferenceManager.getDefaultSharedPreferences(this)
}
fun SharedPreferences.clear() {
edit().clear().apply()
@zakelfassi
zakelfassi / android_shortcut.java
Created April 10, 2014 21:03
Create android app shortcut programatically
// Note that a shortcut is created automagically if the app is installed via Play store.
// Change "APP_NAME" by your app name. *MrObvious*
/*Manifest file - add this */
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
/* MainActivity.java */
public class MainActivity ... {
...
private SharedPreferences appSettings;
@solar
solar / IconPreference.java
Created June 1, 2011 09:41
Android PreferenceScreen with icon image.
package org.sazabi.lib.preference;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.preference.Preference;
@JakeWharton
JakeWharton / IconCheckBoxPreference.java
Created August 9, 2010 16:37
IconCheckBoxPreference: An Android CheckBox preference with an optional Icon
package com.jakewharton.utilities;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.preference.CheckBoxPreference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import com.jakewharton.wakkawallpaper.R;