Skip to content

Instantly share code, notes, and snippets.

View mattknox's full-sized avatar

matt knox mattknox

View GitHub Profile

Let's say you have a Bash shell script, and you need to run a series of operations on another system (such as via ssh). There are a couple of ways to do this.

First, you can stage a child script on the remote system, then call it, passing along appropriate parameters. The problem with this is you will need to manually keep the remote script updated whenever you change it -- could be a bit of a challenge when you have something to execute on a number of remote servers (i.e., you have a backup script running on a central host, and it needs to put remote databases in hot backup mode before backing them up).

Another option is to embed the commands you want to run remotely within the ssh command line. But then you run into issues with escaping special characters, quoting, etc. This is ok if you only have a couple commands to run, but if it is a complex piece of Bash code, it can get a bit unwieldy.

So, to solve this, you can use a technique called rpcsh -- rpc in shell script, as follows:

First, place th

@mattknox
mattknox / wisdom.md
Created November 7, 2021 20:59 — forked from merlinmann/wisdom.md
Merlin's Wisdom Project (Draft)

Wisdom From Merlin

Or: “Everybody likes being given a glass of water.”

It's only advice for you because it had to be advice for me.


This odd collection began life as a challenge for a podcast 
@mattknox
mattknox / looking for the mouse.md
Created May 3, 2021 23:47 — forked from jm3/looking for the mouse.md
Gin, Television, and Social Surplus

Gin, Television, and Social Surplus, or, “Looking for the Mouse”

Clay Shirky / April 26, 2008

transcription of a speech [Clay Shirky] gave at the Web 2.0 in 2008, emphasis by @jm3

I was recently reminded of some reading I did in college, way back in the last century, by a British historian arguing that the critical technology, for the early phase of the industrial revolution, was gin.

The transformation from rural to urban life was so sudden, and so wrenching, that the only thing society could do to manage was to drink itself into a stupor for a generation. The stories from that era are amazing-- there were gin pushcarts working their way through the streets of London.

And it wasn't until society woke up from that collective bender that we actually started to get the institutional structures that we associate with the industrial revolution today. Things like public libraries and museums, increasingly broad education for children, elected leaders--a lot of th

@mattknox
mattknox / GIF-Screencast-OSX.md
Created October 26, 2018 21:15 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

require "socket"
class Memcached
attr_accessor :client
def initialize(store = {})
@client = client
@store = store
end
def get(key)
@mattknox
mattknox / blockstack
Created November 6, 2017 19:55
blockstack verification
Verifying my Blockstack ID is secured with the address 1ALEXweBWEeGVpeQYiYoqpkfjDVz7MZmmS https://explorer.blockstack.org/address/1ALEXweBWEeGVpeQYiYoqpkfjDVz7MZmmS
@mattknox
mattknox / keybase.md
Created November 1, 2017 20:46
keybase verification

Keybase proof

I hereby claim:

  • I am mattknox on github.
  • I am mattknox (https://keybase.io/mattknox) on keybase.
  • I have a public key ASCyzg1VoVlb5wEtV8Ah5OUhfMlyaWfQcsm6otEhVtcWzgo

To claim this, I am signing this object:

@mattknox
mattknox / GraphQL-Architecture.md
Created April 21, 2017 21:32 — forked from idibidiart/GraphQL-Architecture.md
Building an Agile, Maintainable Architecture with GraphQL

Building a Maintainable, Agile Architecture for Realtime, Transactional Apps

A maintainable application architecture requires that the UI only contain the rendering logic and execute queries and mutations against the underlying data model on the server. A maintainable architecture must not contain any logic for composing "app state" on the client as that would necessarily embed business logic in the client. App state should be persisted to the database and the client projection of it should be composed in the mid tier, and refreshed as mutations occur on the server (and after network interruption) for a highly interactive, realtime UX.

With GraphQL we are able to define an easy-to-change application-level data schema on the server that captures the types and relationships in our data, and wiring it to data sources via resolvers that leverage our db's own query language (or data-oriented, uniform service APIs) to resolve client-specified "queries" and "mutations" against the schema.

We use GraphQL to dyn

@mattknox
mattknox / postgres_queries_and_commands.sql
Created December 14, 2016 23:44 — forked from indigoviolet/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@mattknox
mattknox / repo_cleanup.rb
Created September 2, 2016 20:33
cleanup merged branches
#! /usr/bin/env ruby
# if run inside a git repo, this will pull current master and force remove all branches that have no diff against master.
# this is useful if you use squash-merge- or rebase-based merge strategies, and does not require anything particular of the
# developer to use.
in_repo = system("git status")
unless in_repo
puts "run this from inside a git repo"
exit 1