Skip to content

Instantly share code, notes, and snippets.

View davidlukac's full-sized avatar

David Lukac davidlukac

View GitHub Profile
@davidlukac
davidlukac / k8s-get-version.sh
Last active March 30, 2021 11:32
Get Kubernetes cluster version from the cluster using kubectl CLI or kubernetes Terraform provider
#!/usr/bin/env bash
# Prerequsites:
# - have kubectl installed
# - be logged in via kubectl
# - have enough permissions to access kubeadm-config Config Map
# - have jq installed (https://stedolan.github.io/jq/)
# - have yq installed (https://mikefarah.gitbook.io/yq/)
kubectl get configmap kubeadm-config -n kube-system -o json | \
@davidlukac
davidlukac / secret.json
Created April 11, 2020 21:41
terraform-poc
{
"USERNAME": "foo-user",
"PASSWORD": "somepassword123"
}
@davidlukac
davidlukac / script.sh
Created March 30, 2019 17:46
Bash - Iterating over directory structure and replacing pattern from input list
LIST_FILENAME="input-list.txt"
SERVICES=$(cat ${LIST_FILENAME})
NO_SERVICES=$(cat ${LIST_FILENAME} | wc -l)
FILES=(`find . -type f -not -path "./.git/*" -prune -not -path "./script.sh" -not -path "./${LIST_FILENAME}" | sort`)
NO_FILES="${#FILES[@]}"
FILE_NO=1
echo "Processing ${NO_SERVICES} services and ${NO_FILES} files."
# Iterate over all files.
@davidlukac
davidlukac / main.py
Last active October 27, 2017 15:49
Joining CSVs rough way
from modules.modules import CsvRepository, FileResource
def read_and_write(source_file: str, f, rm_header: bool):
line_counter = 0
with open(source_file) as f_in:
for line in f_in:
if rm_header:
if line_counter != 0:
f.write(line)
@davidlukac
davidlukac / FallbackCacheItemRepository.php
Last active December 2, 2016 18:57
FallBackCachItem and Spec
<?php
namespace NMH\Helper;
use Stash\Invalidation;
use Tedivm\StashBundle\Service\CacheService;
/**
* Class FallbackCacheItemRepository
*
@davidlukac
davidlukac / circleci-tunnel.sh
Last active August 26, 2021 12:16
VPN via Redsocks
#!/usr/bin/env bash
set -xe
SSH_USER_PWD="${SSH_USER_PWD}"
SSH_USER="${SSH_USER}"
VPN_GATEWAY="${VPN_GATEWAY}"
sshpass -p "${SSH_USER_PWD}" ssh -o StrictHostKeyChecking=no -v "${SSH_USER}@${VPN_GATEWAY}" -22 -D 9999 -nf "sleep 90000" &
echo 'base{log_debug = on; log_info = on; log = "file:/tmp/reddi.log";daemon = on; redirector = iptables;}redsocks { local_ip = 127.0.0.1; local_port = 12345; ip = 127.0.0.1;port = 9999; type = socks5; }' > ~/redsocks.conf
<?php
// Version 2016.2
error_reporting(0);
define('HHVM_PHP_INI', "/etc/hhvm/php.ini");
define('HHVM_SERVER_INI', "/etc/hhvm/server.ini");
define('XDEBUG', "xdebug");
define('ZEND_DEBUGGER', "Zend Debugger");
diff --git a/dmemcache.inc b/dmemcache.inc
index b19c9c2..e279144 100644
--- a/dmemcache.inc
+++ b/dmemcache.inc
@@ -394,6 +394,11 @@ function dmemcache_get_multi($keys, $bin = 'cache', $mc = NULL) {
if ($collect_stats) {
foreach ($multi_stats as $key => $value) {
+ // If we are using the broken version of memcache library, we need to
+ // prepend the key prefix to get correct statistics for get/set_multiple.
@davidlukac
davidlukac / Coins.scala
Created April 30, 2016 09:44
Learning Scala / Scala snippets
package com.davidlukac.learn.scala
/**
* Created by davidlukac on 30/04/16.
*/
class Coins {
def countChange(money: Int, coins: List[Int]): Int = {
// Just for the sake of algorithm logic, sort the coins from highest value, to smallest value.
@davidlukac
davidlukac / index.php
Created April 7, 2016 16:32
Drupal 7 snippets
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);