Skip to content

Instantly share code, notes, and snippets.

@vbarbarosh
vbarbarosh / node_csv_write.js
Last active June 27, 2019 20:12
node_csv_write – Create csv files from arrays https://codescreens.com
const {createObjectCsvWriter} = require('csv-writer');
// Create csv files from arrays
main().catch(panic);
// https://stackabuse.com/reading-and-writing-csv-files-with-node-js/
async function main()
{
const rows = [
@vbarbarosh
vbarbarosh / shell_lines_common
Last active June 23, 2019 14:46
shell_lines_common – Show common lines in two files 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
# Show common lines in two files
# https://unix.stackexchange.com/a/398143/121657
# > Use comm -12 file1 file2 to get common lines in both files.
@vbarbarosh
vbarbarosh / node_csv_parse.js
Last active June 21, 2019 19:05
node_csv_parse – Parsing csv files and strings https://codescreens.com
const csv = require('neat-csv');
const fs = require('fs');
const path = require('path');
// Parsing csv files and strings
main().catch(panic);
// https://stackabuse.com/reading-and-writing-csv-files-with-node-js/
async function main()
@vbarbarosh
vbarbarosh / math_line_intersection.html
Last active June 18, 2019 20:02
math_line_intersection – Calculating the point of intersection of two lines https://codescreens.com
<!-- Calculating the point of intersection of two lines -->
<svg id="app" xmlns="http://www.w3.org/2000/svg">
<line :x1="x1" :y1="y1" :x2="x2" :y2="y2" stroke="black" />
<line :x1="x3" :y1="y3" :x2="x4" :y2="y4" stroke="black" />
<circle :cx="c.x" :cy="c.y" r="3" fill="red" />
</svg>
<script src="//cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"></script>
<script>
// https://stackoverflow.com/a/38977789/1478566
@vbarbarosh
vbarbarosh / css_keyframes_values_at.html
Last active June 17, 2019 12:18
css_keyframes_values_at – Get property values from keyframes at specific time https://codescreens.com
<div id="app">
Get property values from keyframes at specific time.
<br>
<textarea v-model="keyframes" cols="50" rows="5"></textarea>
<br>
<input v-model="time" type="number" min="0" max="1" step="0.01">
<pre>{{ values }}</pre>
</div>
<script src="https://unpkg.com/vue@2.6.10/dist/vue.js"></script>
@vbarbarosh
vbarbarosh / css_pretty_format
Last active June 14, 2019 19:54
css_pretty_format – How to pretty print css 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
# How to pretty print css
#
# usage
# $ cat a.css | ./css_pretty_format > out.css
@vbarbarosh
vbarbarosh / css_autoprefixer_clean
Last active June 13, 2019 20:21
css_autoprefixer_clean – Remove prefixes from css 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
# Remove prefixes from css
#
# usage
# $ cat a.css | ./css_autoprefixer_clean > out.css
@vbarbarosh
vbarbarosh / css_autoprefixer
Last active June 12, 2019 19:59
css_autoprefixer – How to add prefixes to css 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
# How to add prefixes to css
#
# usage
# $ cat a.css | ./css_autoprefixer > out.css
@vbarbarosh
vbarbarosh / css_minify_optimize
Last active June 11, 2019 18:06
css_minify_optimize – How to minify css 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
# How to minify css
#
# usage
# $ cat a.css | ./css_minify_optimize > out.css
@vbarbarosh
vbarbarosh / php_math_float_error.php
Last active June 9, 2019 17:32
php_math_float_error – Rounding errors in PHP https://codescreens.com
<?php
# Rounding errors in PHP
# docker run --rm -i php:5.6 php < php_math_float_error.php
# docker run --rm -i php:7.1 php < php_math_float_error.php
# docker run --rm -i php:7.2 php < php_math_float_error.php
# docker run --rm -i php:7.3 php < php_math_float_error.php
define('FLOAT_ERROR', 0.00001);