I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!
\
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// variant 1 | |
function getPrefersReducedMotion() { | |
const mediaQueryList = window.matchMedia( | |
'(prefers-reduced-motion: no-preference)' | |
); | |
const prefersReducedMotion = !mediaQueryList.matches; | |
return prefersReducedMotion; | |
} | |
// variant 2 - complex with event |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum CitySize { | |
Town, // approximate residents: 1_000 | |
City, // approximate residents: 10_000 | |
Metropolis, // approximate residents: 1_000_000 | |
} | |
struct City { | |
description: String, | |
residents: u64, | |
is_coastal: bool, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct City { | |
description: String, | |
residents: u64, | |
is_coastal: bool | |
} | |
fn new_city(residents: u64, is_coastal: bool) -> City { | |
if is_coastal { | |
City { | |
description: format!("a *coastal* city of approximately {} residents", residents), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Вывести в форме Product в админке, дополнительное поле чтобы заполнить город, не создавая дополнительного поля в модели Product | |
class Product(models.Model): | |
title = models.CharField(max_length=250, verbose_name='Название города') | |
class City(models.Model): | |
name = models.CharField(max_length=250, verbose_name='Название города') | |
products = models.ManyToManyField(Bath, blank=True, verbose_name='Бани', related_name='city') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def forms_valid(self, form, inlines): #yes, f%%ng form(s)_valid, yeh... | |
""" | |
If the form and formsets are valid, save the associated models. | |
""" | |
self.object = form.save(commit=False) | |
self.object.author = self.request.user | |
form.save(commit=True) | |
for formset in inlines: | |
formset.save() | |
return HttpResponseRedirect(self.get_success_url()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
path('/filter/', views.FilterView.as_view(), name="type_filter"), | |
path('/filter/<page_slug>', views.FilterView.as_view(), name="type_filter_with_slug"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What you can do to fix this is the following: | |
Click on the query you want to edit the enum on. | |
Click the query name on the top. This will open up an object. In here you want to add the enum. | |
Click save query and rerun the queries. | |
Now the enum will show up in your view. | |
If you would now double click the enum you want to edit, it will give you a dialog modal in which you can now edit the enum. Add the items you want and click the cross in the top right of the modal. | |
Don’t forget to click the save to database button in the bottom right of your screen. | |
You’ve now successfully edited your enum. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prisma generate --env-file variables.env | |
--- prisma.yml | |
endpoint: ${env:PRISMA_ENDPOINT} | |
datamodel: datamodel.prisma | |
# secret: ${env:PRISMA_SECRET} | |
hooks: | |
post-deploy: | |
- graphql get-schema -p -prisma |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
lintOnSave: false | |
} |
NewerOlder