Skip to content

Instantly share code, notes, and snippets.

@vasgat
vasgat / wikirate_answer_export.py
Last active September 20, 2024 17:56
This script interacts with the WikiRate API to retrieve metrics and answers based on specific keywords and corporate identifiers, and then saves the gathered data to a CSV file.
from itertools import islice
from wikirate4py import API, Cursor, to_dataframe
# splits a list into chunks of a given size
def chunked_iterable(iterable, size):
iterable = iter(iterable)
return iter(lambda: list(islice(iterable, size)), [])
@vasgat
vasgat / spec.json
Created June 3, 2022 11:03
Vega spec Bee swarm with Unknowns
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A beeswarm chart example that uses a force-directed layout to group items by category.",
"width": 950,
"height": 400,
"padding": {"left": 5, "right": 5, "top": 0, "bottom": 30},
"background": "#ffefd9",
"autosize": "none",
"config": {"axis": {"labelFontSize": 15, "labelFont": "GothamNarrow"}},
"signals": [
@vasgat
vasgat / spec.json
Created June 3, 2022 10:30
Vega spec Bee swarm with Unknowns
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A beeswarm chart example that uses a force-directed layout to group items by category.",
"width": 950,
"height": 400,
"padding": {"left": 5, "right": 5, "top": 0, "bottom": 30},
"background": "#ffefd9",
"autosize": "none",
"config": {"axis": {"labelFontSize": 15, "labelFont": "GothamNarrow"}},
"signals": [
@vasgat
vasgat / spec.json
Created September 29, 2021 10:03
Apparel Top 100 Companies Reporting their Suppliers
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A basic line chart example.",
"width": 500,
"height": 200,
"padding": 5,
"signals": [{"name": "interpolate", "value": "cardinal"}],
"title": {
"text": "Apparel Top 100 Companies Reporting their Suppliers.",
"subtitle": "Number of Apparel Top 100 Companies making their list of suppliers publicly available over the years.",
@vasgat
vasgat / histogram.js
Created November 30, 2016 13:33
Draw histogram with d3.js
function histogramChart(color_value, title, xAxisTitle, yAxisTitle, num_of_of_bins) {
var margin = {top: 30, right: 40, bottom: 50, left: 50},
width = 460,
height = 300;
var histogram = d3.layout.histogram(),
x = d3.scale.ordinal(),
y = d3.scale.linear(),
xAxis = d3.svg.axis().scale(x).orient("bottom").tickSize(6, 0),
yAxis = d3.svg.axis()