Skip to content

Instantly share code, notes, and snippets.

@elliette
elliette / main.dart
Created January 27, 2022 01:43
Keyboard shortcut example with / without TextField
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@elliette
elliette / main.dart
Created January 26, 2022 22:11
Keyboard shortcuts and focus demo
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

STRING PERMUTATIONS

THE QUESTION:

Given a string, return an array of all the permutations of that string. The permutations of the string should be the same length as the original string (i.e. use each letter in the string exactly once) but do not need to be actual words.

Notes:

  • The array that is returned should only contain unique values

A Walk Through of React-Redux Data Flow Using Puppy Book

So you've finished Puppy Book but want to take it to the next level- let's walk through the data flow for adding a puppy to our store state!

Step One - How will your state change?

Think about how store state is going to change. Then write an action, an action creator, and modify your reducer accordingly.

Action:

const ADD_PUPPY = 'ADD_PUPPY';

Javascript Promises

A Promise is a Javascript object that takes in a function, called the executor. The executor itself takes in two parameters, resolve and reject, that are themselves functions. Inside the promise, resolve must be invoked with the sucessful returned value of the promise instance. You can also invoke the reject function with the reason for the promise instance's failure, although doing so is optional.

Promises are used to capture the values of asynchronous functions. They resolve only once the asynchronous function has returned.

.then and .catch

@elliette
elliette / ManyToManyRelationships.md
Last active October 31, 2023 16:03
Describing `belongsToMany` and `hasMany` methods in Sequelize

Defining Many-to-Many Associations in Sequelize

Reference: Sequelize docs on association

Let’s say we have two models: Films and Festivals

We know that a film can be shown at many film festivals and that, conversely, a festival can show many films. This is what is known as a many-to-many relationship.

Knowing this, we can set up our associations: