Skip to content

Instantly share code, notes, and snippets.

@nvander1
nvander1 / schemas.scala
Created August 29, 2019 01:01
How to Use SQL Constraints in Spark
import org.apache.spark.sql.types._
val personSchema = new StructType()
.add(name="person_id", dataType=LongType)
.add(name="firstname", dataType=StringType)
.add(name="lastname", dataType=StringType)
val bookSchema = new StructType()
.add(name="book_id", dataType=StringType)
.add(name="title", dataType=StringType)
@nvander1
nvander1 / keybase.md
Created March 26, 2019 16:08
Keybase Proof

Keybase proof

I hereby claim:

  • I am nvander1 on github.
  • I am nrv (https://keybase.io/nrv) on keybase.
  • I have a public key ASD4TxyOyEit7z5MWORFEl7gE8wm_lF-HYtTkWkI3pxvPAo

To claim this, I am signing this object:

n=int(input())
l=(n//2)if n&1else((n-1)//2)
r=[' '*l+('*'if n&1else'**')]+[(n-w)*' '+'*'+(2*w-2-n)*' '+'*'for w in [l+i+(2if n&1else 3)for i in range(l)]
print('\n'.join(r+r[-2::-1]))
@nvander1
nvander1 / invertmap.py
Last active April 28, 2017 17:52
Invert a mapping of keys to lists.
from collections import defaultdict as dd
mapping = {
'000': [46, 53, 58, 62, 65, 68, 70, 72, 74],
'010': [45, 52, 57, 61, 64, 67, 69, 71, 73],
'100': [44, 51, 56, 60, 63, 66, 68, 70, 72],
'110': [43, 50, 55, 59, 62, 65, 67, 69, 71],
'001': [43, 50, 55, 59, 62, 65, 67, 69, 71],
'011': [42, 49, 54, 58, 61, 64, 66, 68, 70],
'101': [41, 48, 53, 57, 60, 63, 65, 67, 69],