GodOfThunder

joined 2 years ago
MODERATOR OF
[–] GodOfThunder@lemm.ee 7 points 2 years ago* (last edited 2 years ago)
[–] GodOfThunder@lemm.ee 23 points 2 years ago* (last edited 2 years ago)

Humans are more influenced by emotions than logic, which means that critical thinking alone may not convince them. Only those who are receptive to logical reasoning can be persuaded.

A video about it

[–] GodOfThunder@lemm.ee 19 points 2 years ago

Imagus is a browser extension for Firefox that allows users to enlarge images and display images/videos from links with a simple mouse-over. It is similar to the Hover Zoom extension, which is a popular tool for browsing memes and gifs on desktop. However, Hover Zoom has been flagged as spyware, so users may want to consider using Imagus instead. Imagus works with a wider range of links than Hover Zoom, including those from imgur. The extension also has customizable settings, including an expandable set of rules for getting larger images, media, or other content.

[–] GodOfThunder@lemm.ee 19 points 2 years ago (1 children)

I've saved this, but it would be nice to see the syntax somewhere in the search engine

[–] GodOfThunder@lemm.ee 29 points 2 years ago

A function decorator: You can create a decorator that handles the connection and cursor creation and passes the cursor to the decorated function.

import sqlite3
from functools import wraps

DB_FILE = "your_database_file.db"

def with_cursor(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        conn = sqlite3.connect(DB_FILE)
        cursor = conn.cursor()

        result = func(cursor, *args, **kwargs)

        conn.commit()
        cursor.close()
        conn.close()

        return result

    return wrapper

@with_cursor
def insert_post_to_db(cursor: sqlite3.Cursor, issue: Issue, lemmy_post_id: int) -> None:
    cursor.execute(
        "INSERT INTO posts (issue_url, lemmy_post_id, issue_title, issue_body) VALUES (?, ?, ?, ?)",
        (issue.url, lemmy_post_id, issue.title, issue.formatted_body),
    )
[–] GodOfThunder@lemm.ee 29 points 2 years ago (1 children)

A context manager: Create a context manager that handles the connection and cursor creation, as well as closing the connection when done. This way, you can use the with statement to manage the connection and cursor in your functions.

import sqlite3

DB_FILE = "your_database_file.db"

class DatabaseConnection:
    def __enter__(self):
        self.conn = sqlite3.connect(DB_FILE)
        self.cursor = self.conn.cursor()
        return self.cursor

    def __exit__(self, exc_type, exc_val, exc_tb):
        self.conn.commit()
        self.cursor.close()
        self.conn.close()

def insert_post_to_db(issue: Issue, lemmy_post_id: int) -> None:
    with DatabaseConnection() as cursor:
        cursor.execute(
            "INSERT INTO posts (issue_url, lemmy_post_id, issue_title, issue_body) VALUES (?, ?, ?, ?)",
            (issue.url, lemmy_post_id, issue.title, issue.formatted_body),
        )
[–] GodOfThunder@lemm.ee 22 points 2 years ago

This is so cool. It's exactly what I had in mind when thinking of a modern bash alternative.

[–] GodOfThunder@lemm.ee 17 points 2 years ago

Github style:

> If you need to find a post, don't use search engines or indexers, use lemmy's own search page, which allows you to filter by community if you wish. Its been a concious decision from the beginning to not favor SEO over simple urls.
> 
> *Originally posted by @dessalines in [#839 (comment)](https://github.com/LemmyNet/lemmy-ui/issues/839#issuecomment-1304368786)*

Result:

If you need to find a post, don't use search engines or indexers, use lemmy's own search page, which allows you to filter by community if you wish. Its been a concious decision from the beginning to not favor SEO over simple urls.

Originally posted by @dessalines in #839 (comment)

[–] GodOfThunder@lemm.ee 0 points 2 years ago

I don't care about the Bible, it's just an expression. I think.

[–] GodOfThunder@lemm.ee 32 points 2 years ago* (last edited 2 years ago) (2 children)
> *[@username](profile_link)* said:
>
> > Original quote from the person
>
> Source: [Link to the source](source_link)

For example:

> [@GodOfThunder@lemm.ee](https://lemm.ee/u/GodOfThunder) said:
>
> > How would you quote someone using CommonMark markdown syntax?
>
> [Source](https://lemm.ee/post/1063209)

Result:

@GodOfThunder@lemm.ee said:

How would you quote someone using CommonMark markdown syntax?

Source

[–] GodOfThunder@lemm.ee 7 points 2 years ago* (last edited 2 years ago) (3 children)
[–] GodOfThunder@lemm.ee 23 points 2 years ago* (last edited 2 years ago)

Which is why we should make the implementer's job easier by providing only the relevant information instead of wasting their time with a flood of comments on the issue tracker.

view more: ‹ prev next ›