Skip to content

Instantly share code, notes, and snippets.

👻
I may be slow to respond.

Hafiq afiqiqmal

👻
I may be slow to respond.
Block or report user

Report or block afiqiqmal

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
@afiqiqmal
afiqiqmal / APNS.php
Last active Aug 11, 2019
Sample of APNS
View APNS.php
<?php
namespace App\PushNotification;
class Apns
{
static function sendPush($deviceToken, $message, $type = '', $contentId = -1) {
// check if is not empty string
if (!isset($deviceToken) || strlen($deviceToken) == 0) {
@afiqiqmal
afiqiqmal / ModelRouteUrlGenerator.php
Last active Apr 22, 2019
Leverage Eloquent To Prepare Your URLs LARAVEL
View ModelRouteUrlGenerator.php
<?php
/**
* Created by PhpStorm.
* User: hafiq
* Date: 21/04/2019
* Time: 7:17 PM
*/
namespace App\Http\Traits;
@afiqiqmal
afiqiqmal / AsyncGeocoder.java
Created Sep 29, 2018 — forked from reline/AsyncGeocoder.java
Async RxAndroid wrapper for Android's Geocoder
View AsyncGeocoder.java
import android.content.Context;
import android.location.Address;
import android.location.Geocoder;
import java.io.IOException;
import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
@afiqiqmal
afiqiqmal / cmd.txt
Created Sep 8, 2018
Create symlink in Cpanel
View cmd.txt
ls -s /home/user/public_html/folder/from /home/user/public_html/folder/to
@afiqiqmal
afiqiqmal / BooleanStringConverter.php
Last active Jul 25, 2018
Middleware of Laravel to Convert Incoming Request contain boolean string to boolean. Kinda head ache when laravel didn't detect boolean string
View BooleanStringConverter.php
<?php
class BooleanStringConverter extends TransformsRequest
{
protected function transform($key, $value)
{
if($value === 'true' || $value === 'TRUE' || $value === '1')
return true;
if($value === 'false' || $value === 'FALSE' || $value === '0')
@afiqiqmal
afiqiqmal / Nearest.java
Created Jun 21, 2018
Find the distances between 2 location
View Nearest.java
class Utils {
private double distance(double lat1, double lon1, double lat2, double lon2) {
// haversine great circle distance approximation, returns meters
double theta = lon1 - lon2;
double dist = Math.sin(deg2rad(lat1)) * Math.sin(deg2rad(lat2))
+ Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2))
* Math.cos(deg2rad(theta));
dist = Math.acos(dist);
dist = rad2deg(dist);
// 60 nautical miles per degree of seperation
@afiqiqmal
afiqiqmal / FireBaseNotification.php
Created Jun 2, 2018
Firebase notification PHP class for easier boilerplate
View FireBaseNotification.php
<?php
namespace App\Firebase;
class FireBaseNotification
{
protected $headers = [];
protected $key = null;
protected $baseUrl = null;
protected $pushBy = 1; // 1- topic 2- device
@afiqiqmal
afiqiqmal / sample.php
Created May 26, 2018
Clear All Files in Folders using Iluminate FileSystems
View sample.php
<?php
$file = new Filesystem();
$file->cleanDirectory('storage/app/public/images');
@afiqiqmal
afiqiqmal / HorizonServiceProvider.php
Created May 26, 2018
Horizon Service Provider to distinguish access for valid user only
View HorizonServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Laravel\Horizon\Horizon;
use Zizaco\Entrust\Entrust;
class HorizonServiceProvider extends ServiceProvider
{
@afiqiqmal
afiqiqmal / DateFormatted.php
Last active May 12, 2019
Auto generate Date Formatted Attribute for Laravel Model
View DateFormatted.php
<?php
/**
* Created by PhpStorm.
* User: hafiq
* Date: 14/05/2018
* Time: 9:28 AM
*/
namespace App\Models\Traits;
You can’t perform that action at this time.