Skip to content

Instantly share code, notes, and snippets.

View engineervix's full-sized avatar
🎯
Focusing

Victor Miti engineervix

🎯
Focusing
View GitHub Profile
// Core assets
let coreAssets = [];
// On install, cache core assets
self.addEventListener('install', function (event) {
// Cache core assets
event.waitUntil(caches.open('app').then(function (cache) {
for (let asset of coreAssets) {
cache.add(new Request(asset));
@dkirkham
dkirkham / models.py
Created July 17, 2021 00:31
This validator checks the amount of text in a RichTextField, by stripping away basic formatting markup. It also incorporates an adjustment for markup that causes line breaks.
from wagtail.core.models import Page
from wagtail.core.fields import RichTextField
from proj.richtext_validator import RichTextLengthValidator
class AuthorPage(Page):
biography = RichTextField(
max_length=3600,
validators=[RichTextLengthValidator(3000, line_length=50)],
@thclark
thclark / blocks.py
Created May 23, 2019 19:18
Wagtail serializers for streamfield - example of customizing per-block
class HeroBlock(StructBlock):
content = StreamBlock([
('button', StructBlock([
('text', CharBlock(required=False, max_length=80, label='Label')),
('url', URLBlock(required=False, label='URL')),
], label='Call to action', help_text='A "call-to-action" button, like "Sign Up Now!"')),
('video', EmbedBlock(label='Video')),
('quote', StructBlock([
('text', TextBlock()),
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active April 15, 2024 02:19
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@pv8
pv8 / fix-venv.sh
Last active September 1, 2022 03:33
Fix virtualenv symlinks after upgrading python with Homebrew and running brew cleanup
#!/usr/bin/env bash
#
# Fix virtualenv symlinks after upgrading python with Homebrew and then running
# `cleanup`.
#
# After upgrading Python using Homebrew and then running `brew cleanup` one can
# get this message while trying to run python:
# dyld: Library not loaded: @executable_path/../.Python
# Referenced from: /Users/pablo/.venv/my-app/bin/python
# Reason: image not found
@ekinertac
ekinertac / field_blank_null.md
Last active April 15, 2024 08:38
Django null/blank field explanation
Fields null=True blank=True
CharField, TextField, SlugField, EmailField, CommaSeparatedIntegerField DON'T Django's convention is to store empty values as the empty string, and to always retrieve NULL or empty values as the empty string for consistency. OK Do this if you want the corresponding form widget to accept empty values. If you set this, empty values get stored as empty strings in the database.
BooleanField DON'T Use NullBooleanField instead. DON'T
IntegerField, FloatField, DecimalField OK If you wabt to be able to set the value to NULL in the database OK if you want the corresponding form widget to accept empty values. if so out will also want to set null=True
DateTimeField, DateField, TimeField OK if you want to be able to set the value to NULL in the database. OK If you want the corresponding form widget to accept empty values, or if you are using auto now or auto now add. If so, you will al
@rxaviers
rxaviers / gist:7360908
Last active May 4, 2024 17:52
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@zabbarob
zabbarob / anki.css
Created May 7, 2013 22:45
Anki cards, CSS and HTML templates.
@font-face {
font-family: junicode;
src: url('_junicode.ttf');
}
.card, table {
font-family: Helvetica, sans-serif, junicode;
font-size: 20px;
text-align: center;
color: #d03030;
background-color: #fafaf5;
@dupuy
dupuy / README.rst
Last active April 23, 2024 23:38
Common markup for Markdown and reStructuredText

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.