All Projects → petersolopov → carbonara

petersolopov / carbonara

Licence: MIT License
API for carbon

Programming Languages

javascript
184084 projects - #8 most used programming language
Dockerfile
14818 projects
HTML
75241 projects

Projects that are alternatives of or similar to carbonara

git-the-lines
A Discord bot that prints out the lines referenced in a GitHub, GitLab, or BitBucket snippet link
Stars: ✭ 37 (-56.98%)
Mutual labels:  snippet
awesome-forests
🌳 A curated list of ground-truth forest datasets for the machine learning and forestry community.
Stars: ✭ 111 (+29.07%)
Mutual labels:  carbon
idea-carbon-now-sh
IntelliJ IDEA plugin to open the selected code in https://carbon.now.sh
Stars: ✭ 27 (-68.6%)
Mutual labels:  carbon
openair-cyan
DIY small-scale open hardware direct air carbon capture device called Cyan. Our documentation is on https://openair-collective.github.io/openair-cyan
Stars: ✭ 54 (-37.21%)
Mutual labels:  carbon
carbon-boilerplate
A simple boilerplate for rapid UI prototyping with Carbon components
Stars: ✭ 42 (-51.16%)
Mutual labels:  carbon
devtools
A simple set of tools for teams building live Carbon pages.
Stars: ✭ 31 (-63.95%)
Mutual labels:  carbon
php-helpers
An extensive set of PHP helper functions and classes.
Stars: ✭ 27 (-68.6%)
Mutual labels:  carbon
meta-theme-sky-color
Js snippet that changes the mobile Chrome nav bar color to the color of the sky based on time of day.
Stars: ✭ 19 (-77.91%)
Mutual labels:  snippet
pi-eco-indicator
Display at-a-glance data of carbon intensity or Octopus Agile prices on a Pimoroni Blinkt! display or a Pimoroni Inky pHAT display.
Stars: ✭ 15 (-82.56%)
Mutual labels:  carbon
inspector-metrics
Typescript metrics / monitoring library
Stars: ✭ 19 (-77.91%)
Mutual labels:  carbon
carbon-business-days
A simple class for business days counting
Stars: ✭ 37 (-56.98%)
Mutual labels:  carbon
pest-plugin-test-time
A Pest plugin to control the flow of time
Stars: ✭ 31 (-63.95%)
Mutual labels:  carbon
DS-Cookbook101
A jupyter notebook having all most frequent used code snippet for daily data scienceoperations
Stars: ✭ 59 (-31.4%)
Mutual labels:  snippet
tailwind-shift
⚙️ Shift to the next TailwindCSS version hassle-free.
Stars: ✭ 114 (+32.56%)
Mutual labels:  snippet
Ubufundi
Android Code Recipies:Short targeted code snippets to get the job done
Stars: ✭ 16 (-81.4%)
Mutual labels:  snippet
carbon-preprocess-svelte
Collection of Svelte preprocessors for the Carbon Design System
Stars: ✭ 39 (-54.65%)
Mutual labels:  carbon
add-to-calendar-button
A convenient JavaScript snippet, which lets you create beautiful buttons, where people can add events to their calendars.
Stars: ✭ 697 (+710.47%)
Mutual labels:  snippet
puppet-graphite
Puppet module for graphite monitoring tools
Stars: ✭ 67 (-22.09%)
Mutual labels:  carbon
carbon-components-svelte
Svelte implementation of the Carbon Design System
Stars: ✭ 1,615 (+1777.91%)
Mutual labels:  carbon
Rhythm-CB-Scripts
Collection of scripts for use with Carbon Black Cb Response API
Stars: ✭ 14 (-83.72%)
Mutual labels:  carbon

Carbonara build

API for carbon.

Getting started

Send POST https://carbonara-42.herokuapp.com/api/cook to take an image of code snippet.

How it works

  • Puppeteer visit https://carbon.now.sh.
  • Mapping all params in properly URL params.
  • Taking a screenshot of the editor.

POST /api/cook

Body is JSON or multipart with next params:

parameter default type description
code (required) string code snippet
backgroundColor "rgba(171, 184, 195, 1)" string hex or rgba color
dropShadow true boolean turn on/off shadow
dropShadowBlurRadius "68px" string shadow blur radius
dropShadowOffsetY "20px" string shadow offset y
exportSize "2x" string resolution of exported image, e.g. 1x, 3x
fontCustom "" string custom woff font's contents, encoded in base64
fontSize "14px" string font size
fontFamily "Hack" string font family, e.g. JetBrains Mono, Fira Code. See all names in carbon exported config.
firstLineNumber 1 number first line number
language "auto" string programing language for properly highlighting. See name in carbon exported config. For example bash is named "application/x-sh"
lineHeight "133%" string line height
lineNumbers false boolean turn on/off line number
paddingHorizontal "56px" string horizontal padding
paddingVertical "56px" string vertical padding
prettify false boolean prettify code with prettier. It works with javascript snippets only, like in carbon.
theme "seti" string code theme
watermark false boolean turn on/off watermark
width 536 number specify the width of the screenshot
widthAdjustment true boolean turn on/off width adjustment
windowControls true boolean turn on/off window controls
windowTheme "none" "none" "sharp" "bw" window theme

Defaults params are the same as https://carbon.now.sh.

Response is an image of a code snippet.

Example

Creating image and saving to code.png in terminal.

curl -L https://carbonara-42.herokuapp.com/api/cook \
-X POST \
-H 'Content-Type: application/json' \
-d '{
      "code": "export default const sum = (a, b) => a + b",
      "backgroundColor": "#1F816D"
    }' \
> code.png

or using multipart

curl -L https://carbonara-42.herokuapp.com/api/cook \
-X POST \
-H 'Content-Type: multipart/form-data' \
-F code="export default const sum = (a, b) => a + b" \
-F fontCustom=$(base64 < my-custom-font.ttf) \
-F backgroundColor="#1F816D" \
> code.png

Easy way to tune image

  1. Visit https://carbon.now.sh.
  2. Set appearance.
  3. Click gear → miscexport config for downloading JSON with the current setting.
  4. Add code property in JSON.
  5. Use JSON in /api/cook request body.

Unsupported params

These options exist in exported config but there is not a possibility pass them via URL: backgroundImage, backgroundImageSelection, backgroundMode, squaredImage, hiddenCharacters, name, loading, icon, isVisible.

Docker container

Running the server in 3000 port with docker:

docker run -p 3000:3000 -it petersolopov/carbonara

Running test

docker build -t local/carbonara .
docker run -it --rm local/carbonara npm test

Development

There are two main files:

  • api/cook.js — lambda function (deprecated).
  • src/index.js – nodejs server that running in docker container.

Running development server:

docker build -t local/carbonara .
docker run -v $(pwd):/home/pptruser/app/ -p 3000:3000 -it --rm local/carbonara npm run nodemon

Updating test images:

docker build -t local/carbonara .
docker run -v $(pwd):/home/pptruser/app/ -it --rm local/carbonara npm test

LICENSE

MIT.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].