Skip to content

Instantly share code, notes, and snippets.

View cyberfly's full-sized avatar

Muhammad Fathur Rahman cyberfly

View GitHub Profile
mode model description
ask
Claude Sonnet 4
Find Code Smells

Please review and analyze the ${selection} and identify potential areas for improvement related to code smells, readability, maintainability, performance, security, etc. Do not list issues already addressed in the given code. Focus on providing up to 5 constructive suggestions that could make the code more robust, efficient, or align with best practices. For each suggestion, provide a brief explanation of the potential benefits. After listing any recommendations, summarize if you found notable opportunities to enhance the code quality overall or if the code generally follows sound design principles. If no issues found, reply "There are no errors."

Task: Q&A Chatbot.

Instructions: You are an intelligent and professional Assistant. You have access to files to answer questions about XYZ company information. Always respond with info from either of the files.

Input: Question from User as text.

Output: Concise and short answer as plain text.

@cyberfly
cyberfly / article_list.html
Last active May 14, 2024 02:44
example use case: after polling get how many pending article left, once it become zero, trigger event to ask article list to get latest data
<div
hx-get="/api/v2/{{ACTIVE_PROJECT_CODE}}/refresh_article_list"
hx-trigger="finishArticleGeneration from:body"
hx-select="#article_list_content"
hx-target="this"
>
<div id="article_list_content">
<!--do something-->
</div>
</div>
<form
id="keyword_suggestions_form"
hx-post="/api/v2/keyword_suggestions"
hx-target="#keywords_container"
hx-indicator="#loader_container"
hx-on:htmx:before-request="emptyDiv('#keywords_container')"
hx-trigger="submit[!isFieldEmpty('#seed_keyword')], submitKeywordSearch from:body"
>
<input type="hidden" name="search_type" id="search_type" value="all_terms">
</form>
class User(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4)
email = models.CharField(unique=True, null=False, blank=False)
password_hash = models.CharField(max_length=255, null=True, blank=False)
@property
def pending_articles_count(self):
return self.articles.filter(state__in=['pending_content', 'pending_translation']).count()
class Meta:
@cyberfly
cyberfly / views.py
Last active December 21, 2023 08:11
def articles(request):
filters = {
'user': request.user
}
rating = request.GET.get('rating')
search_q = request.GET.get('search_q')
if rating:
@cyberfly
cyberfly / test.html
Last active December 19, 2023 09:11
Add validation to hx-trigger. If validate false, hx-post is not trigger `hx-trigger="submit[!isFieldEmpty('#seed_keyword')]`
<form
id="keyword_suggestions_form"
hx-post="/api/v1/keywords"
hx-target="#keywords_container"
hx-indicator="#loader_container"
hx-on:htmx:before-request="emptyDiv('#keywords_container')"
hx-trigger="submit[!isFieldEmpty('#seed_keyword')], submitKeywordSearch from:body"
>
<button type="submit">Search</button>
</form>
<?php
namespace App\Libraries;
class Lookup {
// constant for MAP NEGERI ID
// const MAP_JOHOR = "001";
// const MAP_KEDAH = "002";
public function store()
{
$rules = [
'title' => 'required',
'description' => 'required',
];
if (! $this->validate($rules)) {
return redirect()->back()->withInput();
}