This file contains 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
{ | |
"metadata": { | |
"name": "mmap with native type" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |
This file contains 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
# coding: utf-8 | |
from __future__ import print_function | |
import sys | |
import xml.etree.ElementTree as ET | |
import urllib.request | |
import html | |
def remove_node(root, node): | |
title = html.escape(node.attrib['title']) | |
for parent in root.findall('.//outline[@title="{}"]/..'.format(title)): |
This file contains 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 enum import Enum | |
class Signal(Enum): | |
red = 1 | |
yellow = 2 | |
green = 3 | |
def switch(e, **cases): | |
cls = e.__class__ |
This file contains 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 sys import argv, stdin, stdout | |
from csv import reader, writer | |
enc = argv[2] if len(argv) > 2 else "UTF-8" | |
inputf = open(argv[1], encoding=enc) if len(argv) > 1 else stdin | |
writer(stdout, lineterminator='\n', delimiter='\t').writerows(reader((x.strip('\r\n') for x in inputf))) |
This file contains 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 itertools | |
for i, f in zip(itertools.count(1), open('lex.csv', 'rb')): | |
for j, g in zip(itertools.count(0), f): | |
if g >= 0b11110000: | |
print(i, f[j:j+4], f[j:j+4].decode('utf-8')) |
This file contains 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 java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class CSVParser { | |
private static final Pattern p = Pattern.compile(",|[^,\"]+|\"(?:[^\"]|\"\")*\""); | |
public static List<String> parse(final String line, final int max) { | |
if (max == 0) { |
This file contains 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 sys | |
try: | |
from PySide import QtCore | |
from PySide import QtGui | |
from PySide import QtWebKit | |
except: | |
from PyQt4 import QtCore | |
from PyQt4 import QtGui | |
from PyQt4 import QtWebKit |
This file contains 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
<select class="ng-pristine ng-valid" ng-options="e.name for e in entries" ng-model="entry"> | |
<option value="0" selected="selected"> | |
default | |
</option> | |
</select> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 zipfile | |
import sys | |
from pathlib import Path | |
def unzip(f, encoding, v): | |
with zipfile.ZipFile(f) as z: | |
for i in z.namelist(): | |
n = Path(i.encode('cp437').decode(encoding)) | |
if v: |