Skip to content

Instantly share code, notes, and snippets.

mostly harmless

Rachel Greenfield catermelon

mostly harmless
View GitHub Profile
Allows scoring of text using n-gram probabilities
from math import log10
# make a class called ngram_score
# which is wrong, Python classes are always CamelCased so it should be NGramScore but whatever
class ngram_score(object):
Allows scoring of text using n-gram probabilities
from math import log10
class ngram_score(object):
def __init__(self,ngramfile,sep=' '):
''' load a file containing ngrams and counts, calculate log probabilities '''
self.ngrams = {}
catermelon /
Created Jan 20, 2015
PyExchange Stackoverflow answer
from pyexchange import Exchange2010Service, ExchangeNTLMAuthConnection
from datetime import datetime
import time
from pytz import timezone, utc
def getEvents():
URL = u'https://blah.blah/EWS/exchange.asmx'
PASSWORD = u"password"
catermelon /
Last active Jan 28, 2016
Script to easily test XML requests against an exchange server
#!/usr/bin/env python
import os
import logging
import requests
from requests_ntlm import HttpNtlmAuth
import getpass
import xml.dom.minidom
View gist:f3b1d2e9e4d094d118fa


So the SF pasttime isn't baseball or anything like that, it's laughing at tourists who wear shorts. All the visions of warm, beachy California are lies spread by the Los Angeles tv industry. SF can be cold and windy even in summer (actually especially in summer, the land warms up and causes the fog to roll in) and the fog is beautiful but it's FRICKIN COLD. I always bring a jacket to SF no matter what time of year it is. It can be 30 deg C maybe 20 miles away and 10 degrees C in SF. No joke.


SF has awesome food, with a lot of Asian and Mexican influence. Here's a great list from all price ranges:

Pay particular attention to Mexican/Central and South American food, since I know the UK has great Asian food but not Mexican. The burrito is a Californian staple. Try the al pastor and the carnitas.

catermelon / example_response.xml
Created Aug 22, 2014
Search for calendar events in exchange
View example_response.xml
<s:Envelope xmlns:s="">
<h:ServerVersionInfo xmlns:h="" xmlns="" xmlns:xsi="" xmlns:xsd="" MajorVersion="14" MinorVersion="3" MajorBuildNumber="195" MinorBuildNumber="1"/>
<s:Body xmlns:xsi="" xmlns:xsd="">
<m:FindItemResponse xmlns:m="" xmlns:t="">
<m:FindItemResponseMessage ResponseClass="Success">
<m:RootFolder TotalItemsInView="20" IncludesLastItemInRange="true">
from flask import current_app
class FeatureFlags(object):
def __init__(self, app=None):
if app is not None:
def init_app(self, app):
catermelon / gist:7494177
Created Nov 16, 2013
You have a string with many consecutive letters: "aabbaadddc". Write a function that compresses the string by counting the consecutive letters. (If there is only one letter, it should resolve to itself). "aaaaabbaadddc" -> "a5b2a2d3c"
View gist:7494177
#"aabbbcccdde" => "a2b3c3d2e1"
def encode_string(unencoded):
if unencoded is None or unencoded == "":
return None
last_letter = None
count = 0
class Rachel_ChanceItIfUsing(object):
def __init__(self, name): = name
self.minShotguns = 2
def turn(self, gameState):
green_dice_left = 6
red_dice_left = 3
# Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz"
# instead of the number and for the multiples of five print "Buzz". For numbers which are
# multiples of both three and five print "FizzBuzz".
# This is a moldly oldie in the programmer community, it's known as "FizzBuzz" (for obvious
# reasons). Here's a blog post:
# This solution runs through every number between 1 and 100, checks if they are evenly