Skip to content

Instantly share code, notes, and snippets.

View gemcave's full-sized avatar
🎯

Aldiyar Y. gemcave

🎯
  • 08:48 (UTC +03:00)
View GitHub Profile
@gemcave
gemcave / The Technical Interview Cheat Sheet.md
Created August 5, 2022 12:34 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

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!






\

@gemcave
gemcave / reduced-motion.js
Created January 11, 2022 08:48
Check reduced-motion with js
// variant 1
function getPrefersReducedMotion() {
const mediaQueryList = window.matchMedia(
'(prefers-reduced-motion: no-preference)'
);
const prefersReducedMotion = !mediaQueryList.matches;
return prefersReducedMotion;
}
// variant 2 - complex with event
@gemcave
gemcave / lesson3.rs
Created April 2, 2021 11:07
frontendmasters rust lesson3 solution
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,
@gemcave
gemcave / lesson2.rs
Created April 2, 2021 10:41
frontendmasters rust lesson2 solution
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),
/// Вывести в форме 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')
@gemcave
gemcave / views.py
Created September 23, 2020 10:56
django-extra-views save formset
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())
@gemcave
gemcave / urls.py
Last active September 23, 2020 05:34
django redirect + filter
...
path('/filter/', views.FilterView.as_view(), name="type_filter"),
path('/filter/<page_slug>', views.FilterView.as_view(), name="type_filter_with_slug"),
@gemcave
gemcave / gist:32314a8f92a68dd9f2fe7c839f8ac685
Created January 8, 2020 16:39
permissions does not edit prisma
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.
@gemcave
gemcave / gist:19a6f750119305e025a43ec7b59df3ed
Created December 31, 2019 15:22
Generate prisma.graphql
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
@gemcave
gemcave / vue.config.js
Last active December 8, 2019 05:02
Disable esling in vue-cli
module.exports = {
lintOnSave: false
}