Skip to content

Instantly share code, notes, and snippets.

View lukeorland's full-sized avatar

Luke Orland lukeorland

View GitHub Profile
import time
from nose2.tools import such
def slow_blocking_init():
time.sleep(1)
print("a second elapsed")
time.sleep(1)
print("a second elapsed")
return True
# std
import io
import time
# vendor
import serial
ser = serial.Serial('/dev/tty.usbserial-A6008sxN', 115200, timeout=1)
time.sleep(2)
@lukeorland
lukeorland / nltk_english_sentence_splitter.py
Last active December 19, 2015 01:29
This script reads in lines of UTF-8 text from stdin, applies the NLTK English sentence tokenizer to the text, and prints out the split lines to stdout, preserving runs of two or more newline characters. N.B. An assumption being made is that the NLTK English Punkt model is already installed in an appropriate location in the environment.
#!/usr/bin/env python
"""
This script reads in lines of UTF-8 text from stdin,
applies the NLTK English sentence tokenizer to the text, and
prints out the split lines to stdout (in UTF-8), preserving runs of two or more
newline characters.
N.B. An assumption being made is that the NLTK English Punkt model is already
installed in an appropriate location in the environment.
"""
$ python manage.py shell
/Users/orluke/src/neo4django-tutorial/venv/src/neo4django/neo4django/db/models/relationships.py:170: UserWarning: `lazycat_set` and `lazycat_set` share a relationship type and direction. Is this what you meant to do?
% (r.name, name))
Python 2.7.3 (default, Feb 6 2013, 23:59:57)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.24)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from polls.models import Poll, Choice
/Users/orluke/src/neo4django-tutorial/venv/src/neo4django/neo4django/db/models/relationships.py:170: UserWarning: `choices` and `choices` share a relationship type and direction. Is this what you meant to do?
% (r.name, name))
function split_novowel {
echo $1 | cut -d_ -f$2 | sed 's/[aeiou]//g'
}
function abbr {
echo $(split_novowel $1 1 | cut -c 1-3)$(split_novowel $1 2 | cut -c 1-1)
}
abbr Computer_Hardware
@lukeorland
lukeorland / gigaword-separate-sentences.py
Created April 27, 2012 19:02
filter out SGML tags from gigaword files and print out headlines and text from story- and mult-type DOCs, one sentence per line
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Luke Orland
# [email protected]
# Fri Apr 27 14:51:01 EDT 2012
# EXAMPLE USAGE:
# $ zcat gigaword/data/*/*gz | python gigaword-separate-sentences.py > text
@lukeorland
lukeorland / combined_size.py
Created January 24, 2012 23:11
Prints the combined MB of the files passed as arguments
#!/usr/bin/env python
from __future__ import print_function
import argparse
import os
def file_size(file_name):
"""Returns size of the file named file_name in bytes."""
if not os.path.exists(file_name):
msg = "The file {} does not exist.".format(file_name)
@lukeorland
lukeorland / mediasite_slides_movie.py
Last active September 29, 2015 13:38
Mediasite content version to standalone videos
#!/usr/bin/env python
# Convert Mediasite content for a lecture into two DV-formatted videos:
# one from the lecture
# one of the slideshow with timings extracted from the Mediasite content.
#
# Usage: run this Python script from the root directory of the Mediasite
# content.
# It's the directory that contains the directories and files as follows:
# App_Themes/ Content/ Player.html PlayerOptions/ Players/
@lukeorland
lukeorland / handbrake_cli_dvd2m4v.sh
Created November 16, 2011 22:46
bash script for using HandBrakeCLI to rip a DVD on a Mac and compress it to H.264 m4v. requires a specific version of the HandBrakeCLI dmg in a specific location.
#!/usr/bin/env bash
set -x
HANDBRAKECLI_DMG="/Volumes/CLSP-500GB/handbrakeCLI/HandBrake-0.9.5-MacOSX.5_CLI_x86_64.dmg"
HANDBRAKECLI="/Volumes/HandBrake-0.9.5-MacOSX.5_CLI_x86_64/HandBrakeCLI"
open $HANDBRAKECLI_DMG
sleep 4s
DVD="$1"
DEST="$2"
@lukeorland
lukeorland / gist:1273312
Created October 9, 2011 04:46
vim-pandoc git commit error
$ git commit
Error detected while processing /Users/orluke/src/newnew_dotvim/.vim/bundle/vim-pandoc/plugin/pandoc.vim:
line 1:
E319: Sorry, the command is not available in this version: python<<EOF
line 2:
E488: Trailing characters: # We register openers with PandocRegisterExecutor.
line 3:
E488: Trailing characters: # We take its first argument as the name of a vim ex command, the second
line 4:
E488: Trailing characters: # argument as a mapping, and the rest as the description of a command,