Skip to content

Instantly share code, notes, and snippets.

View TaijaQ's full-sized avatar

Taija Mertanen TaijaQ

View GitHub Profile
@joepie91
joepie91 / promises-faq.md
Last active June 25, 2023 09:02
The Promises FAQ - addressing the most common questions and misconceptions about Promises.

Minimum Viable Async with Node 6

With the release of Node 6.0.0, the surface of code that needs transpilation to use ES6 features has been reduced very dramatically.

This is what my current workflow looks like to set up a minimalistic and fast microservice using micro and async + await.

The promise

@TaijaQ
TaijaQ / django_mvc.py
Last active June 19, 2017 19:10
Django Model-View-Controller architecture example
# models.py (the database tables)
from django.db import models
class Book(models.Model):
name = models.CharField(max_length=50)
pub_date = models.DateField()
# views.py (the business logic)
@danni
danni / fields.py
Created March 8, 2016 08:52
Multi Choice Django Array Field
from django import forms
from django.contrib.postgres.fields import ArrayField
class ChoiceArrayField(ArrayField):
"""
A field that allows us to store an array of choices.
Uses Django 1.9's postgres ArrayField
and a MultipleChoiceField for its formfield.
@TaijaQ
TaijaQ / Processing.js
Last active June 19, 2017 19:08
Graphical tools and ideas for visual Javascript
// Learning Processing
// Daniel Shiffman
// http://www.learningprocessing.com
// Example 1-1: stroke and fill
function setup() {
createCanvas(480, 270);
stroke(0);
fill(150);
arrays = arrays.map(sort); // sort each sub-array
arrays = arrays.sort(function (ary) { return ary.length; }); // sort arrays by length, shortest will be first
var indexes = [];
for (i = 0; i < arrays.length; i++) {
indexes[i] = 0;
}
var result = [];
@DJCordhose
DJCordhose / server-side-react-redux-router.js
Created September 20, 2015 11:58
React-redux-router: How to wait until all required actions have finished before rendering on the server side
export default function renderRoute(request, reply) {
const store = configureStore();
store.dispatch(match(request.path, (error, redirectLocation, routerState) => {
if (redirectLocation) {
reply.redirect(redirectLocation.pathname + redirectLocation.search);
} else if (error) {
reply(error.message).code(500);
} else if (!routerState) {
reply('Not found').code(404);
} else {
@paulirish
paulirish / what-forces-layout.md
Last active June 26, 2024 20:47
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
@royshouvik
royshouvik / Full Stack JavaScript.md
Last active July 6, 2023 13:55
Learn Full Stack JavaScript Web Development for FREE using resources like YouTube, Udacity and NodeSchool
@jefftriplett
jefftriplett / trello-to-newsletter.py
Last active June 5, 2021 17:00
Trello to Newsletter builder
"""
Trello to Newsletter builder
This is heavily inspired by: https://changelog.com/trello-as-a-cms/
To install:
pip install click cached_property markdown py-trello
To run:
export TRELLO_APP_KEY=''