Skip to content

Instantly share code, notes, and snippets.

View mikkipastel's full-sized avatar

Monthira Chayabanjonglerd mikkipastel

View GitHub Profile
@huytd
huytd / wordle.md
Last active May 16, 2024 20:39
Wordle in less than 50 lines of Bash

image

How to use:

./wordle.sh

Or try the unlimit mode:

@mattiaferigutti
mattiaferigutti / MainActivity.kt
Last active July 31, 2021 08:05
Get a file from assets ExoPlayer 2
package com.studio.mattiaferigutti.exoplayertest
import android.annotation.SuppressLint
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.google.android.exoplayer2.*
import com.google.android.exoplayer2.source.ProgressiveMediaSource
import android.os.SystemClock
import android.util.Log
import okhttp3.Interceptor
import okhttp3.Response
import java.io.IOException
class RequestInterceptor(private val tokenStore: TokenStore) : Interceptor {
private val oauthService by lazy { ServiceGenerator.createAuthService() }
private var isRefreshing = false
@nikartx
nikartx / Cache.java
Last active April 26, 2024 07:40
Android. Example how to save an image file in the App cache and get Uri for it. The Image will not be saved in a device gallery, only in an internal App cache.
package com.github.example;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.core.content.FileProvider;
@HBiSoft
HBiSoft / FileUtils.java
Last active February 1, 2024 19:10
This fixes the issue when selecting a file from Downloads directory as well as the SD Card. This class can be called like this: String sourcePath = FileUtils.getRealPathFromURI_API19(this, data.getData());
import android.annotation.SuppressLint;
import android.content.ContentUris;
import android.content.Context;
import android.content.CursorLoader;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
@michaeltys
michaeltys / ShareFileToInstagram
Created October 10, 2018 15:13
Sharing an image to instagram stories or create a post
private void shareFileToInstagram(Uri uri, boolean isVideo, Post post) {
Intent feedIntent = new Intent(Intent.ACTION_SEND);
feedIntent.setType(isVideo ? "video/*" : "image/*");
feedIntent.putExtra(Intent.EXTRA_STREAM, uri);
feedIntent.setPackage(Constants.INSTAGRAM_PACKAGE_NAME);
Intent storiesIntent = new Intent("com.instagram.share.ADD_TO_STORY");
storiesIntent.setDataAndType(uri, isVideo ? "mp4" : "jpg");
storiesIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
storiesIntent.setPackage(Constants.INSTAGRAM_PACKAGE_NAME);
@anop72
anop72 / gist:8fff5f3ffd1dec91f3e9609c6c133af3
Created August 6, 2018 05:07
fuel-kotlin-refresh-token-test
private fun getData(): Single<String> {
var request: Request? = null
var response: Response? = null
var data: Any? = null
var error: FuelError? = null
var manager = FuelManager()
manager.basePath = "http://192.168.1.73:3000"
@akexorcist
akexorcist / index.js
Last active November 17, 2022 11:25
Axios post method requesting with x-www-form-urlencoded content type. See https://axios-http.com/docs/urlencoded
const axios = require('axios')
/* ... */
const params = new URLSearchParams()
params.append('name', 'Akexorcist')
params.append('age', '28')
params.append('position', 'Android Developer')
params.append('description', 'birthdate=25-12-1989&favourite=coding%20coding%20and%20coding&company=Nextzy%20Technologies&website=http://www.akexorcist.com/')
params.append('awesome', true)
@costular
costular / BottomMenuItem.kt
Last active June 20, 2022 12:05
Bottom sheet menu with recyclerview faster thanks to Kotlin
data class BottomMenuItem(
val resId: Int,
val name: String,
val action: () -> Unit
)
@rapee
rapee / cityglide_api_doc.md
Last active October 24, 2016 07:46
CityGlide API Hack Manual