Skip to content

Instantly share code, notes, and snippets.

View juanje's full-sized avatar

Juanje Ojeda juanje

View GitHub Profile
@juanje
juanje / backup_toolbox_images.sh
Last active August 18, 2020 19:35
Some simple scripts to sync Toolbox's images using Skopeo
#!/bin/bash
declare -a versions
versions=(29 31 32 33)
for version in "${versions[@]}"; do
src="registry.fedoraproject.org/f${version}/fedora-toolbox:${version}"
dest="fedora-toolbox-${version}"
echo "Create local copy from the remote image '${src}' into the directory '${dest}'"
@juanje
juanje / virsh_remove_domain.sh
Created August 14, 2020 16:52
Remove libvirt domain after Vagrant fails
# Found hre: https://github.com/vagrant-libvirt/vagrant-libvirt/issues/658#issuecomment-380976825
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
juanje / run_GNOME_OS.sh
Last active July 23, 2020 19:20
Quick and dirty way t test the last built of GNOME OS
# More info here: https://gitlab.gnome.org/GNOME/gnome-build-meta/-/wikis/home
# 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:
wget https://gitlab.gnome.org/GNOME/gnome-build-meta/-/jobs/artifacts/master/raw/image/disk.img.xz?job=vm-image-x86_64
# Decompress it:
unxz disk.img.xz
@juanje
juanje / gnome.yml
Created July 4, 2020 02:26
Set some Gnome configurations using Ansible
---
- name: Configure desktop
hosts: localhost
gather_facts: false
vars:
dconf_items:
- { 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" }
@juanje
juanje / gist:1310403
Created October 24, 2011 21:37
Use Ruby as AWK or Grep
# A few examples about how to use Ruby for parsing files as we could do
# with Awk or Grep. This is based on what I learn fro this post:
# http://code.joejag.com/2009/using-ruby-as-an-awk-replacement/
# Split each line with ':' and print the first $F[0] field
awk -F: '{ print $1 }' /etc/passwd
ruby -F: -nae 'puts $F[0]' /etc/passwd
# Parse the 'ps aux' output
# It'll print the ID process for the 'jojeda' user
@juanje
juanje / test_web.py
Last active April 22, 2020 19:58
Smoke tests for a web server with TestInfra
import requests
def test_website_1(host):
"""Check if the website is recheable from outside the managed host,
using the standar Python's library Requests.
It also check for the website content.
"""
host_ip = host.interface("eth0").addresses[0]
result = requests.get(f'http://{host_ip}')
@juanje
juanje / Dockerfile
Created April 15, 2020 12:41
Dockerfile multi-stage for a minimal production-ready React app
# Multistage Dockerfile
# STEP 1: build the Reac static files
FROM node:13.2.0-alpine as builder
# Create app directory and set a current directory
WORKDIR /app
# Copy the dependencies files
COPY package.json package-lock.json /app/
@juanje
juanje / description.md
Last active April 13, 2020 15:50
Filter json file with jq

Filter json file with jq

Let's say we have the file data.json with a json compacted in one line:

$ cat data.json
{"employees":[{"name":"Shyam","email":"shyamjaiswal@example.com"},{"name":"Bob","email":"bob32@example.com"},{"name":"Jai","email":"jai87@example.com"}]}

We can use the command jq to see it in with nicer format:

@juanje
juanje / script.sh
Created April 13, 2020 15:49
Passing parammeters to ansible-playbook in a shellscript
#!/bin/bash
# This is a small test to check how to pass some parameters with
# special characters (!) to avoid shell calls, to ansible-playbook.
_except='!dell10,!dell19'
ansible-playbook -l "${_except}" bootstrap.yml
@juanje
juanje / karma.js
Created April 13, 2020 15:38
Example of Karma configuration to test Js with Chrome Headless
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),