Here's a comprehensive cheatsheet for Python's debugging capabilities:
# Insert at any point in your code| const result = await this.getNotification(notificationId, clientId) | |
| .andThen((notification) => this.executeSms(notification).map(() => notification)) | |
| .andThen((notification) => this.saveAndPublish(notification)) | |
| if (result.isOk()) { | |
| return result.value | |
| } | |
| throw new Error(result.error) |
| // depends on the words_alpha.txt file from https://github.com/dwyl/english-words | |
| import * as readline from 'readline' | |
| const file = Bun.file('./words_alpha.txt') | |
| const text = await file.text() | |
| const wordleWords = text.split('\r\n').filter((w) => w.length === 5) | |
| const prompt = (text: string): void => { |
| interface PadConfig { | |
| value: string | |
| padding: string | |
| requiredLength: number | |
| } | |
| export const pad = ({ value, padding, requiredLength }: PadConfig): string => { | |
| const pads = Math.max(requiredLength - value.length, 0) | |
| return Array(pads).fill(padding).concat(value).join('') |
| module Main exposing (main) | |
| import Browser | |
| import Html exposing (Html, div, text) | |
| import Json.Decode as D exposing (Decoder) | |
| {- | |
| This module demonstrates how to decode a nested tree of nodes that are NOT infinitely recursive. | |
| -} | |
| type alias CommentTree = |
| -- A tree contains 2 kinds of nodes | |
| -- at depths 1 through 2 you will have a node with a 'replies' field | |
| -- at depth 3 the node is missing a 'replies' field | |
| type alias TreeNode a = | |
| { a | |
| | body : String | |
| } |
| const pickFunc = <T extends {}, K extends keyof T>( | |
| obj: T, | |
| predicate: (k: string) => boolean | |
| ): Pick<T, K> => | |
| Object | |
| .keys(obj) | |
| .filter(predicate) | |
| .reduce((filteredObj: Pick<T, K>, key) => ({ | |
| ...filteredObj, | |
| [key]: obj[key as keyof T] |
| {- | |
| Note that we use the `riskyRequest` function because this | |
| webapp uses Cookies for authentication. | |
| These cookies come from a different domain than the one | |
| that host this app | |
| -} | |
| module Api exposing | |
| ( adminSignup | |
| , adminSignin | |
| , getAdminSession |