Skip to content

Instantly share code, notes, and snippets.

View marteinn's full-sized avatar
✖️
🥕

Martin Sandström marteinn

✖️
🥕
View GitHub Profile

Phoenix 1.4.x to 1.5.0 upgrade instructions

Phoenix 1.5 requires Elixir >= 1.7. Be sure your existing version is up to date by running elixir -v on the command line.

Install the new phx.new project generator

$ mix archive.uninstall phx_new
$ mix archive.install hex phx_new 1.5.0
@justincy
justincy / README.md
Last active April 5, 2024 22:19
Configure Storybook to work with Next.js, TypeScript, and CSS Modules

In addition to the Storybook for React setup, you'll also need to install these packages:

npm i -D @babel/core babel-loader css-loader style-loader
@tomdyson
tomdyson / wagtail-on-zappa.md
Last active June 20, 2023 02:22
Wagtail on AWS Lambda, with Zappa

Wagtail on AWS Lambda, with Zappa

Install Wagtail and Zappa, and create an empty site:

pip install wagtail zappa zappa-django-utils
pip install pip==9.0.3 # see https://github.com/Miserlou/Zappa/issues/1471
wagtail start foo

Side Effects

A few of the Enzyme examples show using a class method of a component, but instead of using the instance() function to get the class instance and test the method's return value, instead they simulate events, then check the side effects of those events called from the method you want to test.

In the below example, unit test coverage will say the Failure part of the onNameBlur method was covered.

AddUser.js

class AddUserForm extends React.Component {
@pydanny
pydanny / django_local_settings.py
Last active December 12, 2018 12:31
running local unverified SSL on Django and Flask (don't do this in production!!!)
from .common import * # noqa
DEBUG = True
INSTALLED_APPS += ('django_extensions',)
# Snip all the other stuff
@Valian
Valian / profile_middleware.py
Created May 6, 2017 14:13
Detailed Hotshot profiler middleware for Django
# Orignal version taken from http://www.djangosnippets.org/snippets/186/
# Original author: udfalkso
# Modified by: Shwagroo Team and Gun.io
# Further modified by: Jakub Skalecki (https://rock-it.pl)
import hotshot
import hotshot.stats
import textwrap
import os
@alexgleason
alexgleason / m2m.py
Last active May 9, 2023 17:49
Many to many relationships in Wagtail
from django.db import models
from wagtail.wagtailsnippets.models import register_snippet
from wagtail.wagtailcore.models import Page
from modelcluster.fields import ParentalKey
from wagtail.wagtailadmin.edit_handlers import InlinePanel
@register_snippet
class Category(models.Model):
@paulirish
paulirish / what-forces-layout.md
Last active May 6, 2024 07:54
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@koreno
koreno / README.md
Last active April 1, 2020 10:44
'rebaser' improves on 'git rebase -i' by adding information per commit regarding which files it touched.

Prebase

git-prebase improves on 'git rebase -i' by adding information per commit regarding which files it touched.

  • Each file gets an alpha-numeric identifier at a particular column, a list of which appears below the commit list. (The identifiers wrap around after the 62nd file)
  • Commits can be moved up and down safely (without conflicts) as long as their columns don't clash (they did not touch the same file).

Installation

Add the executable to your path and git will automatically expose it as

@nkbt
nkbt / .eslintrc.js
Last active May 5, 2024 07:31
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {