Skip to content

Instantly share code, notes, and snippets.

Avatar

Joni R jonira

  • Helsinki, Finland
View GitHub Profile
@kellyegan
kellyegan / ViewController.swift
Last active Apr 29, 2019
Send emails with attachments in iOS using Swift
View ViewController.swift
//
// ViewController.swift
// SendEmailWithAttachment
//
// Created by Kelly Egan on 3/17/15.
// Copyright (c) 2015 Kelly Egan. All rights reserved.
//
import UIKit
import MessageUI
@jakevdp
jakevdp / discrete_cmap.py
Last active Dec 18, 2020
Small utility to create a discrete matplotlib colormap
View discrete_cmap.py
# By Jake VanderPlas
# License: BSD-style
import matplotlib.pyplot as plt
import numpy as np
def discrete_cmap(N, base_cmap=None):
"""Create an N-bin discrete colormap from the specified input map"""
@tbranyen
tbranyen / backbone_pushstate_router.js
Last active Jan 6, 2020
hijack links for pushState in Backbone
View backbone_pushstate_router.js
// All navigation that is relative should be passed through the navigate
// method, to be processed by the router. If the link has a `data-bypass`
// attribute, bypass the delegation completely.
$(document).on("click", "a[href]:not([data-bypass])", function(evt) {
// Get the absolute anchor href.
var href = { prop: $(this).prop("href"), attr: $(this).attr("href") };
// Get the absolute root.
var root = location.protocol + "//" + location.host + Application.root;
// Ensure the root is part of the anchor href, meaning it's relative.