Skip to content

Instantly share code, notes, and snippets.

@fabricat
fabricat / ssh-agent.sh
Last active September 25, 2020 09:18
Load a private key in ssh-agent (from file or Lastpass), eventually using also Pageant (on Cygwin)
#!/bin/bash
### Setup: source this script from your .bashrc or .bash_profile
### In Cygwin, you can use Putty (Plink + Pageant) for GIT - see https://git-scm.com/docs/git
export GIT_SSH_COMMAND='"/cygdrive/c/Program Files/PuTTY/plink.exe" -agent'
export GIT_SSH_VARIANT='plink'
### Some tools don't like Putty (e.g. Ansible): then use also "ssh-agent"
environ="$HOME/.ssh/environment"
if [ -f "$environ" ]; then
@fabricat
fabricat / twig-getTemplateVars.php
Created April 4, 2019 10:38
Get all variable names defined in a Twig template
<?php
tokens = $twig->tokenize($loader->getSourceContext('index.html'));
$templateVars = [];
while (!$tokens->isEOF()) {
$token = $tokens->next();
if ($token->getType() === \Twig_Token::VAR_START_TYPE) {
$templateVars[] = $tokens->next()->getValue();
$tokens->next();
}
}