Skip to content

Instantly share code, notes, and snippets.

View josepsmartinez's full-sized avatar

José Pedro Silveira Martinez josepsmartinez

View GitHub Profile
@mamaj
mamaj / ssh-utils.py
Last active September 4, 2024 06:21
Python: simple class to perform commands and copy files (scp) on ssh using subprocess and native ssh client (OpenSSH).
import subprocess
import os
from pathlib import Path
from typing import Union
class SshClient():
""" Perform commands and copy files on ssh using subprocess
and native ssh client (OpenSSH).
"""
@mchelem
mchelem / gcp-bucket-display-images-bookmarklet.js
Last active February 14, 2022 04:34
Bookmarklet do display all images in a GCP bucket path
javascript:(function() {
let table = document.getElementsByTagName("table")[0];
let linkList = table.querySelectorAll("a.object-link");
let imageElements = [...linkList].map(url => {
let path = url.href.split("_details")[1];
let name = url.href.split("/").pop().split("?")[0];
return "<img height=200 src='https://storage.cloud.google.com" + path + "' title='" + name + "'/>";
});
imageElements = Array.from(new Set(imageElements));
table.insertAdjacentHTML("beforebegin", "<div>" + imageElements.join("") + "</div>");
@josepsmartinez
josepsmartinez / ssh-set-permissions.sh
Last active October 3, 2021 15:49
ssh permissions
#!/bin/bash
# Configs
chmod 700 $HOME/.ssh
chmod 644 $HOME/.ssh/authorized_keys
chmod 644 $HOME/.ssh/known_hosts
chmod 644 $HOME/.ssh/config
# Keys
chmod 600 $HOME/.ssh/id_rsa
@josepsmartinez
josepsmartinez / SCRIPTPATH.sh
Last active March 21, 2022 13:27
Safe practice for attributing a script's directory UNIX path to a shell variable [Reference: https://stackoverflow.com/posts/4774063/revisions (2020/12/27)]
#!/bin/bash
SCRIPTPATH=$( cd $(dirname $0) >/dev/null 2>&1 ; pwd -P )
@GregRos
GregRos / startTerminator.vbs
Created April 27, 2019 00:20 — forked from ropnop/startTerminator.vbs
VBS Script to Launch Terminator through WSL
' terminator.vbs
myCd = "~"
If WScript.Arguments.Length > 0 Then
myCd = "'$(wslpath -u '" & WScript.Arguments(0) & "')'"
End If
args = "bash" & " -c ""cd " & myCd & "; DISPLAY=:0 terminator"""
WScript.CreateObject("Shell.Application").ShellExecute "C:\Windows\System32\wsl.exe", args, "", "open", 0
@nistath
nistath / terminator.vbs
Last active February 19, 2023 22:15 — forked from ropnop/startTerminator.vbs
Script to start terminator on WSL from CMD or PowerShell
' Usage: terminator[.vbs] [path to starting directory]
' contents enclosed in square brackets optional
args = "-c" & " -l " & """DISPLAY=:0 terminator"""
' If there's a single argument, interpret it as the starting directory
If WScript.Arguments.Count = 1 Then
dir = WScript.Arguments(0)
Else
dir = ""
@PingjunChen
PingjunChen / convert_svs_img.py
Last active December 13, 2023 16:39
Convert SVS file to TIFF image
# -*- coding: utf-8 -*-
__author__ = "Pingjun Chen"
__email__ = "chenpingjun@gmx.com"
import os, sys, pdb
import numpy as np
from scipy import misc
import matplotlib.pyplot as plt
from skimage import io
import openslide
@ropnop
ropnop / startTerminator.vbs
Created September 29, 2017 00:02
VBS Script to Launch Terminator through WSL
args = "-c" & " -l " & """DISPLAY=:0 terminator"""
WScript.CreateObject("Shell.Application").ShellExecute "bash", args, "", "open", 0
@Brainiarc7
Brainiarc7 / xclip-copy-to-clipboard.md
Created April 26, 2017 17:53
Using xclip to copy terminal content to the clip board on Linux

Using xclip to copy terminal content to the clip board:

Say you want to pipe shell output to your clipboard on Linux. How would you do it? First, choose the clipboard destination, either the Mouse clip or the system clipboard.

For the mouse clipboard, pipe straight to xclip:

echo 123 | xclip

For the system clip board, pipe to xclip and select clip directly:

@xcsrz
xcsrz / center_text_on_image.py
Created March 8, 2017 00:17
Center text on an image with Python and OpenCV. Had to come up with it myself as no one was spelling this out anywhere (or google couldn't find it)
#!/usr/bin/env python
import numpy as np
import cv2
from time import sleep
# create blank image - y, x
img = np.zeros((600, 1000, 3), np.uint8)
# setup text