Skip to content

Instantly share code, notes, and snippets.

# Set up our path similar to dev_appserver.py
EXTRA_PATHS = [
DIR_PATH,
os.path.join(DIR_PATH, 'lib', 'antlr3'),
os.path.join(DIR_PATH, 'lib', 'django'),
os.path.join(DIR_PATH, 'lib', 'ipaddr'),
os.path.join(DIR_PATH, 'lib', 'webob'),
os.path.join(DIR_PATH, 'lib', 'yaml', 'lib'),
os.path.join(os.path.dirname(__file__)),
]
# Import AE's api stubs
from google.appengine.api import apiproxy_stub_map
from google.appengine.api import datastore_file_stub
from google.appengine.api import mail_stub
from google.appengine.api import urlfetch_stub
from google.appengine.api import user_service_stub
# Set up our dummy environment
APP_ID = 'test_app'
AUTH_DOMAIN = 'gmail.com'
# Watch the file given at the command line
if __name__ == '__main__':
old_mtime = 0
while True:
if len(sys.argv) == 1:
print 'Usage: python this_file.py your_module.py'
sys.exit()
else:
test = sys.argv[1].split('.')[0]
# Load here so we can use imp.reload later
- (void)fetchContours {
int currentPixel, currentDir;
RSPoint point, nextPoint, testPoint;
lastEntryPoint = RSPointMake(0,0);
lastPoint = RSPointMake(0,0);
lastFoundDir = 4;
marching = YES;
-- Make a pattern to match the consonants and vowels in a word where a cons is
-- not "aeiou" or y preceded by a cons e.g., "happy" -> ("happy", "cvccv")
wordDesc :: String -> (String, String)
wordDesc str =
(str, [corv (a,b,i) | (a,b,i) <- zip3 str (rotateR str) [0..len]])
where len = length str - 1
corv (a,b,i)
| a == 'y' && i /= 0 && b `notElem` vs = 'v'
| a `elem` vs = 'v'
| otherwise = 'c'
rotateR :: [a] -> [a]
rotateR [x] = [x]
rotateR xs = last xs : init xs
def cons(self, i):
"""cons(i) is TRUE <=> b[i] is a consonant."""
if self.b[i] == 'a' or self.b[i] == 'e' or self.b[i] == 'i' or self.b[i] == 'o' or self.b[i] == 'u':
return 0
if self.b[i] == 'y':
if i == self.k0:
return 1
else:
return (not self.cons(i - 1))
return 1
-- Make a pattern to match the consonants and vowels in a word where a cons is
-- not "aeiou" or y preceded by a cons e.g., "happy" -> ("happy", "cvccv")
wordDesc :: String -> (String, String)
wordDesc str = (str, [corv (a,b,i) | (a,b,i) <- zip3 str (rotateR str) [0..len]])
where len = length str - 1
corv (a,b,i)
| a == 'y' && i /= 0 && b `notElem` vs = 'v'
| a `elem` vs = 'v'
| otherwise = 'c'
where vs = "aeiou"
rotateR :: [a] -> [a]
rotateR [x] = [x]
rotateR xs = last xs : init xs
rotateR :: [a] -> [a]
rotateR [x] = [x]
rotateR xs = last xs : init xs
-- Make a pattern to match the consonants and vowels in a word where a cons is
-- not "aeiou" or y preceded by a cons e.g., "happy" -> ("happy", "cvccv")
wordDesc :: String -> (String, String)
wordDesc str =
(str, [corv (a,b,i) | (a,b,i) <- zip3 str (rotateR str) [0..len]])
where len = length str - 1