Skip to content

Instantly share code, notes, and snippets.

View francois's full-sized avatar

François Beausoleil francois

  • Sherbrooke, QC, Canada
View GitHub Profile
francois@francois:/home/francois $ mkdir a b
francois@francois:/home/francois $ echo "A" > a/A
francois@francois:/home/francois $ echo "B" > b/B
francois@francois:/home/francois $ echo "C" > a/C
francois@francois:/home/francois $ envdir a envdir b bash
francois@francois:~$ echo $A
A
francois@francois:~$ echo $B
B
francois@francois:~$ echo $C
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Another local or imported resource exists with the type and title Nagios_service[admin.local/health] on node todd.ca.seevibes.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
2014-05-15 18:45:11,896 ERROR [o.a.a.s.k.KahaDBStore] Failed to reset batching
java.lang.IllegalStateException: PageFile is not loaded
at org.apache.kahadb.page.PageFile.assertLoaded(PageFile.java:800) ~[puppetdb.jar:na]
at org.apache.kahadb.page.PageFile.tx(PageFile.java:294) ~[puppetdb.jar:na]
at org.apache.activemq.store.kahadb.KahaDBStore$KahaDBMessageStore.resetBatching(KahaDBStore.java:575) ~[puppetdb.jar:na]
at org.apache.activemq.store.ProxyMessageStore.resetBatching(ProxyMessageStore.java:111) [puppetdb.jar:na]
at org.apache.activemq.broker.region.cursors.QueueStorePrefetch.resetBatch(QueueStorePrefetch.java:85) [puppetdb.jar:na]
at org.apache.activemq.broker.region.cursors.AbstractStoreCursor.stop(AbstractStoreCursor.java:72) [puppetdb.jar:na]
at org.apache.activemq.broker.region.cursors.StoreQueueCursor.stop(StoreQueueCursor.java:84) [puppetdb.jar:na]
at org.apache.activemq.broker.region.Queue.stop(Queue.java:909) [puppetdb.jar:na]

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

WITH btree_index_atts AS (
SELECT nspname, relname, reltuples, relpages, indrelid, relam,
regexp_split_to_table(indkey::text, ' ')::smallint AS attnum,
indexrelid as index_oid
FROM pg_index
JOIN pg_class ON pg_class.oid=pg_index.indexrelid
JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace
JOIN pg_am ON pg_class.relam = pg_am.oid
WHERE pg_am.amname = 'btree'
),

Keybase proof

I hereby claim:

  • I am francois on github.
  • I am francois (https://keybase.io/francois) on keybase.
  • I have a public key whose fingerprint is B4AB D84F 0506 FAAE 5638 1E45 5A74 FF58 AD61 7433

To claim this, I am signing this object:

-- The owner of all database objects
-- This user can and will change the database schema
CREATE ROLE meetphil WITH NOSUPERUSER NOCREATEDB NOCREATEROLE LOGIN;
-- The group which all regular users will be part of
CREATE ROLE mpusers WITH NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT NOLOGIN;
-- The user which the web application connects as
-- Has limited rights by itself
CREATE ROLE mpwebui WITH NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT LOGIN IN ROLE mpusers;
int = Seevibes::Interval.new("1w")
int.period == 1
int.to_sql == "1 week"
int.unit == "week"
int.to_s == "1w"
int = Seevibes::IntervalParser.parse_interval("1w")
int.period == 1
int.to_sql == "1 week"
int.unit == "week"
@francois
francois / gist:8151926
Created December 27, 2013 20:04
Simple git pre-commit hook to prevent trailing whitespace from entering the repository.
#!/bin/sh
if ( /usr/bin/grep --quiet --exclude="*.log" --recursive --extended-regexp ' $' * )
then
echo >&2 "Trailing whitespace errors found in:"
/usr/bin/grep >&2 --files-with-matches --exclude="*.log" --recursive --extended-regexp ' $' *
echo >&2 ""
echo >&2 "Please fix before trying to commit again"
exit 1
fi
---
- parameters:
ports: "9194"
ipaddresses: "142.4.219.180"
server_names: "mike:9194"
tag: "dc:staging"
options: "check inter 65761 fastinter 1751 downinter 5761 weight 100"
listening_service: www-admin
line: 57
file: /etc/puppet/modules/seevibes/manifests/www_admin.pp