This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from beautifulsoup import BeautifulSoup | |
from androidhelper import Android | |
import requests | |
def hijri_now(): | |
resp = requests.get("http://beta.islamicfinder.org") | |
soup = BeautifulSoup(resp.content) | |
date_html = soup.find("div", {"class" : "date-box2"}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
class Aritmatik(object): | |
"""Aritmatik sederhana. | |
Penggunaan: | |
Buat instance dahulu dari objek Aritmatik, mempunyai value | |
optional berupa *initial_int* bila anda tidak berikan maka | |
default adalah 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
class Aritmatik(object): | |
"""Aritmatik sederhana. | |
Penggunaan: | |
Buat instance dahulu dari objek Aritmatik, mempunyai value | |
optional berupa *initial_int* bila anda tidak berikan maka | |
default adalah 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import choice | |
from string import ascii_lowercase, ascii_uppercase, digits | |
from tkinter import Tk, Entry, Button, StringVar | |
def random_string(length): | |
return ''.join(choice(ascii_lowercase + digits + ascii_uppercase) for i in range(length)) | |
root = Tk() | |
root.title('32 chars random string generator') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# contoh https://github.com/ihfazhillah/whatsapp-bot-seed/blob/master/src/router.py | |
def cobaA(): | |
print("a") | |
def cobaB(): | |
print("b") | |
routes = [("a", cobaA), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Hi, ini adalah code snippet tentang parsing multiple line text | |
biasanya dipakai untuk file file konfigurasi. | |
Berikut adalah sample_text yang saya ingin buat spt ini: | |
{'COBA': 'sedang ini adalah coba\ncoba lagi\ncoba lagi', | |
'INITIAL': 'ini adalah initial\ndan ini adalah kalimat\njuga ini'} | |
dari: sample_text dibawah ini, | |
semoga bermanfaat, dan saya tidak bingung lagi.....""" | |
sample_text = """####INITIAL#### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
"""A simple vtt to srt converter. | |
penggunaan cukup mudah, gunakan convert(path_vtt_file) dan isi file akan diubah menjadi srt file | |
dengan nama yang sama dan beda extensi. | |
Kita juga bisa tambahkan parameter lainnya yaitu path_to, berguna bila kita ingin nama yang berbeda. | |
misal: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
latihan algoritma dasar... | |
menemukan jumlah bab didalam string dibawah ini | |
s = "sldjfalskdfjbabababksjdfalkj" | |
expected = 3 | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
"""Scrape alquran surahs into json format""" | |
import requests | |
from bs4 import BeautifulSoup | |
import json | |
URL = "http://www.islamology.com/quran/fahres.asp" | |
def get_response(url=URL): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
asumsi database memiliki 3 table: book, author, genre | |
setiap table tidak memiliki kolom slug dan akan ditambahkan kolom ini | |
dan diisi slug berdasarkan: | |
- book => title | |
- genre => name | |
- author => name | |
menggunakan slugify.slugify module (pip install python-slugify) | |
contoh penggunaaan: |
OlderNewer