Skip to content

Instantly share code, notes, and snippets.


Juanje Ojeda juanje

View GitHub Profile
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" }
juanje / gist:1310403
Created Oct 24, 2011
Use Ruby as AWK or Grep
View gist:1310403
# 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:
# 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 /
Last active Apr 22, 2020
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 /
Last active Apr 19, 2020
Example for an User class in Python with dataclasses
from dataclasses import dataclass
class User:
user_id: str = None
name: str = None
email: str = None
role: str = 'standard'
juanje / Dockerfile
Created Apr 15, 2020
Dockerfile multi-stage for a minimal production-ready React app
View Dockerfile
# 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
# Copy the dependencies files
COPY package.json package-lock.json /app/
juanje /
Last active Apr 13, 2020
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

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

juanje /
Created Apr 13, 2020
Passing parammeters to ansible-playbook in a shellscript
# This is a small test to check how to pass some parameters with
# special characters (!) to avoid shell calls, to ansible-playbook.
ansible-playbook -l "${_except}" bootstrap.yml
juanje / karma.js
Created Apr 13, 2020
Example of Karma configuration to test Js with Chrome Headless
View karma.js
// Karma configuration file, see link for more information
module.exports = function (config) {
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
juanje / rules.js
Created Apr 13, 2020
Example of Rules configuration for Firebase/Firestore
View rules.js
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isAdmin() {
let adminData = get(/databases/$(database)/documents/permissions/admin).data;
return isCompany() && request.auth.uid in adminData.userIds