Skip to content

Instantly share code, notes, and snippets.

View ariefbayu's full-sized avatar
🏠
Working from home

Arief Bayu Purwanto ariefbayu

🏠
Working from home
View GitHub Profile
implementation "androidx.work:work-runtime:2.2.0"
implementation "com.squareup.okhttp3:okhttp:4.2.2"
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;
OneTimeWorkRequest refreshWork = new OneTimeWorkRequest.Builder(ProcessingWorker.class).build();
WorkManager.getInstance(getApplicationContext()).enqueueUniqueWork(PUSH_LOCATION_WORK_TAG, ExistingWorkPolicy.KEEP, refreshWork);
OneTimeWorkRequest refreshWork = new OneTimeWorkRequest.Builder(ProcessingWorker.class).build();
WorkManager.getInstance(getApplicationContext()).enqueueUniqueWork(PUSH_LOCATION_WORK_TAG, ExistingWorkPolicy.KEEP, refreshWork);
<?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
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 February 12, 2016 03:44
custom build.gradle to support command line auto builder.
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
<?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 August 29, 2015 14:27
OkHttp recipe for uploading files with additional form inputs
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 July 26, 2015 22:24
Snippet to convert all *.flac in a directory to *.mp3 while preserving its id3 medatas
(for FILE in *.flac ; do ffmpeg -i "$FILE" -f mp3 -ab 320000 -map_metadata 0 -id3v2_version 3 "`basename "$FILE" .flac`.mp3" || break; done)