Skip to content

Instantly share code, notes, and snippets.

View jonira's full-sized avatar

Joni R jonira

  • Helsinki, Finland
View GitHub Profile
@tbranyen
tbranyen / backbone_pushstate_router.js
Last active February 25, 2024 21:38
hijack links for pushState in Backbone
// 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.
@jakevdp
jakevdp / discrete_cmap.py
Last active March 8, 2024 14:54
Small utility to create a discrete matplotlib colormap
# 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"""
@kellyegan
kellyegan / ViewController.swift
Last active April 2, 2023 00:57
Send emails with attachments in iOS using Swift
//
// ViewController.swift
// SendEmailWithAttachment
//
// Created by Kelly Egan on 3/17/15.
// Copyright (c) 2015 Kelly Egan. All rights reserved.
//
import UIKit
import MessageUI