Skip to content

Instantly share code, notes, and snippets.

@akmalxxx
akmalxxx / hijri.py
Created June 24, 2018 01:22
Umm Al-Qura Python 3 Calendar
View hijri.py
# File-desc: Hijri - Gregorian date converter (Umm al-Qurra)
# Dep:
# Ref: 1) https://github.com/tytkal/python-hijiri-ummalqura
# 2) http://www.staff.science.uu.nl/~gent0113/islam/ummalqura.htm
# 3) http://keith-wood.name/calendars.html
# ---------------------------------------
import math
def tohijri(year, month, day):
View sample_script_data.py
from script import t, r, topic, end, tpl
tpl('no_answer', ['I cannot answer that yet', 'I don\' have answer for that'])
tpl('no_answer', ['Saya tak ada jawapan buat masa ini', 'Saya tiada maklumat tersebut'], 'ms')
t('cancel')
r('Let\'s move on, anything else i can help? ', fun='cancel_topic')
t('batal')
r('Baiklah, apa lagi yang boleh saya bantu?', fun='cancel_topic')
View fb_upload.py
import os
import requests
from requests_toolbelt import MultipartEncoder
def send_attachment(page_token, recipient_id, filetype, path): # filetype = image, audio, video, file
payload = {
'recipient':{
{ 'id':recipient_id }
},
'message':{
View tint example
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.EditText;
import android.os.Build;
import android.support.v7.internal.widget.TintTypedArray;
public class EditTextEx extends EditText {
View snippet.java
/* Storage access check */
public static boolean isExternalStorageWritable() {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) return true;
return false;
}
public static boolean isExternalStorageReadable() {
String state = Environment.getExternalStorageState();
@akmalxxx
akmalxxx / DBHelper.java
Last active November 7, 2017 18:24
SQLite Android Wrapper
View DBHelper.java
/*
Source -> http://www.michenux.net/android-database-sqlite-creation-upgrade-245.html
- make sql file like below and save inside /assets/sql/
Create: mydb-create.sql
Upgrades: mydb-upgrade-101.sql, mydb-upgrade-102.sql
Do Not Edit (unless you know what you're doing)
*/
View DividerItemDecoration.java
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.Canvas;
View MakkahCalendar.java
/*
Makkah Calendar
http://www.makkahcalendar.org/en/hijriCalendar.php
Usage: String today = MakkahCalendar.getSimpleDate(null);
*/
import java.util.Calendar;
public final class MakkahCalendar {
@akmalxxx
akmalxxx / HijriCalendar.java
Last active April 8, 2018 08:53
Umm Al-Qura Java Calendar
View HijriCalendar.java
/*
Umm Al-Qura Islamic Calendar
valid from 1356 AH (14 March 1937 CE) to 1500 AH (16 November 2077 CE).
Outside this interval, the converter will give erroneous results.
ported from javascript from:
http://www.staff.science.uu.nl/~gent0113/islam/ummalqura_converter.htm#top
*/
import java.util.Calendar;