text = open('a_unicode_file.txt', 'r').read()
print text
print 'type:', type(text) # str is a container for binary data
print 'bytes:', len(text) # The number of bytes, not characters!
print ' '.join(repr(b) for b in text)
print 'first byte:', text[:1] # Prints an invalid character!
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
#!/usr/bin/env python | |
# | |
# Copyright 2009 Facebook | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); you may | |
# not use this file except in compliance with the License. You may obtain | |
# a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.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
def first_match(seq, pred=None, default=None): | |
""" | |
Obtain the first item in `seq` where `pred` returns True, otherwise return | |
`default`. | |
If no `pred` is supplied, then the first value in seq will be returned. If | |
no `default` is supplied and no matching value is found in `seq`, then | |
`None` will be returned instead. | |
:param seq: A sequence or iterable to obtain an item from. |
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
in a file called ~/.reverseit.py: | |
#!/usr/bin/python | |
# -*- coding: UTF-8 -*- | |
from sys import stdin, stdout | |
pchars = u"abcdefghijklmnopqrstuvwxyz,.?!'()[]{}" | |
fchars = u"ɐqɔpǝɟƃɥıɾʞlɯuodbɹsʇnʌʍxʎz'˙¿¡,)(][}{" | |
flipper = dict(zip(pchars, fchars)) |
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
#!/bin/bash | |
# Jasper install script (http://jasperproject.github.io/) | |
# Must be run as root (i.e. sudo setup.sh) | |
apt-get update | |
apt-get upgrade --yes | |
apt-get install vim git-core espeak python-dev python-pip bison libasound2-dev libportaudio-dev python-pyaudio subversion autoconf libtool automake gfortran --yes | |
sed "s/options snd-usb-audio index=-2/options snd-usb-audio index=0" /etc/modprobe.d/alsa-base.conf>/etc/modprobe.d/alsa-base.conf |
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
void backlight_effect_solid_reactive(void) | |
{ | |
// Relies on hue being 8-bit and wrapping | |
for ( int i=0; i<DRIVER_LED_TOTAL; i++ ) | |
{ | |
uint16_t offset2 = g_key_hit[i]<<2; | |
// stabilizer LEDs use spacebar hits | |
if ( i == 42 || // LC6, LD13 |