Skip to content

Instantly share code, notes, and snippets.

View pczerkas's full-sized avatar

Przemysław Czerkas pczerkas

View GitHub Profile
@pczerkas
pczerkas / console
Last active August 29, 2015 14:21 — forked from markmc/console
$> python ./test-notification-server.py
$> python test-notification.py --config-file ./test.conf --debug
$> git reset --hard 5315399
$> python test-notification-old.py --config-file ./test.conf --debug
@pczerkas
pczerkas / pre-commit.sh
Created September 29, 2015 07:37 — forked from glyphobet/pre-commit.sh
self-installing git-hook to prevent accidentally committing pdb.set_trace() calls
#!/bin/bash
mybasename=`basename $0`
if [ ! -e .git/hooks/${mybasename} ] ; then
ln -s ../../git-hooks/${mybasename} .git/hooks/${mybasename}
fi
set_traces=`git diff --cached -Gpdb\.set_trace\(\) | grep '^\+'`
if [ ! -z "$set_traces" ] ; then
<?php
// CONFIG
$servers = array(
array('Local', '127.0.0.1', 6379),
);
// END CONFIG
$server = 0;
if (isset($_GET['s']) && intval($_GET['s']) < count($servers)) {
$server = intval($_GET['s']);
@pczerkas
pczerkas / sql_profiling.php
Created March 4, 2019 14:19 — forked from mslabko/sql_profiling.php
Enable sql profiling for Magento2
<?php
/**
* Enable sql profiling for each page.
*
* Put code to index file in two parts
*/
// place it BEFORE application run
$profiler = \Magento\Framework\App\ObjectManager::getInstance()
->get('Magento\Framework\App\ResourceConnection')
#!/bin/bash
####
# Split MySQL dump SQL file into one file per table
# based on http://blog.tty.nl/2011/12/28/splitting-a-database-dump
####
if [ $# -lt 1 ] ; then
echo "USAGE $0 DUMP_FILE [TABLE]"
exit
@pczerkas
pczerkas / ec2_instance_create_and_setup.sh
Created July 17, 2022 21:15 — forked from Pablosan/ec2_instance_create_and_setup.sh
A bash script that will set up a new EC2 instance and ssh into it.
#!/bin/bash
# Authorize TCP, SSH & ICMP for default Security Group
#ec2-authorize default -P icmp -t -1:-1 -s 0.0.0.0/0
#ec2-authorize default -P tcp -p 22 -s 0.0.0.0/0
# The Static IP Address for this instance:
IP_ADDRESS=$(cat ~/.ec2/ip_address)
# Create new t1.micro instance using ami-cef405a7 (64 bit Ubuntu Server 10.10 Maverick Meerkat)
@pczerkas
pczerkas / prometheus.yml
Created September 9, 2022 16:34 — forked from venth/prometheus.yml
Prometheus configuration to scrape Kubernetes outside the cluster
# Prometheus configuration to scrape Kubernetes outside the cluster
# Change master_ip and api_password to match your master server address and admin password
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
# metrics for the prometheus server
- job_name: 'prometheus'
@pczerkas
pczerkas / gist:bf1ac32627a84f5760aa0ff6f68600d7
Created November 3, 2022 15:15 — forked from neerfri/gist:4bd7477920cb33a2a229807ed10c29c2
k8s cluster autoscaler command line options
$ docker run k8s.gcr.io/cluster-autoscaler:v1.2.2 /cluster-autoscaler -h
Usage of /cluster-autoscaler:
pflag: help requested
--address string The address to expose prometheus metrics. (default ":8085")
--alsologtostderr log to standard error as well as files
--application-metrics-count-limit int Max number of application metrics to store (per container) (default 100)
--azure-container-registry-config string Path to the file containing Azure container registry configuration information.
--balance-similar-node-groups Detect similar node groups and balance the number of nodes between them
--boot-id-file string Comma-separated list of files to check for boot-id. Use the first one that exists. (default "/proc/sys/kernel/random/boot_id"
@pczerkas
pczerkas / AttributeManagement.php
Created August 11, 2023 12:14 — forked from 0-Sony/AttributeManagement.php
Magento 2: change attribute type to Visual Swatch / Visual Text and add swatch options Ids
<?php
declare(strict_types=1);
namespace MyNamespace\Catalog\Model;
use Dnd\Catalog\Api\AttributeManagementInterface;
use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Eav\Api\AttributeRepositoryInterface;
use Magento\Eav\Api\Data\AttributeInterface;
@pczerkas
pczerkas / README.md
Created January 26, 2024 18:18 — forked from osy/README.md
Local caching for GitHub Actions self hosted runner using Squid Proxy

One of the biggest issues with using a self hosted GitHub runner is that actions that require downloading large amounts of data will bottleneck at the network. [actions/cache][1] does not support locally caching objects and artifacts stored on GitHub's servers will require a lot of bandwidth to fetch on every job. We can, however, set up a content proxy using [Squid][2] with SSL bumping to locally cache requests from jobs.

Patching Squid

A major challenge is that [actions/cache][1] uses Azure storage APIs which makes HTTP range requests. While Squid supports range requests, it is not good at caching them. There is an option, range_offset_limit none which, according to the [documentation][3]:

A size of 'none' causes Squid to always fetch the object from the beginning so it may cache the result. (2.0 style)

However, after extensive debugging, I discovered that the feature does not work if the client closes the connection. When range_offset_limit is set, Squid will make a full request to the server,