Skip to content

Instantly share code, notes, and snippets.

View isfaaghyth's full-sized avatar
Work from home

Muh Isfhani Ghiath isfaaghyth

Work from home
View GitHub Profile

Raw Query Factory:

interface GraphQuery {
    @RawQuery(R.raw.product_search)
    fun productSearch(): Extractor<String>
}

Thread:

package com.apps.search.utils
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.StaggeredGridLayoutManager
abstract class EndlessRecyclerViewScrollListener : RecyclerView.OnScrollListener {
// The minimum amount of items to have below your current scroll position
// before loading more.
fun ffmegCommand(cropSize: Int?, sourceFile: String, resultFile: String): Array<String> {
return arrayOf(
"-i",
sourceFile,
"-filter:v",
"crop=$cropSize:$cropSize",
"-codec:v",
"libx264",
"-profile:v",
"high",
public class HaversineFormula {
static double lat1, lat2, deg;
public HaversineFormula() {}
public static double calculate(double initialLat, double initialLong, double finalLat, double finalLong){
int R = 6371; // km
double dLat = toRadians(finalLat - initialLat);
public class CacheManager {
private static final String TAG = "CacheManager";
private static SharedPreferences getPref() {
return PreferenceManager.getDefaultSharedPreferences(RangerApplication.getContext());
}
public static void save(String key, String value) {
Log.d(TAG, "saveCache: " + value);
Pre Mojave (from Sierra or High Sierra)
======================================================
1. boot into recovery mode
2. take your logical volume ID
$ diskutil cs list
3. change CoreStorage logical volume into normal disk partition
# diskutil cs revert <<LOGICAL_VOLUME_ID>>
4. restart! and welcome to mojave installer.
Post Mojave
package app.isfaaghyth.location.utils;
import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import app.rangers.ranger.RangerApplication;
public class CacheManager {
private static final String TAG = "CacheManager";
1. buat layout untuk notif error (contoh: error.xml):
<LinearLayout
android:id="@+id/layoutError"
...>
<TextView
...
android:id="@+id/txtErr"
android:text="error!"/>
@isfaaghyth
isfaaghyth / sendgcm.php
Created September 24, 2018 12:36
Send GCM
<?php
function sendFirebaseNotification($threat, $id) {
$url = 'https://fcm.googleapis.com/fcm/send';
$fields = [
'to' => $id,
'data' => [
"caption" => $threat->caption,
"browser" => $threat->browser,