Skip to content

Instantly share code, notes, and snippets.

@multimeric
multimeric / mtgjson to csv
Created September 11, 2016 13:04
Bash script to convert mtgjson's AllCards.json into a csv format
# Download the database
wget https://mtgjson.com/json/AllCards.json.zip
# Unzip it
unzip AllCards.json.zip
# Convert to CSV
jq -r 'to_entries[] | [.key, (.value | tostring ) ] | @csv' AllCards.json > AllCards.csv
# Load into postgres
@multimeric
multimeric / dna_nexus_debug.sh
Created February 27, 2017 04:40
Script to run a DNA Nexus app from inside the app, with the same environment as it would be run automatically
# Replace the job-* file with the right job ID
sudo -E PYTHONPATH=$PYTHONPATH bash job-F2kfkk804G2KyYvvF3fKffy2
@contextlib.contextmanager
def suppress_outputs(suppress_stdout=True, suppress_stderr=True):
"""
Context manager that can be used to suppress any printing to sdtout or stderr from any python
code within its context
"""
#Open /dev/null
null = open(os.devnull, 'w')
@multimeric
multimeric / .vimrc
Created August 18, 2017 08:08
Colemak Vim Config
" Always use the system clipboard
set clipboard=unnamed
" X deletes without adding to the register
noremap x "_x
vnoremap x "_x
" Colemak key bindings
noremap n h
noremap e j
@multimeric
multimeric / aws-creds.bash
Created November 5, 2018 00:50 — forked from ddgenome/aws-creds.bash
Fetch AWS STS keys and set environment variables
#!/bin/bash
# Fetch 24-hour AWS STS session token and set appropriate environment variables.
# See http://docs.aws.amazon.com/cli/latest/reference/sts/get-session-token.html .
# You must have jq installed and in your PATH https://stedolan.github.io/jq/ .
# Add this function to your .bashrc or save it to a file and source that file from .bashrc .
# https://gist.github.com/ddgenome/f13f15dd01fb88538dd6fac8c7e73f8c
#
# usage: aws-creds MFA_TOKEN [OTHER_AWS_STS_GET-SESSION-TOKEN_OPTIONS...]
function aws-creds () {
local pkg=aws-creds
from marshmallow_jsonapi import fields, Schema
import json
class ProductSchema(Schema):
class Meta:
type_ = "products"
id = fields.String()
processes = fields.Relationship(
@multimeric
multimeric / pollunit.js
Last active October 10, 2019 03:07
PollUnit Scraping
/**
* Scrapes the names and summary results of a PollUnit poll, without paying for the business subscription
* How to use:
* 1. Copy the entire contents of this file
* 2. Browse to the public or admin link for your poll
* 3. Open the developer tools using F12 (on Chrome)
* 4. Paste this script into the input box and press enter
* 5. Copy the text that is output
* 6. Paste it into Excel or whatever application you are using this for. If Excel asks for a delimiter, specify the tab character
**/
# Scrapes price data from http://www.mtggtm.com.au, a Magic the Gathering shop website
# Paste this into the console on a product list page, e.g. http://www.mtggtm.com.au/product-list/466?page=1
$$('.item_data').forEach(el => {
const name = el.querySelector('.item_name');
const price = el.querySelector('.price');
console.log(name.innerText + '\t' + price.innerText);
});
import { Serializer, Deserializer } from 'jsonapi-serializer';
return new Deserializer(relationshipProxy).deserialize(response.data);