Skip to content

Instantly share code, notes, and snippets.

View ak4zh's full-sized avatar
🏔️
Working from mountains

ak4zh

🏔️
Working from mountains
View GitHub Profile
@ak4zh
ak4zh / migration.sql
Created September 22, 2022 08:48
Double Entry Book Keeping with Journals and Voucher
CREATE TABLE public.vouchers (
id serial PRIMARY KEY,
name text NOT NULL
);
INSERT INTO vouchers
(name)
VALUES
('Sales'),
('Purchase'),
@ak4zh
ak4zh / accounting.sql
Last active June 2, 2024 09:57 — forked from NYKevin/accounting.sql
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE account_groups
(
id bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 9223372036854775807 CACHE 1 ),
name text COLLATE pg_catalog."default" NOT NULL,
account_group_id bigint,
CONSTRAINT account_types_pkey PRIMARY KEY (id),
CONSTRAINT account_groups_account_group_id_fkey FOREIGN KEY (account_group_id)
REFERENCES public.account_groups (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
@ak4zh
ak4zh / build_keyboard_python_telegram_bot
Created July 12, 2018 22:48
custom build_keyboard helper function, modified version of build_menu in code snippets page
def build_keyboard(buttons, n_cols=2, resize=True, auto_cols=False, auto_arrange=False, header_buttons=None, footer_buttons=None):
text_cols = {1: 8, 2: 7, 3: 6, 4: 5} # dict text size as key and possible columns as value
longest_text, longest_button = 1, buttons[0]
lengths_list = [] # to find second largest text
for button in buttons:
length = len(button.text if isinstance(button, InlineKeyboardButton) else button)
lengths_list.append(length)
longest_button = button if length >= longest_text else longest_button
longest_text = length if length >= longest_text else longest_text
@ak4zh
ak4zh / 20.py
Last active April 30, 2017 19:25
import turtle
turtle.hideturtle()
data = {"P": 'red', "y": 'dark blue', "t": 'green', "h": 'purple', "o": 'orange', "n": 'purple'}
for key in data:
turtle.color(data.get(key))
turtle.write( key, move= False, align="center", font=("comic sans", 22, "bold") )
turtle.penup()
turtle.forward(22)
turtle.pendown()
@ak4zh
ak4zh / 18.py
Last active April 30, 2017 19:09
18.py
import turtle
turtle.hideturtle()
turtle.color('yellow')
turtle.begin_fill()
turtle.width(5)
turtle.penup()
turtle.goto(0,0)
turtle.pendown()
turtle.forward(150)
turtle.left(90)
@ak4zh
ak4zh / how_to_make_egg.py
Created April 27, 2017 08:53
how_to_make_egg.py
import time
import random
room = ('rooster', 'hen') #must be tuple
effort = random.randint(5,10)
egg = 0
for times in range(effort):
egg += round((len(room[0]) / len(room[1])) + (len(room[1]) / len(room[0])))
time.sleep(2) #don't worry time is not too less, there's a reason rooster is called cock
#change time as per your rooster
@ak4zh
ak4zh / get_payload.py
Created April 26, 2017 08:50
get_payload.py
import requests
from bs4 import BeautifulSoup
import re
import clipboard
clipboard = clipboard.get()
if 'http' not in clipboard:
url = input('Enter the URL: ') #Enter the url address of website you want to generate payload template for
else:
url = (re.search('(http\S+)', clipboard)).group(1)