Skip to content

Instantly share code, notes, and snippets.

Arief Bayu Purwanto ariefbayu

Block or report user

Report or block ariefbayu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View app.gradle
implementation "androidx.work:work-runtime:2.2.0"
implementation "com.squareup.okhttp3:okhttp:4.2.2"
View ProcessingWorker.java
package xyz.ariefbayu.android.workmanagertutorial.worker;
import android.content.Context;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.work.ExistingWorkPolicy;
import androidx.work.OneTimeWorkRequest;
import androidx.work.PeriodicWorkRequest;
import androidx.work.WorkManager;
View MainActivity.Java
OneTimeWorkRequest refreshWork = new OneTimeWorkRequest.Builder(ProcessingWorker.class).build();
WorkManager.getInstance(getApplicationContext()).enqueueUniqueWork(PUSH_LOCATION_WORK_TAG, ExistingWorkPolicy.KEEP, refreshWork);
View MainActivity.Java
OneTimeWorkRequest refreshWork = new OneTimeWorkRequest.Builder(ProcessingWorker.class).build();
WorkManager.getInstance(getApplicationContext()).enqueueUniqueWork(PUSH_LOCATION_WORK_TAG, ExistingWorkPolicy.KEEP, refreshWork);
View json-load-and-cacher.php
<?php
class JsonLoadAndCacher {
public $url;
public $hash;
//set cache directory here
private $fileLocation = 'd:/temp/';
public function LoadJson($url) {
$hash = md5($url);
//set your cached offline file as variable for ease of use
View custom.gradle
if(project.hasProperty("serverbuild.properties")
&& new File(project.property("serverbuild.properties")).exists()) {
Properties props = new Properties()
props.load(new FileInputStream(file(project.property("serverbuild.properties"))))
android {
signingConfigs {
release {
storeFile file(props['keystore'])
@ariefbayu
ariefbayu / build.gradle
Created Feb 12, 2016
custom build.gradle to support command line auto builder.
View build.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
View broadcast.php
<?php
$loader = require __DIR__.'/vendor/autoload.php';
use Longman\TelegramBot\Request;
$API_KEY = '--botfather-api-keu--';
$BOT_NAME = '--bofather-bot-name--';
$telegram = new Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME);
@ariefbayu
ariefbayu / snippet.java
Last active Aug 29, 2015
OkHttp recipe for uploading files with additional form inputs
View snippet.java
File file1 = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/Master/CAM_" + s.getType() + "_" + s.getJobCode() + ".jpg");
File file2 = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/Master/SIGN_" + s.getType() + "_" + s.getJobCode() + ".jpg");
Log.d("LOG", "File1: "+ (file1.exists() ? "E" : "N") + " -> " + file1.getAbsolutePath());
Log.d("LOG", "File2: "+ (file2.exists() ? "E" : "N") + " -> " + file2.getAbsolutePath());
RequestBody requestBody = new MultipartBuilder()
.type(MultipartBuilder.FORM)
.addFormDataPart("gambar1", file1.getName(),
RequestBody.create(MEDIA_TYPE_IMAGE, file1))
@ariefbayu
ariefbayu / convert-flac-to-mp3.sh
Created Jul 26, 2015
Snippet to convert all *.flac in a directory to *.mp3 while preserving its id3 medatas
View convert-flac-to-mp3.sh
(for FILE in *.flac ; do ffmpeg -i "$FILE" -f mp3 -ab 320000 -map_metadata 0 -id3v2_version 3 "`basename "$FILE" .flac`.mp3" || break; done)
You can’t perform that action at this time.