diff options
| author | Christian Hodgden <chrhodgden@gmail.com> | 2026-02-03 16:25:44 -0600 |
|---|---|---|
| committer | Christian Hodgden <chrhodgden@gmail.com> | 2026-02-03 16:25:44 -0600 |
| commit | 7b2b1f6b837dbca3dd08cb89836cb1ae098c2bd8 (patch) | |
| tree | 2e9f027245a84e9c1372f88196ebbdfbf58bf920 /content-demo/demo-posts/demo_repo.md | |
Initial Commit.main
Yay
Diffstat (limited to 'content-demo/demo-posts/demo_repo.md')
| -rw-r--r-- | content-demo/demo-posts/demo_repo.md | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/content-demo/demo-posts/demo_repo.md b/content-demo/demo-posts/demo_repo.md new file mode 100644 index 0000000..7ac5847 --- /dev/null +++ b/content-demo/demo-posts/demo_repo.md @@ -0,0 +1,75 @@ +--- +title: Ultra Hello World Program +keywords: [python, sql, programming] +params: + themeColorCheck: false + accentHue: 120 +--- +*Correctly identifies greeting to user.* + +This repository is mostly used for demonstration purposes in my network. It is a python script implementing an advanced algorithm to correctly greet the user. This algorithm also stores session results in an SQLite database to improve accuracy in future sessions. + +## The python code + +```python +#!/usr/bin/python3 + +import os +from random import * +from sqlite3 import * +import getpass + + +if not os.path.isfile(os.path.join(os.getcwd(), 'sexy.db')): + chk_1 = True +else: + chk_1 = False + +con = connect('sexy.db') +cur = con.cursor() + +if chk_1: + cur.execute("CREATE TABLE sexy_tbl (username TEXT, chk INTEGER);") + +chk_2 = randint(0,1) +username = getpass.getuser() +param = {"username" : username, "chk" : chk_2} + +cur.execute("INSERT INTO sexy_tbl (username, chk) VALUES(:username, :chk);", param) + +k = [] +res = cur.execute(''' + SELECT sum(chk) as sum_chk, count(chk) as count_chk + FROM sexy_tbl + WHERE username = :username;''', + param) + +for desc in cur.description: k.append(desc[0]) +row = res.fetchone() +rcd = dict(zip(k,row)) + +chk_3 = (rcd["sum_chk"]/rcd["count_chk"]) > 0.5 + +if chk_3: + print("\033[95mheyy sexy!\033[0m") +else: + print("Hello World!") + +diag = input() + +if 'sexy' in diag.lower(): + print(f"Your sexy score is {rcd['sum_chk']} out of {rcd['count_chk']}.") + input() + +con.commit() +cur = None +con = None +``` + +## SQL Syntax Highlighting Check + +```sql +SELECT sum(chk) as sum_chk, count(chk) as count_chk +FROM sexy_tbl +WHERE username = :username; +``` |