Problem: I want to read and serve JSON, but the JSON structure differs by query. I solve this with an interface FleetVehicle, a base Vehicle struct, and additional specialized structs that allow for differetnail parsing. The Fleet struct holds raw json in RawVehicles, and parsed objects/structs in Vehicles. By writing MarsahJSON and UnmarshalJSON for the Fleet struct, and I control how each JSON block is parsed into a different type of struct/vehicle. To run: GOPATH=${PWD} go run helloVariant.go
, and check http://localhost:8080/world
. This loads multiple JSON files into one Fleet object allowing me to serve a concatenation of the JSON files. For now, each JSON block must use the data
field to hold a list of vehicles.
- helloVariant.go is the main file
- src/varparse/varparse.go holds structs for variants in JSON
- testVariant1.json and testVariant2.json are example files used by helloVariant.go
- hello.go is my initial attempt
- fleet.go, fleet_test.go, fleet_test_
#!/usr/bin/env python3 | |
""" | |
The idea here is to have one demo of each common argparse format | |
type. This is useful for me to be able to copy/paste into a new | |
script and have something to quickly edit and trim down to get | |
the functionality I need. | |
Example (in your terminal): | |
$ python3 argparse-template.py "hello" 123 --enable |
import rule_maker | |
one_out = 'out1' | |
rule one: | |
output: | |
one_out | |
shell: | |
'touch {output}' | |
# generate a snakefile file for the second rule |
def mk_rule(in_file, out_file, tmp_snake='tmp_snake.py'): | |
'''input is single file | |
output is single file | |
''' | |
with open(tmp_snake, 'w') as f: | |
rule_str = f"""rule auto: | |
input: | |
'{in_file}' | |
output: | |
'{out_file}' |
''' Three rule ex ''' | |
rule one: | |
output: | |
'out1' | |
shell: | |
'touch {output}' | |
rule two: | |
input: |
I hereby claim:
- I am samesense on github.
- I am samesense (https://keybase.io/samesense) on keybase.
- I have a public key ASB-sPD-A8yIsdlWUcJNosvQ0yi326pqYwvZRVxkg3-LHQo
To claim this, I am signing this object:
I frequently administer remote servers over SSH, and need to copy data to my clipboard. If the text I want to copy all fits on one screen, then I simply select it with my mouse and press CMD-C, which asks relies on m y terminal emulator (xterm2) to throw it to the clipboard.
This isn't practical for larger texts, like when I want to copy the whole contents of a file.
If I had been editing large-file.txt
locally, I could easily copy its contents by using the pbcopy
command:
onsuccess: | |
shell( | |
"curl `singularity exec docker://vault:1.2.1 vault read -field=value secret/v1/users/evansj/twilio-a` -X POST --data-urlencode 'To=+12406819176' --data-urlencode 'From=+18174022818' -u `singularity exec docker://vault:1.2.1 vault read -field=value secret/v1/users/evansj/twilio-u` --data-urlencode 'Body=gatk done'" | |
) | |
onerror: | |
shell( | |
"curl `singularity exec docker://vault:1.2.1 vault read -field=value secret/v1/users/evansj/twilio-a` -X POST --data-urlencode 'To=+12406819176' --data-urlencode 'From=+18174022818' -u `singularity exec docker://vault:1.2.1 vault read -field=value secret/v1/users/evansj/twilio-u` --data-urlencode 'Body=gatk fail'" | |
) |