Skip to content

Instantly share code, notes, and snippets.

Avatar

Anton Medvedev antonmedv

View GitHub Profile
@antonmedv
antonmedv / table.js
Created September 14, 2020 14:18
fx snippet for table output on JSON
View table.js
global.table = (json) => {
let Table = require('cli-table3')
let table = new Table({head: Object.keys(json[0])});
table.push(...json.map(Object.values))
return table.toString()
}
@antonmedv
antonmedv / connect_linkedin.js
Last active November 25, 2019 10:11 — forked from bertolo1988/connect_linkedin.js
Quickly your LinkedIn network
View connect_linkedin.js
// 1. load https://www.linkedin.com/mynetwork/
// 2. make sure your LinkedIn is in English
// 3. paste this script on chrome dev tools at your own risk
async function moreConnectionsPlease() {
// maximum limit of Connect buttons clicked
const LIMIT = 500;
// wait in ms before each scroll
const SCROLL_TIMEOUT = 600;
// bulk scroll will scroll this amount of times
@antonmedv
antonmedv / .bash_profile
Created December 20, 2018 05:26
My bash profile
View .bash_profile
# Brew
export PATH="/usr/local/sbin:$PATH"
# Php
export PATH="/usr/local/opt/php@7.1/bin:$PATH"
export PATH="$PATH:~/.composer/vendor/bin"
export dep="/Users/anton/Projects/deployer/bin/dep"
#export COMPOSER_DISABLE_XDEBUG_WARN=1
eval "$(symfony-autocomplete)"
@antonmedv
antonmedv / find.js
Created December 12, 2018 05:49
Search Snippet
View find.js
global.find = re => json => [...find(json, re)]
function* find(v, regex, path = '') {
if (regex.test(path)) {
yield path
return
}
if (typeof v === 'undefined' || v === null) {
return
View round.sh
#!/usr/bin/env bash
fd frame | while read line; do
convert $line \
\( +clone -alpha extract \
-draw 'fill black polygon 0,0 0,15 15,0 fill white circle 15,15 15,0' \
\( +clone -flip \) -compose Multiply -composite \
\( +clone -flop \) -compose Multiply -composite \
\) -alpha off -compose CopyOpacity -composite $line;
done
@antonmedv
antonmedv / bench_test.go
Created October 21, 2018 08:15
Benchmark antonmedv/expr
View bench_test.go
package expr_test
import (
"testing"
"github.com/antonmedv/expr"
"github.com/dop251/goja"
"github.com/robertkrimen/otto"
)
@antonmedv
antonmedv / parser.go
Created September 23, 2018 13:39
Parser example (GoWayFest 2018)
View parser.go
package main
import (
"fmt"
"os"
"regexp"
"strings"
)
type token = string
@antonmedv
antonmedv / fastJSON.js
Created September 14, 2018 16:53
Function for fast extraction of part of JSON
View fastJSON.js
/**
* Fast extract part of json by path.
* Example: fastJSON('{...}', ['foo', 'bar'])
*
* @param {String} input JSON string
* @param {Array} path Path for extraction
* @returns {String} Extracted JSON string
* @throws SyntaxError
*/
function fastJSON(input, path) {
View chain.php
<?php declare(strict_types=1);
$app->get('/prices', [
ParseParams::class,
NormalizeParams::class,
delayed() => Notify::class,
parallel() => [
ServiceA::class,
SomeOtherService::class,
ServiceB::class,
@antonmedv
antonmedv / ActiveRecord.php
Created October 22, 2017 07:43
Facade in Symfony
View ActiveRecord.php
<?php
namespace AppBundle\Entity;
use AppBundle\DependencyInjection\Container;
class ActiveRecord extends Container
{
protected static function getDoctrine()
{