Skip to content

Instantly share code, notes, and snippets.

View tamsky's full-sized avatar

Marc Tamsky tamsky

View GitHub Profile
{
"manifest_version": 2,
"name": "Hacker News styles",
"version": "0.1",
"content_scripts": [{
"matches": ["https://news.ycombinator.com/*"],
"css": ["style.css"]
}]
}
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@tamsky
tamsky / raid_ephemeral.sh
Last active August 29, 2015 14:25 — forked from joemiller/raid_ephemeral.sh
detect all ephemeral disks on EC2 then stripe together in a raid-0 vol mounted at /mnt
#!/bin/bash
#
# this script will attempt to detect any ephemeral drives on an EC2 node and create a RAID-0 stripe
# mounted at /mnt. It should be run early on the first boot of the system.
#
# Beware, This script is NOT fully idempotent.
#
METADATA_URL_BASE="http://169.254.169.254/2012-01-12"
@tamsky
tamsky / online_google_auth.r
Last active August 29, 2015 14:25 — forked from MarkEdmondson1234/online_google_auth.r
Google OAuth2 Authentication functions for an R Shiny app
## GUIDE TO AUTH2 Authentication in R Shiny (or other online apps)
##
## Mark Edmondson 2015-02-16 - @HoloMarkeD | http://markedmondson.me
##
## v 0.1
##
##
## Go to the Google API console and activate the APIs you need. https://code.google.com/apis/console/?pli=1
## Get your client ID, and client secret for use below, and put in the URL of your app in the redirect URIs
## e.g. I put in https://mark.shinyapps.io/ga-effect/ for the GA Effect app,
@tamsky
tamsky / README.rst
Last active August 29, 2015 14:27 — forked from dupuy/README.rst
Common markup for Markdown and reStructuredText

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.

@tamsky
tamsky / reference-markdown-metadata-from-jinja-template.py
Last active August 29, 2015 14:27 — forked from glombard/reference-markdown-metadata-from-jinja-template.py
How to use Markdown as a filter in a Jinja2 template, and then extract the Markdown Meta property directly from the template. Assuming you want to use the Meta-data value before rendering the converted Markdown content (e.g. in the html head), the trick is to render the markdown first, save it to a variable (html_content in this example) using a…
from pprint import pprint
import jinja2
import markdown
HTML_TEMPLATE = """{% macro get_html() %}
{{ content | markdown }}
{% endmacro %}
{% set html_content = get_html() %}
Title from Markdown meta-data: {{ get_title() }}
@tamsky
tamsky / gist:1353addfc67c9266ed87
Last active August 29, 2015 14:27
Close all open ControlMaster sockets. Assumes ssh config has "ControlPath ~/.ssh/connections/%r_%h_%p"
(
cd ~/.ssh/connections/
for i in * ; do
PORT=${i##*_}
USER=${i%%_*}
UR=${i%%_$PORT}
REMOTE=${UR##$USER$'_'}
host: ${REMOTE}
ssh ${USER}@${REMOTE} -p ${PORT} -O exit
done
@tamsky
tamsky / ansible_conditionals_examples.yaml
Last active August 29, 2015 14:27 — forked from marcusphi/ansible_conditionals_examples.yaml
Ansible 1.3 Conditional Execution -- Very complete example with comments -- I find the conditional expressions to be ridiculously hard to get right in Ansible. I don't have a good model of what's going on under the surface so I often get it wrong. What makes it even harder is that there has been at least three different variants over the course …
---
# This has been tested with ansible 1.3 with these commands:
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts isFirstRun=false"
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts isFirstRun=true"
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts"
# NB: The type of the variable is crucial!
- name: Ansible Conditionals Examples
hosts: $hosts
vars_files:
@tamsky
tamsky / backup-keyspace.sh
Last active September 19, 2015 21:42 — forked from JensRantil/backup-keyspace.sh
Basic Cassandra -> S3 backup script
#!/bin/bash
KEYSPACE=$1
DATE=`date +"%Y-%m-%d--%H-%M-%S"`
FOLDER_NAME=${DATE}-daily
S3_BUCKET=s3://YOUR-S3-BUCKET
S3_BUCKET_PATH=cassandra/full/`date +"%Y/%m/%d/%H/%M"`/`cat /etc/hostname`
SNAPSHOTID=`uuidgen --time`
PGP_KEY_RECIPIENT=YOUR-PGP-KEY-RECIPIENT
@tamsky
tamsky / latest-pepper-flash.sh
Created October 28, 2015 02:09 — forked from ruario/README.md
Fetches Chrome and extracts out PPAPI Flash so that it can be used by other Chromium-based browsers
#!/usr/bin/env bash
available () {
command -v $1 >/dev/null 2>&1
}
# Make sure we have wget or curl
if available wget; then
SILENT_DL="wget -qO-"
LOUD_DL="wget"