Skip to content

Instantly share code, notes, and snippets.

@vbarbarosh
vbarbarosh / svg_pattern_grid.svg
Last active June 9, 2019 17:39
svg_pattern_grid – Drawing a 10x10 grid by 100x100 outline https://codescreens.com
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vbarbarosh
vbarbarosh / svg_pattern_dots.svg
Last active December 8, 2020 22:40
svg_pattern_dots – Drawing dots on each 5th pixel https://codescreens.com
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vbarbarosh
vbarbarosh / chartjs.html
Last active June 6, 2019 21:19
chartjs – Rendering charts with chart.js https://codescreens.com
<!-- Rendering charts with chart.js -->
<div style="position:absolute; top:0; left:0; width:100%; height:100%;">
<canvas id="canvas" style="width:100%; height:100%;"></canvas>
</div>
<script src="https://unpkg.com/chart.js@2.8.0/dist/Chart.min.js"></script>
<script>
new Chart(document.getElementById('canvas').getContext('2d'), {
type: 'line', // line|bar
@vbarbarosh
vbarbarosh / svg_coords.svg
Last active June 5, 2019 16:47
svg_coords – Drawing a coordinate system https://codescreens.com
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vbarbarosh
vbarbarosh / math_scale.html
Last active June 2, 2019 08:57
math_scale – Scale a point around origin https://codescreens.com
<!-- Scale a point around origin -->
<!-- https://codepen.io/vbarbarosh/pen/OYrdxK -->
<svg>
<circle id="orig" cx="200" cy="150" r="10" />
<circle id="a" cx="25" cy="25" r="5" fill="#8f8" />
<circle id="b" cx="150" cy="25" r="5" />
</svg>
<style>
@vbarbarosh
vbarbarosh / math_rotate.html
Last active May 31, 2019 18:15
math_rotate – Rotate a point around origin https://codescreens.com
<!-- Rotate a point around origin -->
<!-- https://codepen.io/vbarbarosh/pen/joXEyR -->
<svg>
<circle id="origin" cx="200" cy="150" r="10" />
<circle id="point" cx="175" cy="125" r="5" />
</svg>
<style>
svg {
@vbarbarosh
vbarbarosh / node_promise_promisify.js
Last active May 29, 2019 16:56
node_promise_promisify – Ways to promisify a function https://codescreens.com
const Promise = require('bluebird');
const fs = require('fs');
const util = require('util');
// Ways to promisify a function
// $ node node_promise_promisify.js
// https://nodejs.org/api/util.html#util_util_promisify_original
const fs_open = util.promisify(fs.open);
@vbarbarosh
vbarbarosh / node_promise_then.js
Last active May 27, 2019 18:59
node_promise_then – How Promise.then is designed to work https://codescreens.com
const Promise = require('bluebird');
// How Promise.then is designed to work
// $ node node_promise_then.js
main().catch(panic);
async function main()
{
// FULFILLED
@vbarbarosh
vbarbarosh / node_buffer.js
Last active May 26, 2019 18:58
node_buffer – How to work with Buffer https://codescreens.com
// How to work with Buffer
main().catch(panic);
async function main()
{
// Use this if buffer will be immediately written to
Buffer.allocUnsafe(1024);
// Use this to allocate memory filled with zeroes
@vbarbarosh
vbarbarosh / app_fontmerge
Last active May 25, 2019 17:54
app_fontmerge – Merge several .woff2 files into a single one https://codescreens.com
#!/bin/bash
# http://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -o nounset -o errexit -o pipefail
# Merge several .woff2 files into a single one. Primary use case is to
# feed resulted file to a svgtext app.
#
# https://github.com/fonttools/fonttools