Skip to content

Instantly share code, notes, and snippets.

@mcoira
mcoira / unused-html-imports-bookmarket.js
Created October 27, 2015 17:33 — forked from ebidel/unused-html-imports-bookmarket.js
Bookmarklet to help prune unnecessary HTML Imports loaded on a page.
javascript:(function(){'use strict';var _temporalUndefined={};function _temporalAssertDefined(val,name,undef){if(val===undef){throw new ReferenceError(name+' is not defined - temporal dead zone');}return true;}(function(){'use strict';var els=_temporalUndefined;var allCustomElements=_temporalUndefined;var polymerRegisteredElements=_temporalUndefined;var diff=_temporalUndefined;function isCustomEl(el){return el.localName.indexOf('-')!=-1||el.getAttribute('is');}els=[].slice.call(document.querySelectorAll('html /deep/ *')).filter(function(el){return isCustomEl(el);}).map(function(el){return el.getAttribute('is')||el.localName;});allCustomElements=new Set(_temporalAssertDefined(els,'els',_temporalUndefined)&&els);polymerRegisteredElements=Polymer.telemetry.registrations.map(function(el){return el.is;}).filter(function(name){var blacklist=_temporalUndefined;blacklist=['dom-template','array-selector','custom-style'];return(_temporalAssertDefined(blacklist,'blacklist',_temporalUndefined)&&blacklist).indexOf(name)==
@mcoira
mcoira / gist:6f796c53f9a6af1641a2
Last active September 18, 2015 13:54 — forked from rustyrazorblade/gist:d4b2b048c4bd88e538ce
working migration
from pyspark.sql import SQLContext
sql = SQLContext(sc)
mysql_movies = sql.read.jdbc("jdbc:mysql://127.0.0.1:3307/movielens?user=root", "movielens.movies")
mysql_movies.write.format("org.apache.spark.sql.cassandra").options(table="movies", keyspace="lens").save(mode="append")
@mcoira
mcoira / backup
Last active August 29, 2015 14:26 — forked from icoloma/backup
Backup a Github repository into a local file. Useful when retiring a Github repository, but keeping a backup copy for a rainy day in Dropbox / Drive / Box.
#!/bin/bash
# Backup the repositories indicated in the command line
# Example:
# bin/backup user1/repo1 user1/repo2
set -e
for i in $@; do
FILENAME=$(echo $i | sed 's/\//-/g')
echo "== Backing up $i to $FILENAME.bak"
git clone git@github.com:$i $FILENAME.git --mirror
cd "$FILENAME.git"
"""Extract mean, median and percentiles from `nodetool cfhistogram` output.
Usage:
1. Run this script.
2. Paste in the output from a read or write latency histograms.
3. Press CTRL+D (to close stdin file descriptor).
"""
import sys
import collections
#!/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
#!/bin/bash
#
# Counts number of tombstones per partition key in one or multiple sstables.
#
# Usage: ./tombstone-count.sh /var/lib/cassandra/data/mykeyspace/mytable/*-Data.db
#
# Sample output:
# "40e6a9839bf44bdaa624cc53e96733fe" 8
# "8e177ab222c14f868bcb6d2922b18d2b" 8
# "28aaa9db0dad4ae78cabe8bcc25d14a3" 9
$('div.modal').on('show.bs.modal', function() {
var modal = this;
var hash = modal.id;
window.location.hash = hash;
window.onhashchange = function() {
if (!location.hash){
$(modal).modal('hide');
}
}
});