Skip to content

Instantly share code, notes, and snippets.

@adamchainz
adamchainz / _base.html
Created Jan 8, 2021
Django HTMX CSRF setup
View _base.html
<script src="{% static 'app.js' %}" data-csrftoken="{{ csrf_token }}"></script>
View htmx crsf docs.md

CRSF Handling

Handling CRSF in htmx is server-side platform dependent, but typically involves something like the following to add a token to a header or parameter:

Vanilla JS

In pure javascript you can listen to the htmx:configRequest event and set the token there:

@kocienda
kocienda / SJ-D8.txt
Last active Dec 2, 2020
D8: Steve Jobs
View SJ-D8.txt
Things are packages of emphasis. Some things are emphasized in a product. Some things are not done as well in a product. Some things are chosen not to be done at all in a product. Different people make different choices, and if the market tells us we’re making the wrong choices, we listen to the market. We’re just people running this company. We’re trying to make great products for people, and so, at least we have the courage of our convictions to say, “We don’t think this is part of what makes a great product. We’re going to leave it out.”
Some people are not going to like that. They’re going to call us names. It’s not going to be a certain company’s vested interest that we do that, but we’re going to take the heat, because we want to make the best product in the world for customers. We’re going to instead focus our energy on these technologies, which we think are in their ascendency, and we think are going to be the right technologies for customers.
And you know what? They’re paying us to make those cho
@slorber
slorber / react-navigation-tree.jsx
Last active Jan 6, 2021
react-navigation-tree.jsx
View react-navigation-tree.jsx
const App = createAppContainer(
createStack({
LoggedSwitch: createSwitch({
// When user is authenticated
LoggedIn: createStack({
// The logged in root is generally a tab or drawer navigator
LoggedInRoot: createTabsOrDrawer({
@jefftriplett
jefftriplett / python-django-postgres-ci.yml
Last active Jan 12, 2021
This is a good starting point for getting Python, Django, Postgres running as a service, pytest, black, and pip caching rolling with GitHub Actions.
View python-django-postgres-ci.yml
name: CI
on: [push]
jobs:
test:
runs-on: ubuntu-latest
services:
@jefftriplett
jefftriplett / modd.conf
Last active Jul 4, 2019
Django + Modd + Maybe Docker
View modd.conf
# Run the test suite if a source or test file changes
**/tests/test_*.py {
# prep +onchange: pytest @dirmods
prep +onchange: pytest @mods
}
requirements.txt {
# prep +onchange: pytest @dirmods
prep +onchange: "
pip install -U -r requirements.txt
@sw-yx
sw-yx / 1.md
Last active Apr 1, 2021
Learn In Public - 7 opinions for your tech career
View 1.md

2019 update: this essay has been updated on my personal site, together with a followup on how to get started

2020 update: I'm now writing a book with updated versions of all these essays and 35 other chapters!!!!

1. Learn in public

If there's a golden rule, it's this one, so I put it first. All the other rules are more or less elaborations of this rule #1.

You already know that you will never be done learning. But most people "learn in private", and lurk. They consume content without creating any themselves. Again, that's fine, but we're here to talk about being in the top quintile. What you do here is to have a habit of creating learning exhaust. Write blogs and tutorials and cheatsheets. Speak at meetups and conferences. Ask and answer things on Stackoverflow or Reddit. (Avoid the walled gardens like Slack and Discourse, they're not public). Make Youtube videos

@webyneter
webyneter / .travis.yml
Last active Oct 9, 2019
Travis CI + Codecov + Docker / Docker Compose (+ Python / Django, but that's not the point anyway)
View .travis.yml
# This setup took me a few hours to come up with; codecov docs turned out to be useless in the end.
# With this gist I hope to be the last one to have ever faced it again :)
sudo: required
services:
- docker
before_install:
- docker version
View main.py
import boto3
import certbot.main
import datetime
import os
import raven
import subprocess
def read_and_delete_file(path):
with open(path, 'r') as file:
contents = file.read()
@Stiivi
Stiivi / cubes2.0-goals.md
Last active Aug 5, 2017
Cubes 2.0 Goals
View cubes2.0-goals.md

Cubes 2.0

Hi there. After almost two years of none or very sparse activity due to life and career situation, I’m committing myself back to the Cubes project. It will take some time to ramp-up, but we will eventually get there. I apologize for not meeting expectations lately and for letting the framework, mailing list and discussions go stale.

I got quite a lot of useful feedback and recommendations from users and people in the domain and that revived my motivation to spend more of my spare time to make Cubes better and modern OLAP toolkit.

Now, let’s move forward. To do any improvements or changes, Cubes needs quite a lot of housekeeping. The whole 2.0 release addresses that. Only when we have consistent, well-defined interface, when we have goals and equally importantly non-goals set, we can start growing Cubes again.

Links: