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
@isfaaghyth
isfaaghyth / mysql.sql
Created December 20, 2018 20:18
InnoDB: Unable to lock ./ibdata1, error: 11
# cd /var/lib/mysql
# mkdir bak
# mv ibdata1 bak/.
# mv ib_logfile* bak/.
# cp -a bak/ibdata1 ibdata1
# cp -a bak/ib_logfile* .
# service mysql restart
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,
CREATE OR REPLACE FUNCTION test(uuidin text)
RETURNS TABLE(uuid integer, name text, business_account_id integer, upline_id integer, user_username text, grade_name text, grade_background_image text) AS $BODY$
BEGIN
RETURN QUERY
WITH RECURSIVE subordinates AS (SELECT b.uuid , b.name, b.business_account_id, b.upline_id,
b.user_username, g.name AS grade_name, g.background_image AS grade_background_image, (SELECT SUM(amount) FROM user_pin_transactions WHERE business_account_uuid = b.uuid) AS omzet FROM business_accounts b
INNER JOIN grades g ON id = b.grade_id
WHERE b.uuid = uuidin
UNION SELECT db.uuid, db.name, db.business_account_id, db.upline_id, db.user_username, dg.name AS grade_name, dg.background_image AS grade_background_image,
(SELECT SUM(amount) FROM user_pin_transactions WHERE business_account_uuid = db.uuid) AS omzet
@isfaaghyth
isfaaghyth / doublelinkedlist.cpp
Last active May 30, 2018 18:06
Data Structure and Algorithm
#include<iostream>
using namespace std;
struct Node {
int data;
Node *next;
Node *prev;
};
Node *node, *head, *tail;