Skip to content

Instantly share code, notes, and snippets.

View H3lllfir3's full-sized avatar
🏠
Working from home

H3llf!r3 H3lllfir3

🏠
Working from home
View GitHub Profile
@H3lllfir3
H3lllfir3 / gist:dba29c9a781db761da121e51171950b4
Created August 20, 2021 13:15
لیست لغات زبان انگلیسی بر اساس تکرار
# لیست کتابها
1. Automate the Boring Stuff with Python
2. Serious Python
3. expert python programming
4. Python Crash Course
5. headfirst python
6. python document
('the', 86496)
@H3lllfir3
H3lllfir3 / urls.py
Created May 9, 2020 20:16
main url
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('polls/', include('polls.urls')),
path('admin/', admin.site.urls),
]
@H3lllfir3
H3lllfir3 / urls.py
Created May 9, 2020 18:17
first urls
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]
@H3lllfir3
H3lllfir3 / views.py
Created May 9, 2020 18:05
first django view
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world. You're at the polls index.")
@H3lllfir3
H3lllfir3 / .md
Last active November 11, 2019 17:39
markdown

Foobar

Foobar is a Python library for dealing with word pluralization.

Installation

Use the package manager pip to install foobar.

pip install foobar
@H3lllfir3
H3lllfir3 / .txt
Last active November 11, 2019 17:39
example of markdown
# Foobar
Foobar is a Python library for dealing with word pluralization.
## Installation
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install foobar.
```bash
pip install foobar
@H3lllfir3
H3lllfir3 / .py
Created November 6, 2019 13:42
if condition
#good
if not seq:
if seq:
if process_ok:
#bad
if len(seq):
if not len(seq):
@H3lllfir3
H3lllfir3 / .py
Created November 6, 2019 13:31
conditions
#good
if foo.startswith('bar'):
if foo.endswith('bar'):
#bad
if foo[:3] == 'bar':
if foo[7:10] == 'bar':
@H3lllfir3
H3lllfir3 / .py
Last active August 21, 2020 15:59
Sequence Unpacking
>>> nums = [10, 20, 30]
>>> a, b, c = nums
>>> a
10
>>> c
30
>>> student_tuple = ('Ayoub', [98, 85, 87])
>>> first_name, grades = student_tuple
>>> first_name
'Ayoub'
@H3lllfir3
H3lllfir3 / .py
Last active November 6, 2019 13:09
Dictionary Comprehension
>>> numbers = {num:num ** 2 for num in range(5)}
>>> numbers
{0: 0, 1: 1, 2: 4, 3: 9, 4: 16}
>>> numbers = {x:x ** 2 for x in [1, 2, 3, 4, 5, 6] if x % 2 == 0}
>>> numbers
{2: 4, 4: 16, 6: 36}
>>> names = ['ayoub', 'reza', 'mersad']
>>> names = {f:f.capitalize() for f in names}
{'ayoub': 'Ayoub', 'reza': 'Reza', 'mersad': 'Mersad'}