Skip to content

Instantly share code, notes, and snippets.

View futurulus's full-sized avatar

Will Monroe futurulus

  • Stanford University
  • Stanford, CA
View GitHub Profile
@futurulus
futurulus / fix-windows-filenames.sh
Last active July 28, 2016 06:11
Ever get impossible-to-delete files on Windows because they have * or ? in their names?
#!/usr/bin/env bash
# Rename files in a Windows folder that somehow ended up with illegal Windows filenames
# (because NTFS doesn't enforce this, but it makes the files unusable and indestructible).
# Must be run in Linux. There seems to be no other way.
ls -1 | awk '/[/\:*?"<>|]/ {
orig = $0;
gsub(/[/\:*?"<>|]/, "_", $0);
gsub(/'"'"'/, "'"'"'\"'"'"'\"'"'"'", orig);
gsub(/'"'"'/, "'"'"'\"'"'"'\"'"'"'", $0);
print "mv '"'"'" orig "'"'"' '"'"'" $0 "'"'"'"
from __future__ import print_function
import random
STRATEGY = {}
def expected_value(seen, choice):
'''
The expected amount you get swindled, given what you've seen so
far (`seen`, adjusted so that the lowest value is 0) and the
@futurulus
futurulus / setup.py
Created January 1, 2016 07:17
py2exe setup file for creating a Windows executable
'''Build an executable.'''
from distutils.core import setup
import os
import py2exe
setup(console=[
{'script': 'main.py'}
],
options={'py2exe': {
#!/usr/bin/env bash
# Reformat as [-]token[-]|||POS_TAGS
cat $1 | awk '
BEGIN {
FS = "·";
ORS = " ";
buckwalter = "java edu.stanford.nlp.international.arabic.Buckwalter";
}
/^t/ {