Skip to content

Instantly share code, notes, and snippets.

@robertwb
robertwb / nasa-dataflow.yaml
Last active December 15, 2023 11:24
Yaml bug bash samples
#
# python -m apache_beam.yaml.main --pipeline_spec_file=yaml-pipelines/nasa-dataflow.yaml
#
pipeline:
type: chain
source:
type: ReadFromCsv
config:

Create

Creates a collection containing a specified set of elements.

YAML/JSON-style mappings will be interpreted as Beam rows. For example::

type: Create
config:
  elements:
    - {first: 0, second: {str: "foo", values: [1, 2, 3]}}
@robertwb
robertwb / astroid-csv.yaml
Last active December 14, 2022 21:33
Apache Beam yaml wordcount
pipeline:
- type: chain
transforms:
- type: ReadFromCsv
path: "gs://apache-beam-samples/nasa_jpl_asteroid/sample_1000.csv"
- type: PyFilter
fn: "lambda astroid: (astroid.diameter or 0) > 250"
- type: PyMap
fn: print
@robertwb
robertwb / Playground.hs
Last active March 30, 2021 08:18
Plutus Playground Smart Contract
-- Factoring challenge contract implemented using the [[Plutus]] interface.
-- Based on Plutus Playground Crowd Funding example.
import Control.Applicative (Applicative (pure))
import Control.Monad (void)
import Language.Plutus.Contract
import qualified Language.Plutus.Contract.Constraints as Constraints
import qualified Language.Plutus.Contract.Typed.Tx as Typed
import qualified Language.PlutusTx as PlutusTx
import Language.PlutusTx.Prelude hiding (Applicative (..), Semigroup (..))
@robertwb
robertwb / Playground.hs
Last active March 27, 2021 07:05
Plutus Playground Smart Contract
-- A game with two players. Player 1 thinks of a secret word
-- and uses its hash, and the game validator script, to lock
-- some funds (the prize) in a pay-to-script transaction output.
-- Player 2 guesses the word by attempting to spend the transaction
-- output. If the guess is correct, the validator script releases the funds.
-- If it isn't, the funds stay locked.
import Control.Monad (void)
import qualified Data.ByteString.Char8 as C
import Language.Plutus.Contract
import qualified Language.PlutusTx as PlutusTx
@robertwb
robertwb / Playground.hs
Last active March 27, 2021 05:24
Plutus Playground Smart Contract
import Playground.Contract
import Control.Monad (void)
import Data.Aeson (FromJSON, ToJSON)
import qualified Data.Text as T
import GHC.Generics (Generic)
import Ledger
import qualified Ledger.Ada as Ada
import qualified Ledger.Constraints as Constraints
import qualified Ledger.Typed.Scripts as Scripts
import Language.Plutus.Contract
@robertwb
robertwb / Playground.hs
Created March 27, 2021 04:15
Plutus Playground Smart Contract
-- Vesting scheme as a PLC contract
import Control.Monad (void, when)
import qualified Data.Map as Map
import qualified Data.Text as T
import Language.Plutus.Contract hiding (when)
import qualified Language.Plutus.Contract.Typed.Tx as Typed
import qualified Language.PlutusTx as PlutusTx
import Language.PlutusTx.Prelude hiding (Semigroup (..), fold)
import Ledger (Address, PubKeyHash, Slot (Slot), Validator, pubKeyHash)
@robertwb
robertwb / Periodic Table of Elements.csv
Last active February 10, 2024 20:03 — forked from GoodmanSciences/Periodic Table of Elements.csv
Tungsten is the more common name for Wolfram.
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 28 columns, instead of 24. in line 6.
AtomicNumber,Element,Symbol,AtomicMass,NumberofNeutrons,NumberofProtons,NumberofElectrons,Period,Group,Phase,Radioactive,Natural,Metal,Nonmetal,Metalloid,Type,AtomicRadius,Electronegativity,FirstIonization,Density,MeltingPoint,BoilingPoint,NumberOfIsotopes,Discoverer,Year,SpecificHeat,NumberofShells,NumberofValence
1,Hydrogen,H,1.007,0,1,1,1,1,gas,,yes,,yes,,Nonmetal,0.79,2.2,13.5984,8.99E-05,14.175,20.28,3,Cavendish,1766,14.304,1,1
2,Helium,He,4.002,2,2,2,1,18,gas,,yes,,yes,,Noble Gas,0.49,,24.5874,1.79E-04,,4.22,5,Janssen,1868,5.193,1,
3,Lithium,Li,6.941,4,3,3,2,1,solid,,yes,yes,,,Alkali Metal,2.1,0.98,5.3917,5.34E-01,453.85,1615,5,Arfvedson,1817,3.582,2,1
4,Beryllium,Be,9.012,5,4,4,2,2,solid,,yes,yes,,,Alkaline Earth Metal,1.4,1.57,9.3227,1.85E+00,1560.15,2742,6,Vaulquelin,1798,1.825,2,2
5,Boron,B,10.811,6,5,5,2,13,solid,,yes,,,yes,Metalloid,1.2,2.04,8.298,2.34E+00,2573.15,4200,6,Gay-Lussac,1808,1.026,2,3
6,Carbon,C,12.011,6,6,6,2,14,solid,,yes,,yes,,Nonmetal,0.91,2.55,11.2603,2.27E+00,3948.15,4300,7,Prehi
@robertwb
robertwb / a.py
Last active June 6, 2017 17:02 — forked from sb2nov/a.py
Test python import
print "defining A"
class A(object):
def __init__():
print 'A'
# pip install cython
# python setup.py build_ext --inplace; python bench-runner.py
import time
import apache_beam as beam
from apache_beam.runners import common
from apache_beam.utils.windowed_value import WindowedValue