Skip to content

Instantly share code, notes, and snippets.

View dergachev's full-sized avatar

Alex Dergachev dergachev

View GitHub Profile
@dergachev
dergachev / Docker-forward-ssh-agent.sh
Created May 15, 2014 17:51
Allows SSH Agent forwarding into docker container
# NB: the line with SSH_AUT_SOCK allows SSH Agent forwarding into docker container
# NB: umask 002 makes all newly created files group-writable
docker-run-with-agent:
docker run -t -i \
-v `pwd`/source:/srv/docker-jekyll/source/ \
-v `pwd`/deploy:/srv/docker-jekyll/deploy \
-v `dirname $(SSH_AUTH_SOCK)`:`dirname $(SSH_AUTH_SOCK)` -e SSH_AUTH_SOCK=$(SSH_AUTH_SOCK) \
-p 4000:4000 \
dergachev/docker-jekyll \
/bin/bash -c "umask 002; $(cmd) $(args)"

With TigerVNC

TigerVNC is the only vnc client that seems to support proxmox's SSL encryption scheme.

If you're willing to install it on your client, run the following:

ssh -L 1234:localhost:1234 mimosa.tree.ewdev.ca -l root -- socat tcp-l:1234,range=127.0.0.1/32 exec:"'"qm vncproxy 119"'"

tigervnc localhost:1234
ADD docker-umask-wrapper.sh /bin/docker-umask-wrapper.sh
RUN chmod u+x /bin/docker-umask-wrapper.sh
@dergachev
dergachev / SPIN-selling.md
Last active July 17, 2022 03:03
SPIN Selling seminar
'use strict';
window.addEventListener("DOMContentLoaded", SL_GOOGLE_WPT(), false);
document.addEventListener('mousedown',function(){SL_HideButton();},!1);
document.addEventListener('mouseup',function(e){QuickBubbleInit(e);},!1);
window.addEventListener("load", setTimeout('SL_Hider()',500), false);
@dergachev
dergachev / Makefile
Last active August 29, 2015 13:57
Makefile for partial re-indexing while working with search_api
#============================================================================
# Utilities
#============================================================================
num_items_to_index = $(shell drush sqlq "SELECT COUNT(*) FROM search_api_item;" --extra=--skip-column-names)
index_name = coursecal_content
index_id = $(shell drush php-eval 'print search_api_index_load("$(index_name)")->id')

When debugging Drupal, I often stick dpm($some_array, "my array"); calls to see what the value of $some_array is. This fails spectacularly if the code I'm debugging is run very late in the request after drupal_get_messages() has already been called. (Eg most hook_preprocess_THEMEHOOK functions).

In that case, I've found it useful to add these helper functions somewhere (any enabled custom module, or even index.php), use them instead of dpm. They'll serialize objects to apache's error_log (wherever that is), which you can track by opening a terminal tab and running:

tail -f /var/log/apache2/error.log | tr '%' "\n"
@dergachev
dergachev / squid-deb-proxy_on_docker.md
Last active February 21, 2025 02:49
Caching debian package installation with docker

TLDR: I now add the following snippet to all my Dockerfiles:

# If host is running squid-deb-proxy on port 8000, populate /etc/apt/apt.conf.d/30proxy
# By default, squid-deb-proxy 403s unknown sources, so apt shouldn't proxy ppa.launchpad.net
RUN route -n | awk '/^0.0.0.0/ {print $2}' > /tmp/host_ip.txt
RUN echo "HEAD /" | nc `cat /tmp/host_ip.txt` 8000 | grep squid-deb-proxy \
  && (echo "Acquire::http::Proxy \"http://$(cat /tmp/host_ip.txt):8000\";" > /etc/apt/apt.conf.d/30proxy) \
  && (echo "Acquire::http::Proxy::ppa.launchpad.net DIRECT;" >> /etc/apt/apt.conf.d/30proxy) \
  || echo "No squid-deb-proxy detected on docker host"

Vim and clipboard support

I generally prefer to use the terminal version of vim, rather than macvim. The major downside is no direct OSX clipboard integration. I tried running brew install vim but even that doesn't seem to compile with +clipboard support. I really wish "+yy and +"p would just work!

Turns out that there's a great little plugin for that, fakeclip!

There are different ways to install vim plugins into ~/.vim/, but these days all the cool kids are using vundle. Here's how to install vundle, then use it to install fakeclip.

Installing vundle

@dergachev
dergachev / _side-by-side-diff.md
Last active January 2, 2016 10:39
Side-By-Side Diff Bookmarklet

Side-By-Side Diff Bookmarklet

Currently hardcodes these domain pairs, tweak it for your use-case:

var urls = {prod: "http://www.mcgill.ca/study/2013-2014", dev: "http://amir-dev.tree.ewdev.ca"}; 

Activating the bookmarklet once on either site displays the same page side-by-side with its complement, as follows: