Skip to content

Instantly share code, notes, and snippets.

View kantord's full-sized avatar

Dániel Kántor kantord

View GitHub Profile
@kantord
kantord / gist:4c4e7b7faa970468312f4ea9ea44f008
Created October 26, 2016 14:07
Get every line from every file annotated with their filename and last modification
find . -type f -exec bash -c 'paste -d "|" <(yes $0) <(yes $(stat -c %y "$0")) "$0" | head -n `cat "$0" | wc -l`' '{}' \;
@kantord
kantord / magic.py
Created October 26, 2016 22:51
Use positional arguments to call a function that only takes keyword arguments
"""
Example:
greet = magic_def("object", object="World")("Hello {object}!".format)
greet() # Hello World!
greet("John Doe") # Hello John Doe!
"""
def magic_def(*argument_names, **default_values):
def wrapper(func):
values = dict(default_values.iteritems())
@kantord
kantord / edges.csv
Last active December 15, 2017 18:13
Visualizing changes in a network using D3
frame source target weight
0 K Smith A Lock 0.21173905130640522
0 K Smith A Lee 0.27582121148579053
0 K Smith B Day 0.447456581342536
0 K Smith C Smith 0.9025337081161997
0 B Doe K Doe 0.27733344115465336
0 B Doe A Lock 0.26563752260276363
0 B Doe B Day 0.2381991164770027
0 B Doe J Smith 0.781246002686131
0 B Doe H Smith 0.47396925684947644
@kantord
kantord / dashboard.json
Last active January 22, 2018 15:52
bottoml.in/e - Hello World
{
"component": "root",
"args": {"title": "Hello World"},
"data": [
{"component": "text",
"args": {"tagName": "h1"},
"data": "Hello World!"
},
{"component": "text",
"args": {"tagName": "p"},
@kantord
kantord / dashboard.json
Last active January 24, 2018 14:48
Cereals
{
"component": "root",
"args": {"title": "Cereals"},
"data": [
{"component": "text",
"args": {"tagName": "h1"},
"data": "Cereals"
},
{"component": "text",
"args": {"tagName": "h2"},
@kantord
kantord / dashboard.yml
Created January 29, 2018 15:53
Cereals
dashboard "Cereals":
- h1 text: "Cereals"
- h2 text: "By calories"
- bar chart:
- attr:query: '{"columns": [(sort_by(-(.calories | tonumber)) | .[] | [.name, .calories])]}'
- data: https://gist.githubusercontent.com/ZeningQu/6184eaf8faa533e320abc938c4738c3e/raw/40f237de825061faa8721c2293b79c46979780b4/cereals.csv
- h2 text: "By nutritional profile"
- 4 columns:
- attr:query: '.[] | {"component": "rows", "data": [{"component": "text", "args": {"tagName": "h3"}, "data": .name}, {"component": "chart", "args": {"type": "pie"}, "data": {"columns": [["protein", .protein], ["carbo", .carbo], ["sugars", .sugars], ["fat", .fat]]}}]}'
- data: https://gist.githubusercontent.com/ZeningQu/6184eaf8faa533e320abc938c4738c3e/raw/40f237de825061faa8721c2293b79c46979780b4/cereals.csv
{"component":"root","args":{"title":"Hello World"},"data":[{"component":"text","args":{"tagName":"h1"},"data":"Hello"},{"component":"text","args":{"query":".[0]","tagName":"h2"},"data":["Hello World!"]}]}
{
"Bananas": [["Protein", 5], ["Sugar", 10], ["Other carbs", 40], ["Fat", 1]],
"Tofu" : [["Protein", 30], ["Sugar", 0], ["Other carbs", 40], ["Fat", 3]],
"Peanut butter": [["Protein", 20], ["Sugar", 2], ["Other carbs", 20], ["Fat", 50]]
}
dashboard "Food":
- h1 text: Food
- h2 text: By caloric content
- 3 columns:
- attr:query: '[to_entries | .[] | {"component": "rows", "data": [
{"component": "text", "args": {"tagName": "h3"}, "data": .key},
{"component": "chart", "args": {"type": "pie"}, "data": {"columns": .value}}
]}]'
- data: https://gist.githubusercontent.com/kantord/2b2e3b22cb70be0415a7d50c395fa411/raw/47542f8a3db0d65aeeb48e28ddfaa8feabbc72b5/nutri.json
@kantord
kantord / dashboard.yml
Last active February 19, 2018 15:58
Crypto example
dashboard "Cryptocurrency prices":
- h1 text: "Cryptocurrency prices"
- spline chart:
- attr:query: '{"rows": []}'
- attr:loader: json
- data: https://coinbin.org/btc/history