Skip to content

Instantly share code, notes, and snippets.

Say Hello

Aleksandr Tsertkov tsertkov

Say Hello
View GitHub Profile
tsertkov / acf-php-to-json.php
Last active Feb 4, 2020 — forked from ollietreend/acf-php-to-json.php
Convert Advanced Custom Fields Pro configuration from PHP to JSON.
View acf-php-to-json.php
* Plugin Name: Convert ACF PHP to JSON
* Description: Convert Advanced Custom Fields Pro configuration from PHP to JSON.
namespace ConvertAcfPhpToJson;
* Add submenu item under 'Custom Fields'
tsertkov / acf-php-to-json.php
Created Jan 30, 2020 — forked from kisabelle/acf-php-to-json.php
Convert ACF Fields Registered by PHP to Importable JSON Format
View acf-php-to-json.php
$groups = acf_get_local_field_groups();
$json = [];
foreach ($groups as $group) {
// Fetch the fields for the given group key
$fields = acf_get_local_fields($group['key']);
// Remove unecessary key value pair with key "ID"
tsertkov /
Last active Oct 22, 2019
JavaScript array tips & tricks

JavaScript array tips & tricks

// Array mapping with .from()

Array.from([{ 'key': 1, 'value': 'val1'}, { 'key': 2, 'value': 'val2' }], ({key}) => key)
Array.from([{ 'key': 1, 'value': 'val1'}, { 'key': 2, 'value': 'val2' }], ({value}) => value)

// Get random value from array
tsertkov /
Last active Sep 28, 2019
Setup GPG agent for ssh authentication and more
tsertkov /
Last active Sep 11, 2019
Forward ports through a Linux gateway with iptables
#!/usr/bin/env bash
iptables -A FORWARD -i $i_in -o $i_out -p tcp --syn --dport $dport -m conntrack --ctstate NEW -j ACCEPT
iptables -A FORWARD -i $i_out -o $i_in -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
tsertkov / wp-remove-dashboard.php
Created Dec 18, 2018 — forked from chrisguitarguy/wp-remove-dashboard.php
Remove all the default WordPress dashboard widgets.
View wp-remove-dashboard.php
Plugin Name: Remove Dashboard Meta Boxes
Plugin URI:
Description: Removes the default dashboard widgets from the WordPress admin.
Author: Christopher Davis
Author URI:
License: GPL2
tsertkov / conditional-custom-tag-trigger.js
Created Oct 23, 2018
Conditionally triggering custom tag (loading remote js script) based on user geolocation and other conditions.
View conditional-custom-tag-trigger.js
<script src=""></script>
<script id="myScript" type="text/javascript">
(function (){
var excludeCountries = [
var timeout = 10000
var cookieValue = document.cookie.replace(/(?:(?:^|.*;\s*)no_ads\s*\=\s*([^;]*).*$)|^.*$/, '$1')
tsertkov /
Created Jun 18, 2018
Send slack message with preformatted content (e.g. file, command output, etc.) from shell
#!/usr/bin/env bash
MSG="Here is file content as preformatted text:"$'\n```\n'"$(< "$FILE")"$'\n```\n'
PAYLOAD="$(jq --raw-input --slurp '{text:.}' <<< "$MSG")"
curl \
-H 'Content-type: application/json' \
tsertkov / nodejs-get-url-concurrency-control.js
Created May 2, 2018
NodeJs http get downloader with concurrency control
View nodejs-get-url-concurrency-control.js
// example
const fetchUrl = fetchUrlFactory(2)
const { content, headers } = await fetchUrl('')
// lib
const https = require('https')
function fetcUrlFactory ({ concurrency }) {
let running = 0
let queue = []