Skip to content

Instantly share code, notes, and snippets.

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

Priyadi Iman Nurcahyo priyadi

🏠
Working from home
View GitHub Profile
@priyadi
priyadi / togglekeyboard.sh
Last active May 13, 2017 20:00
Script to toggle Thinkpad Keyboard+Trackpoint on and off
#!/bin/sh
# inspired from https://askubuntu.com/questions/160945/is-there-a-way-to-disable-a-laptops-internal-keyboard
KEYBOARD="AT Translated Set 2 keyboard"
MOUSE="TPPS/2 IBM TrackPoint"
KEYBOARDMASTER="Virtual core keyboard"
MOUSEMASTER="Virtual core pointer"
ICON=~/bin/keyboard-on.png
@priyadi
priyadi / hisab-awal-bulan.py
Created May 4, 2019 05:51
Script Perhitungan Hisab Awal Bulan Hijriah
#!/usr/bin/env python
'''
Script sederhana hisab bulan baru hijriah.
Mungkin tidak 100% akurat.
Perlu pyephem (pip install ephem).
'''
import ephem
from datetime import datetime, timedelta
@priyadi
priyadi / lunar-eclipse-prediction.py
Created May 19, 2019 18:31
Script for prediction the occurences of a lunar eclipse in the 21st century.
#!/usr/bin/env python
'''
lunar-eclipse-prediction.py
Original: https://github.com/flatearthws/eclipse-calculations/blob/master/lunar-eclipse-prediction.py
Shows the occurences of a lunar eclipse in the 21st century.
Works by iterating every hour in the 21st century and calculating if the
separation between the Moon and the Sun is more than 180°-0.9° (= 179.1°).
The number 0.9° is hardcoded for simplicity, for more accuracy, it
should be computed from the distance of the Moon and the Sun.
@priyadi
priyadi / hilal.py
Last active May 20, 2019 14:41
Calculation For the Beginning of a Month in the Hijri Calendar
#!/usr/bin/env python
'''
A simple script to calculate the beginning of month
in the Hijri calendar. For educational purposes only.
'''
import ephem
from datetime import datetime, timedelta
# start and end time
@priyadi
priyadi / ReadOnly.php
Created January 21, 2022 06:30
A wrapper to make a PHP object read only recursively.
<?php
namespace Rekalogika\Util;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
/**
* Make an object read only by recursively only allowing get*, is*, has*
* methods, and specifically for Doctrine Collection: contains, containsKey,