Skip to content

Instantly share code, notes, and snippets.

@skagedal
skagedal / UIViewController+Deselection.swift
Last active June 9, 2016 12:26 — forked from ZevEisenberg/LICENSE
Smoothly deselect table and collection view cells on dismissal, including interactive dismiss and interactively-partially-dismiss-then-cancel-then-dismiss-again
extension UIViewController {
func rz_smoothlyDeselectRows(tableView tableView: UITableView?) {
let selectedIndexPaths = tableView?.indexPathsForSelectedRows ?? []
if let coordinator = transitionCoordinator() {
coordinator.animateAlongsideTransitionInView(parentViewController?.view, animation: { context in
selectedIndexPaths.forEach {
tableView?.deselectRowAtIndexPath($0, animated: context.isAnimated())
}
from urllib.request import urlopen
counter = 1
while True:
url = 'http://libris.kb.se/xsearch?d=swepub&hitlist&q=l%C3%A4ros%C3%A4te%3agu&f=ext&spell=true&hist=true&n=200&format=json&start=' + str(counter)
print ("Fetching: " + url)
data = urlopen(url).read()
if not data.find(b'"identifier"') >= 0:
print("No more records!")
import json
import re
from os import listdir
def fix_escapes(string):
# Libris over-escapes some backslashes.
string = string.replace("\\\\\"","\\\"")
# Libris fails to properly escape backslashes in strings, which occurs for example with inline
# LaTeX codes like "$\geq" which should be escaped as "$\\geq". They do seem to properly
# escape quote chars, however. Now, we can't easily know whethera string liike "\n" should be