Skip to content

Instantly share code, notes, and snippets.

View sjwiesman's full-sized avatar

Seth Wiesman sjwiesman

View GitHub Profile
from dataclasses import dataclass
from enum import Enum
from typing import Optional, AsyncGenerator, TypeVar, Callable, Generator
from psycopg import sql
from psycopg.rows import dict_row
from psycopg_pool import AsyncConnectionPool
t = TypeVar("t")
@sjwiesman
sjwiesman / flink-parquet-writer.sql
Last active May 11, 2020 19:22
Flink Avro Reader Parquet Writer
@sjwiesman
sjwiesman / day4.sql
Created December 9, 2019 00:29
Advent of code - Day 4 using Flink SQL and Match Recognize
-- https://adventofcode.com/2019/day/4
SELECT COUNT(DISTINCT CAST(
((codes.passcode[1] * 100000) +
(codes.passcode[2] * 10000) +
(codes.passcode[3] * 1000) +
(codes.passcode[4] * 100) +
(codes.passcode[5] * 10) +
codes.passcode[6]) AS VARCHAR)
FROM digits
import org.apache.flink.api.common.functions.AggregateFunction;
import org.apache.flink.api.common.state.ListState;
import org.apache.flink.api.common.state.ListStateDescriptor;
import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.common.typeutils.TypeSerializer;
import org.apache.flink.api.java.functions.KeySelector;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.tuple.Tuple3;
import org.apache.flink.api.java.typeutils.TupleTypeInfo;
@sjwiesman
sjwiesman / RichFsSinkFunction.java
Created January 24, 2017 16:30
Flink RichFsSinkFunction
public abstract class RichFsSinkFunction<IN> extends RichSinkFunction<IN> {
private Collector<Path> collector;
public void setCollector(Collector<Path> collector) {
this.collector = collector;
}
public void collect(Path finalPath) {
/// Or something to this regard that can forward on paths
def rule(num: Long) = (1 to 10).map(digit => (num / Math.pow(10, 10 - digit).toInt) % digit).forall(_==0)
"123456789".permutations.map(number => number ++ "0").map(_.toLong).filter(rule)
/*
* Name:
* Pawprint:
*/
typedef struct student {
char FName[20];
char LName[20];
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
typedef struct _car {
char model[20];
char brand[20];
int year;
long worth;