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 / 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"));
@guangrei
guangrei / script.php
Last active June 8, 2024 14:06
[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 / 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;
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 / 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!"
@guangrei
guangrei / fixJson.php
Created November 7, 2018 14:54
fix json on iis response
<?php
use Clue\React\Buzz\Browser;
use Psr\Http\Message\ResponseInterface;
require "vendor/autoload.php";
$url = "http://jendela.data.kemdikbud.go.id/api/index.php/cwilayah/wilayahKabGet";
$loop = React\EventLoop\Factory::create();
$browser = new Browser($loop);
$browser->get($url)->then(
@guangrei
guangrei / localtunnel.sh
Created November 14, 2018 16:05
localtunnel.me auto reconnect
#!/bin/bash
DOMAIN=$1
PORT=$2
if [ $# -eq 0 ] ; then
echo "No arguments supplied"
echo "Usage: command DOMAIN PORT"
exit 1
fi
@guangrei
guangrei / .bashrc
Created December 28, 2018 13:00
c9.io ~/.bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
. /etc/apache2/envvars
# If not running interactively, don't do anything else
[ -z "$PS1" ] && return
# don't put duplicate lines or lines starting with space in the history.
@guangrei
guangrei / str_replace_word.php
Created November 22, 2020 10:09
php word replace , online demo https://ideone.com/94EjGy
<?php
function str_replace_word($cari, $ganti, $kalimat)
{
$cek = strpos($kalimat, " ");
if ($cek != false) {
$token = explode(" ", $kalimat);
$map = array_map(function($val) use ($cari, $ganti)
{
return $val === $cari ? $ganti : $val;
@guangrei
guangrei / server.py
Last active January 1, 2021 07:14
python web tanpa framework
from http.server import BaseHTTPRequestHandler
from urllib import parse
from http.server import HTTPServer
class GetHandler(BaseHTTPRequestHandler):
def do_GET(self):
parsed_path = parse.urlparse(self.path)
res = """