Skip to content

Instantly share code, notes, and snippets.

View najmsheikh's full-sized avatar
🎯
Focusing

Najm Sheikh najmsheikh

🎯
Focusing
View GitHub Profile
@najmsheikh
najmsheikh / Extensions.kt
Created December 10, 2020 17:29
Backwards compatible saving Bitmap to Gallery in Android 10
fun Bitmap.saveToStorage(
context: Context,
filename: String = "${System.currentTimeMillis()}.jpg",
format: Bitmap.CompressFormat = Bitmap.CompressFormat.JPEG,
quality: Int = 85
) {
val outputStream: OutputStream? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val resolver = context.contentResolver
val contentValues = ContentValues().apply {
put(MediaStore.MediaColumns.DISPLAY_NAME, filename)
@najmsheikh
najmsheikh / android-19.xml
Created July 4, 2020 20:42
Doclava federation XML
This file has been truncated, but you can view the full file.
<api>
<package name="android">
<class extends="java.lang.Object" name="Manifest" static="false" final="true" deprecated="not deprecated" visibility="public" abstract="false">
<constructor name="Manifest" static="false" final="false" deprecated="not deprecated" visibility="public" type="android.Manifest"/>
</class>
<class extends="java.lang.Object" name="Manifest.permission" static="true" final="true" deprecated="not deprecated" visibility="public" abstract="false">
<constructor name="Manifest.permission" static="false" final="false" deprecated="not deprecated" visibility="public" type="android.Manifest.permission"/>
<field value="&quot;android.permission.ACCESS_CHECKIN_PROPERTIES&quot;" name="ACCESS_CHECKIN_PROPERTIES" static="true" final="true" deprecated="not deprecated" visibility="public" type="java.lang.String"/>
<field value="&quot;android.permission.ACCESS_COARSE_LOCATION&quot;" name="ACCESS_COARSE_LOCATION" static="true" final="true" deprecated="not deprecated" vi
const sampleScript = {
value: 'sample script was injected!',
method: function() {
console.dir(this.value);
}
}
sampleScript.method();
@najmsheikh
najmsheikh / foo.java
Last active May 28, 2018 09:00
Piping observable errors while keeping the original observable alive
// The pattern for this abersnaze is referring to is (swallowing all errors, you can also log etc
// inside the flatmap using either doOnError(...) or in the onErrorResumeNext(...)):
observableThatShouldNotCompleteOnError
.flatMap(
e ->
obsrevableThatMayThrow(e)
.onErrorResumeNext(Observable.empty())
)
@najmsheikh
najmsheikh / keybase.md
Created December 31, 2014 00:27
Public verification for KeyBase.io

Keybase proof

I hereby claim:

  • I am najubhai on github.
  • I am najm (https://keybase.io/najm) on keybase.
  • I have a public key whose fingerprint is E3CB 2397 4F1E 49BC 0CE1 9CD6 7DDB 5576 B748 FBD6

To claim this, I am signing this object: