Skip to content

Instantly share code, notes, and snippets.

View mikybars's full-sized avatar

Miguel Ibars mikybars

  • Madrid
  • 04:22 (UTC +01:00)
View GitHub Profile
$ mvn clean install -DskipTests
@mikybars
mikybars / vim_retab.vim
Last active October 8, 2019 10:28
How to re-indent a file from 4 spaces to tabs and a width of 2:http://ppanyukov.github.io/2011/06/29/retabbing-in-vim.html
# Step 0. (Optional) Tell VIM to show whitespace:
:set list
# Step 1. Tell VIM what the the current tabsize is:
:set tabstop=4 # Tab size is 4 spaces
# Step 2. Convert spaces to real tabs:
:set noexpandtab # Use real tab instead of space
:retab! # Replace all space-tabs with real tabs
#!/usr/bin/env bash
USER=XXX
HOST=XXX
LOCAL_PATH=$(pwd)
REMOTE_PATH=docker/apache2/html
cat > /tmp/rsync-include.txt <<EOF
*/
*.html
@mikybars
mikybars / Animal.java
Created April 26, 2019 11:20
The `@AllArgsConstructor` annotation in the superclass is handy for generating the constructor with all the parameters in the subclass. In IntelliJ, for example, the `Generate->Constructor` helper automatically inserts the parameters belonging to the
@AllArgsConstructor
public class Animal {
private int age;
}
Map<String, String> caseInsensitiveMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
addons:
ssh_known_hosts: <deploy-host>
before_deploy:
- openssl aes-256-cbc -K $encrypted_<...>_key -iv $encrypted_<...>_iv -in deploy_rsa.enc -out /tmp/deploy_rsa -d
- eval "$(ssh-agent -s)"
- chmod 600 /tmp/deploy_rsa
- ssh-add /tmp/deploy_rsa
@mikybars
mikybars / docker_stdin.sh
Last active October 10, 2019 11:10
Feed input to a Docker container
$ docker container run -i db psql postgres -U postgres <<EOF
CREATE TABLE employee (id INTEGER PRIMARY KEY, name VARCHAR);
INSERT INTO employee VALUES (1, 'Miguel');
INSERT INTO employee VALUES (2, 'Javier');
EOF
@mikybars
mikybars / ex.sh
Last active February 18, 2019 23:31
sed & ex examples showcasing use cases of regex syntax for group capturing & backreferencing
# Lowercase all html tags
$ ex - '+%s,<\(.*\)>,<\L\1>,' -cwq index.html
$ docker image inspect -f 'CMD {{.Config.Cmd}}, ENTRYPOINT {{.Config.Entrypoint}}' postgres:9.4
CMD [postgres], ENTRYPOINT [docker-entrypoint.sh]
echo -en "Directory ~/bin already exists, overwrite it? [Y/n]: "
read -n 1 action; echo
case "$action" in
'') ;&
[Yy]) rm -rf ~/bin;;
*) echo "Skipping directory ~/bin";;
esac