Skip to content

Instantly share code, notes, and snippets.

View guangrei's full-sized avatar
💭
I may be slow to respond.

Am K guangrei

💭
I may be slow to respond.
View GitHub Profile
@guangrei
guangrei / install.sh
Last active November 14, 2018 16:02
pcat : cat with syntax highlighters
#!/bin/sh
pip install -U Pygments --user
echo "alias pcat='pygmentize -g -O style=colorful,linenos=1'" >> ~/.bashrc
echo "done!"
from typing import NoReturn
import asyncio
import time
from random import randint
nilai: int = 0
start: int = time.time()
async def simulasiProg() -> NoReturn:
@guangrei
guangrei / distanceCalculation.php
Created July 10, 2018 10:19 — forked from nirendra/distanceCalculation.php
Calculate distance between two points
The function below use the latitude and longitude of two locations, and calculate the distance between them in both miles and metric units.
function getDistanceBetweenPointsNew($latitude1, $longitude1, $latitude2, $longitude2) {
$theta = $longitude1 - $longitude2;
$miles = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta)));
$miles = acos($miles);
$miles = rad2deg($miles);
$miles = $miles * 60 * 1.1515;
$feet = $miles * 5280;
$yards = $feet / 3;
@guangrei
guangrei / script.php
Last active February 3, 2025 02:58
[PHP] pengecekan tanggal merah berdasarkan hari libur nasional dan hari minggu
<?php
//default time zone
date_default_timezone_set("Asia/Jakarta");
//fungsi check tanggal merah
function tanggalMerah($value) {
$array = json_decode(file_get_contents("https://raw.githubusercontent.com/guangrei/APIHariLibur_V2/main/calendar.json"),true);
//check tanggal merah berdasarkan libur nasional
if(isset($array[$value]) && $array[$value]["holiday"])
: echo"tanggal merah\n";
@guangrei
guangrei / ifttt.php
Last active November 22, 2020 10:16
Send Event to IFTTT
<?php
//configuration
$key="API key";
$event="event_name";
//data
$data=json_encode(array( "value1"=>"data for value1","value2"=>"data for value2","value3"=>"data for value3"));