Skip to content

Instantly share code, notes, and snippets.

View davidlukac's full-sized avatar

David Lukac davidlukac

View GitHub Profile
@davidlukac
davidlukac / parseAllModules
Last active August 29, 2015 14:19
Parse enabled modules from modules pages (Drupal 7.x; /admin/modules)
var module = '';
jQuery.each(jQuery('#system-modules tr'), function(index, value) {
if (jQuery( this).find('.form-checkbox').val() == 1) {
module = module + '\n' + jQuery(this).find('strong').text() + ',' + jQuery( this).find('td:nth-child(3)').text();
}
});
console.log(module);
@davidlukac
davidlukac / append-timestamp-drush.sh
Last active March 22, 2016 14:33
Shell - related
# The snippet ads timestamp to every line of the output.
drush @site.aloas solr-index | awk -v now="$(date +"%Y-%m-%d %r")" '{ print now ":\n" $0; fflush(); }' | tee -a drush-index.log`
@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);
@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.
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.
<?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");
@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
@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 / 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 / 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.