Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ipython
from openpyxl import load_workbook
from toolz import thread_last, curry
import toolz.curried as tc
from typing import List, Dict, Tuple
import os
def list_to_dict_list(all_rows: List[List]) -> List[Dict]:
"""this just chops the headers off the spreadsheet, and then uses them to make
@joefromct
joefromct / recur-with-atom.clj
Created February 11, 2019 16:29
can i remove the atom?
(def airplanes {:planes
{:plane
[{:make "Cessna",
:year "1977",
:model {:#text "MoonDart", :at-color "blue"},
:owner ["mitch" "glen" "paulie"],
:action
[{:#text "sample text - landed the plane and it was windy.",
:at-type "landing",
:at-weather "windy",
(ns user)
(defn reached-top-of-staircase?
"Tests to make sure the steps get us to the top of the stairway."
[{:keys [stairway-height]} step-vec]
(= stairway-height (apply + step-vec)))
(defn compute-max-steps
"The idea here is that the maximum number of steps we could take is the
stairway height divided by the smallest step. "
from pprint import pprint as pp
def reached_top_of_stairs(stairway_height, step_tuple):
return sum(step_tuple) == stairway_height
def compute_max_steps(stairway_height, step_options):
non_zero = [f for f in step_options if f != 0]
min_step = min(non_zero)
return int(stairway_height / min_step)
strict digraph {
graph [resolution=128 , ranksep=0.2 ,
fontname="Arial Bold Italic" , fontsize=12 ,
compound=true , rankdir=LR ,
style=rounded , splines=line,
label="Agile GTD Work Streams"]
############################################################################
# input apps ##################################################################
node[fillcolor=darkgreen,style=filled, fontname=Arial, fontsize=11, shape=cds, fontcolor=white];
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD>
<?xml version="1.0" encoding="UTF-8"?>
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COUNTRY>UK</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="EN"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Extensible Markup Language (XML) 1.0 (Fifth Edition)</title><style type="text/css">
code { font-family: monospace; }
div.constraint,
div.issue,
div.note,
div.notice { margin-left: 2em; }
ol.enumar { list-style-type: decimal; }
@joefromct
joefromct / set_options.py
Created November 24, 2020 19:51
pandas set_options.py
import pandas as pd
def set_options(*seq):
"https://toolz.readthedocs.io/en/latest/_modules/toolz/itertoolz.html#partition"
assert len(seq) % 2 == 0, "I need pairs of option/values?"
options = [iter(seq)] * 2
for opt, val in list(zip(*options)):
CREATE TABLE lookup_date
(
yyyymmdd INT NOT NULL,
date_actual DATE NOT NULL,
epoch BIGINT NOT NULL,
day_suffix VARCHAR(4) NOT NULL,
day_name VARCHAR(9) NOT NULL,
day_of_week INT NOT NULL,
day_of_month INT NOT NULL,
day_of_quarter INT NOT NULL,