Skip to content

Instantly share code, notes, and snippets.

View hossainchisty's full-sized avatar
🌏
Crafting code to build a better digital world.

Hossain Chisty hossainchisty

🌏
Crafting code to build a better digital world.
View GitHub Profile
@sXakil
sXakil / generator_string.py
Last active March 13, 2021 07:14
Python code for the string generator used in this ASCII art code: https://gist.github.com/sXakil/d7e88da11830dc1370cb7f89b5ebaae1
"""
Copy and paste any shape using space and '|', add an '*' to indicate the end of your stream
example input:
|| ||
|| || ||
|| || ||
||| |||*
STart each line with at least one space and make sure your shape is no more than 60 characters in width to maintain general ASCII range
"""
import re

drf-cheat-sheet

A collection of anything from basics to advanced recommended methods and usages with Django REST Framework for creating browsable and awesome web API's. This could also serve as a quick reference guide.

Here is DRF's official documentation in case you need everything in detail.

Why Django REST Framework?

Summarized from the official docs:

  • Web browsable API
  • Serialization that supports ORM and non-ORM data sources.

Cheatsheet for Django QuerySets

Current Django Version: 2.2

Methods that return new QuerySets

Can be chained:

Entry.objects.filter(**kwargs).exclude(**kwargs).order_by(**kwargs)
@rbtsolis
rbtsolis / middleware.py
Created May 3, 2018 02:46
Django Access the Request or User Object Inside the Models and Signals
# 1) Create a middlewares/middlewares.py file and copy this:
import threading
class RequestMiddleware:
def __init__(self, get_response, thread_local=threading.local()):
self.get_response = get_response
self.thread_local = thread_local
# One-time configuration and initialization.
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 8, 2024 14:54
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@raviwu
raviwu / notes_soft_skills.md
Last active May 5, 2022 06:43
[Notes] Soft Skills: The software developer's life manual

Page 47

This kind of mindset is crucial to managing your career, because when you start to think of yourself as a business, you start to make good business decisions.

Page 52

Every step you take without a clear direction is a wasted step. Don’t randomly walk through life without a purpose for your career.

Your big goal should be something not too specific, but clear enough that you can know if you’re steering toward it or not. Think about what you want to ultimately do with your career.

@wojteklu
wojteklu / clean_code.md
Last active May 9, 2024 08:20
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@jaysonrowe
jaysonrowe / FizzBuzz.py
Created January 11, 2012 03:05
FizzBuzz Python Solution
def fizzbuzz(n):
if n % 3 == 0 and n % 5 == 0:
return 'FizzBuzz'
elif n % 3 == 0:
return 'Fizz'
elif n % 5 == 0:
return 'Buzz'
else:
return str(n)