TL;DR: If you're handling webhook events from Mux (or any webhook-heavy API) and only care about a subset of event types, use an Annotated
Union
with discriminator="type"
wrapped in an Annotated
Union
with a generic fallback and union_mode="left_to_right"
to cleanly support known types and fall back to a generic model for unknown ones.
Create an updated_at
timestamp column that is automatically updated whenever row values are changed in a postgresql database.
- Modifying a column when a row is changed requires a
BEFORE UPDATE
TRIGGER
on row updates. - A
trigger
cancall
aprocedure
- A function can create a
trigger
programatically.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import re | |
from pprint import pprint | |
def main(): | |
begin = "cat" | |
end = "bar" | |
word_len = len(begin) | |
graph = build_graph(get_words(word_len)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; otherwise, it will return false. | |
Each letter in the magazine string can only be used once in your ransom note. | |
Note: | |
You may assume that both strings contain only lowercase letters. | |
canConstruct("a", "b") -> false | |
canConstruct("aa", "ab") -> false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Provided code | |
// Definition for a binary tree node. | |
#[derive(Debug, PartialEq, Eq)] | |
pub struct TreeNode { | |
val: i32, | |
left: Option<Rc<RefCell<TreeNode>>>, | |
right: Option<Rc<RefCell<TreeNode>>>, | |
} | |
impl TreeNode { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn brackets_are_balanced(string: &str) -> bool { | |
// second attempt/idea: | |
// push opening brace onto array | |
// pop array on close and check for match | |
// pop on empty => false | |
// not empty at end => false | |
// third attempt: | |
// make a hashmap of open/close remove code duplication in the | |
// close bracket logic | |
// Is this really the best way to make a fixed hashmap? Also, we |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use itertools::Itertools; | |
use std::collections::HashMap; | |
/// Split a string into substrings of length sub_size | |
/// Final element may be shorter than sub_size | |
fn sub_strings(source: &str, sub_size: usize) -> Vec<String> { | |
source | |
.chars() | |
.chunks(sub_size) | |
.into_iter() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MY_SSH_AUTH_SOCK=$HOME/.ssh/ssh_auth_sock | |
if [ -n "$SSH_AUTH_SOCK" ] ; then | |
if [ -L $MY_SSH_AUTH_SOCK ] && [ -e $MY_SSH_AUTH_SOCK ]; then | |
[ -n "$DEBUG" ] && echo "SSH_AUTH_SOCK is still valid" | |
else | |
[ -n "$DEBUG" ] && echo "linking SSH_AUTH_SOCK to $MY_SSH_AUTH_SOCK" | |
ln -fs "$SSH_AUTH_SOCK" "$MY_SSH_AUTH_SOCK" | |
fi | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" check ITERM_PROFILE for 'DARK' or 'LIGHT' substrings, set background to match. | |
if $ITERM_PROFILE =~? 'DARK\c' | |
set background=dark | |
endif | |
if $ITERM_PROFILE =~? 'LIGHT\c' | |
set background=light | |
endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XPUT "https://localhost:9200/int_vs_str_test" -d '{"mappings": { "foo" : { "properties": { "label_id": { "type": "integer"}}}}}' | |
{"acknowledged":true} |
NewerOlder