This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Serializer, Deserializer } from 'jsonapi-serializer'; | |
return new Deserializer(relationshipProxy).deserialize(response.data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 | |
**/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from marshmallow_jsonapi import fields, Schema | |
import json | |
class ProductSchema(Schema): | |
class Meta: | |
type_ = "products" | |
id = fields.String() | |
processes = fields.Relationship( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ResourceHyperlink(ma.Field): | |
""" | |
Serializes as a hyperlink to a flask_restful Resource | |
""" | |
def __init__(self, endpoint, url_args=None, *args, **kwargs): | |
super().__init__(*args, **kwargs) | |
# If the user passes in a list of args, we assume a field with the exact same name appears on the relation | |
if isinstance(url_args, list): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replace the job-* file with the right job ID | |
sudo -E PYTHONPATH=$PYTHONPATH bash job-F2kfkk804G2KyYvvF3fKffy2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
let str = '' | |
let tables = Array.from($('.sellerWrapMarket')) | |
for (let table of tables){ | |
let $table = $(table) | |
let rows = Array.from($table.find('table.sellerTable')) | |
for (let row of rows){ | |
let $row = $(row) | |
// Card name | |
str += $row.find('.itemsContents h3').text() + '\t' |