Skip to content

Instantly share code, notes, and snippets.


Juanje Ojeda juanje

View GitHub Profile
juanje / gist:3797297
Created Sep 28, 2012
Mount apt cache of a Vagrant box in the host to spin up the packages installation
View gist:3797297

This is a little trick I use to spin up the packages instalation on Debian/Ubuntu boxes in Vagrant.

I add a simple function that checks if a directory named something similar to ~/.vagrant.d/cache/apt/opscode-ubuntu-12.04/partial (it may have another path in Windows or MacOS) and create the directory if it doesn't already exist.

def local_cache(basebox_name)
  cache_dir ='cache', 'apt', basebox_name)
  partial_dir = cache_dir.join('partial')
  partial_dir.mkdir unless partial_dir.exist?
juanje /
Last active Nov 17, 2021
Limit Chrome from eating all the memory and CPU

I was tired of Chrome eating all my laptop resources so I decided to put some limit to it with cgroup.

As I was using Ubuntu 12.04 with support for cgroup, I installed the package cgroup-bin and add the following group to the file /etc/cgconfig.conf:

group browsers {
    cpu {
#       Set the relative share of CPU resources equal to 25%
        cpu.shares = "256";
juanje /
Created Jun 10, 2020
Run Redis with Podman. As a Systemd service and as a Pod.
# This is a simple example of how to run a basic service inside a container with Podman
# Podman
## Pull the Docker image
podman pull
## Run the container as you would do with Docker
podman run -d --name redis_server -p 6379:6379 redis
# But Podman facilitate some extra ways:
juanje / compose_variables.yml
Last active Feb 21, 2021
Different ways to compose variables from other variables in Ansible
View compose_variables.yml
- name: Compose variables and merge lists
hosts: localhost
connection: local
gather_facts: no
- 1
- 2
juanje /
Last active Oct 9, 2020
Example of function to try something a max number of times (and wait between retries).
function get_file() {
# Declare these local variables as integer
local -i count
local -i max_retries
local -i wait_time
local filename
juanje /
Last active Oct 9, 2020
RPM tips & tricks
# Just a place to write down notes for old time Debian/Ubuntu user
# that has just moved into Fedora/RedHat world
# Show which package provides the file '/bin/ls'
# Similar to 'dpkg -S /bin/ls'
$ rpm -qf /bin/ls
# The same but showing only the package name (without version)
$ rpm -qf /bin/ls --queryformat '%{NAME}\n'
juanje /
Last active Aug 18, 2020
Some simple scripts to sync Toolbox's images using Skopeo
declare -a versions
versions=(29 31 32 33)
for version in "${versions[@]}"; do
echo "Create local copy from the remote image '${src}' into the directory '${dest}'"
juanje /
Created Aug 14, 2020
Remove libvirt domain after Vagrant fails
# Found hre:
sudo virsh list --all
# Find the domain is failing (<THE_MACHINE>)
sudo virsh destroy <THE_MACHINE>
sudo virsh undefine <THE_MACHINE> --snapshots-metadata --managed-save
sudo virsh vol-list default
sudo virsh vol-delete --pool default <THE_VOLUME>
juanje /
Last active Jul 23, 2020
Quick and dirty way t test the last built of GNOME OS
# More info here:
# I changed some minor options to have it working out the box.
# Be aware that the compressed image that you need to download is 1 Gb large.
# And, once it gets decompressed, it is 17 Gb large.
# Download the last GNOME OS image:
# Decompress it:
unxz disk.img.xz
juanje / gnome.yml
Created Jul 4, 2020
Set some Gnome configurations using Ansible
View gnome.yml
- name: Configure desktop
hosts: localhost
gather_facts: false
- { key: "/org/gnome/desktop/interface/clock-show-date", value: "true" }
- { key: "/org/gnome/desktop/interface/clock-show-weekday", value: "true" }
- { key: "/org/gnome/desktop/peripherals/touchpad/natural-scroll", value: "false" }