Skip to content

Instantly share code, notes, and snippets.

View rom232's full-sized avatar

Rodrigo Otávio Moraes rom232

View GitHub Profile
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFzkGKoBEADMFlgrsvy/KwS5URoJq+VCcGizjMYKoIyoZQfjGPeNsWieC0kX
o/sY2JT93YFr6bzNjz76PV/K0y5WcHKMRpTEnVo2CaCGFZN4o29E/UFL/frx+HCM
PYPLBzMIbydSzsG7FnIUw0OZcFqpShtSFCt+wZCNsbGd9hCDCzTUKeFSDx1BSyGm
PExsCmRLBFqWrVqnX86FcnumwIU5U0ue0NAUwZTSio+iI2LKJCFkkVatsW5TM2Wn
B7djlNvZNi60VTmBhXx0pskMRWuWRKGF3EcLrlAnSuiMUA+QCoVs3l8YJ0oMGSVG
KfLIbWhkVMRDQzJA3F6oRcAhfnsb64yYlnn27z7QZSPIb/fiXkeHCVWrmIBXxMI7
gaRkEhiiP0eb9E74e4gjgahMc3NrfYpaXpbkDZhL3P/wuAoCW2bwVRt1ip1irWDb
IVyT5D9ayEmAUw635+P2eVZ274ArSHfGjNLZs5LkDLJgo4xQ1yC5CV0kiJ8NM0a6

sshx - Run a Local Script over SSH with Interactivity

Sometimes you want to run a bit more than just one command over ssh, and you also want to maintain interactivity to the processes that you launch. Usually you could just do ssh -t <host> "foo; bar; fish; paste" however that can quickly become unwieldly, especialy if it is more than just a sequence of commands. You also can't use cat my_script | ssh <host> /bin/bash because then you loose your stdin and thus your interactivity.

However, there is a way to achieve our goal using the first form above. Consider that the maximum command line length is usually more than 2MB (see getconf ARG_MAX). Thus, we convert our entire script into a base64 encoded string with cat my_script | base64 and then call ssh -t <host> /bin/bash "<(echo <base64 string> | base64 --decode)". In this way the entire script is sent to the host in the command buffer, and so long as our total command length is less than 2MB, it will run.

Keybase proof

I hereby claim:

  • I am rom232 on github.

  • I am rom232 (https://keybase.io/rom232) on keybase.

  • I have a public key ASBkbH5ZqqePLUyncnegrcIJdICCHn0om6ROR0myaF0Zjgo

@rom232
rom232 / openpgp.txt
Created May 21, 2019 03:32
Identidade Vinculada do OpenKeychain
This Gist confirms the Linked Identity in my OpenPGP key, and links it to this GitHub account.
Token for proof:
[Verifying my OpenPGP key: openpgp4fpr:7d66a77819d377513ad141c552a130cf7c11471b]
@rom232
rom232 / O'Reilly Design Books (Free).md
Created April 24, 2019 19:23 — forked from udezekene/O'Reilly Design Books (Free).md
Download the just released O'Reilly Design Books for free without e-mail signup.

Free O'Reilly Design Books and convenient script to just download them.

HUGE thanks to O'Reilly for making this resource free. Visit the design page if you want to learn more about the design resources. Also, they do have FREE resources for other topics like: Data, IoT, Programming, Security, Web Development, and WebOps.

Thanks @augbog for the initial gist. If you are a developer or looking for software engineering books, headover to the source of this fork.

How to use:

  1. Take the download.sh file and put it into a directory where you want the files to be saved.
  2. cd into the directory and make sure that it has executable permissions (chmod +x download.sh should do it)
@rom232
rom232 / tmux.cheat
Created February 29, 2016 18:21 — forked from afair/tmux.cheat
Tmux Quick Reference & Cheat sheet - 2 column format for less scrolling!
========================================== ==========================================
TMUX COMMAND WINDOW (TAB)
========================================== ==========================================
List tmux ls List ^b w
New -s <session> Create ^b c
Attach att -t <session> Rename ^b , <name>
Rename rename-session -t <old> <new> Last ^b l (lower-L)
Kill kill-session -t <session> Close ^b &
/**
* @name MapIconMaker
* @version 2.0b
* @author Pamela Fox, Marc Climent
* @copyright (c) 2008 Pamela Fox, 2010 Marc Climent
* @fileoverview This gives you static functions for creating dynamically
* sized and colored marker icons using the Charts API marker output.
*/
/*

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@rom232
rom232 / polar.rb
Created June 10, 2014 01:55 — forked from telent/polar.rb
require 'pp'
require 'socket'
module BluetoothPolarHrm
AF_BLUETOOTH=31 # these are correct for the Linux Bluez stack
BTPROTO_RFCOMM=3
class << self
def connect_bt address_str,channel=1
bytes=address_str.split(/:/).map {|x| x.to_i(16) }
s=Socket.new(AF_BLUETOOTH, :STREAM, BTPROTO_RFCOMM)
# This is an example resource file for rTorrent. Copy to
# ~/.rtorrent.rc and enable/modify the options as needed. Remember to
# uncomment the options you wish to enable.
# Maximum and minimum number of peers to connect to per torrent.
min_peers = 1
max_peers = 100
# Same as above but for seeding completed torrents (-1 = same as downloading)