Skip to content

Instantly share code, notes, and snippets.

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

Muhamad Hanafiah Yahya hanafiah

🏠
Working from home
View GitHub Profile
based on https://www.tothenew.com/blog/indoor-positioning-systemtrilateration/
/**
* Calculates the distance from Beacon to device.
**/
private void calculateBeaconDistance(Beacon beacon) {
float txPower = -74.0; // Manufacture set this power in the device
if (beacon .rssi == 0){
@hanafiah
hanafiah / get_last_active_record.sql
Last active April 14, 2021 08:58
get last active record
NEW VER utk current
+++++
updated 2021-04-14 Guna struktur table baru
--
SELECT
t.*,
b.TarikhWarta ,
b.DPT,
b.Penerangan
FROM
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server host.docker.internal:8080;
}
server {
@hanafiah
hanafiah / hashid.php
Last active October 19, 2020 15:50
contoh cast hashid
class HashIdCast implements CastsAttributes
{
public function get($model, $key, $value, $attributes)
{
$hash = new Hashids();
return $hash->encode($value);
}
public function set($model, $key, $value, $attributes)
{
?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
/**
* check valid Password format
*/
class ValidPassword implements Rule