Skip to content

Instantly share code, notes, and snippets.

View malkab's full-sized avatar

Juan Pedro Pérez Alcántara malkab

  • Sunntics Ltd.
  • Seville, Andalusia (Spain)
View GitHub Profile
@malkab
malkab / tar.sh
Last active June 23, 2022 09:42
tar
# TAR
tar -cvf archive.tar folder
tar -xvf archive.tar -C folder_to_deploy --strip 1
tar -tvf archive.tar
# BZ2
tar -jcvf archive.tar.bz2 folder
tar -jxvf archive.tar.bz2 -C folder_to_deploy --strip 1
tar -jtvf archive.tar.bz2

Interpolating a Range with a Predefined Color Scale

const pointColorScale = d3
  .scaleSequential(d3.interpolateTurbo)
  .domain(extent);

where interpolateTurbo is the predefined color scale and extent is the variable min / max values.

@malkab
malkab / linux_software.md
Last active May 27, 2022 07:45
Linux Software

A List of Useful Linux Software

Open Software:

  • FreePlane: Mind Maps;
  • GThumb, Shotwell, Shutter: image viewers, each with their own strengths;
  • Krita, Glimpse: image editing software, Photoshop like;
  • pgAdmin4: PostgreSQL manager, including an ERD editor that generates SQL, very handy to design a database;
  • Pomatez: useful timer, Pomodoro-like;
  • Variety: versatile wallpaper manager.
@malkab
malkab / ssh-recipes.md
Last active May 19, 2022 07:42
SSH - Recipes

Recipes for SSH

SSH bridge using a in-the-middle machine

The situation:

  • A_HOST is a machine that has access to another machine, T_HOST, where the target resource is. For example, a machine able to open a privileged VPN to the resource's machine that B_HOST is unable to open;
  • B_HOST is the machine that is unable to open a connection to the T_HOST where the target resource is;
  • T_HOST is the machine that has the target resource on port T_PORT;
  • T_PORT is the port where the target host T_HOST publish the resource;
@malkab
malkab / rsync_examples.sh
Last active May 18, 2022 14:54
rsync examples
#!/bin/bash
# Get all *.tar files from the remote server app folder, without recursing into folders
rsync -avh --progress --rsh="ssh -i aws-pem" \
user@host:/path/to/folder/*.tar ~/Desktop
# Complete with exclude and mlkctxt
@malkab
malkab / docker_repositories.sh
Created May 16, 2022 11:11
Docker Repositorios
# How to log in Docker repositories
# Log into DockerHub repository (default)
# Private repositories at DockerHub must be created manually beforehand
# and set to private
docker login -u USERNAME -p PASSWORD
# Log into GitLab repository
docker login -u USERNAME -p PASSWORD <registry URL>/<namespace>/<project>/<image>
@malkab
malkab / rxjs_subjects.ts
Last active April 26, 2022 10:20
RxJS - Subjects
import * as rx from "rxjs";
/**
Define a class with a Subject$.
*/
class A {
/**
@malkab
malkab / cli_json_manipulation_jq.sh
Created April 20, 2022 09:46
CLI JSON Manipulation - jq
#!/bin/bash
# Color output
jq --color-output . file.json
# Pretty
jq '.' non-pretty.json > pretty.json
@malkab
malkab / complex_template.yml
Created April 13, 2022 22:12
tmuxinator Templates
name: sunnsaas_v1-full_backend
root: /home/git/sunnsaas/sunnsaas_v1
startup_window: sunnsaas_v1-full_backend/full_backend
# This shows a custom layout obtained with PREFIX : list-windows after configuring it with PREFIX : resize-pane
# Predefined layouts are: even-horizontal, even-vertical, main-horizontal, main-vertical, and tiled.
windows:
- sunnsaas_v1-full_backend/full_backend:
layout: 935c,317x73,0,0{210x73,0,0[210x36,0,0,0,210x36,0,37,4],106x73,211,0[106x18,211,0,1,106x17,211,19,5,106x18,211,37,2,106x17,211,56,3]}
@malkab
malkab / python_json_etl.py
Created April 13, 2022 11:27
Python - JSON ETL
# -------------------------
#
# Reads JSON from file, process it, and save results
#
# -------------------------
import json
wpBaseFolder = "workpackages/wp-2022-04-13-010-process-heliostat_fields/src"
with open("%s/data/000_in/Hel_Eff_param.json" % wpBaseFolder) as f: