Skip to content

Instantly share code, notes, and snippets.

View catermelon's full-sized avatar
🚩
oh no

Rachelle Green catermelon

🚩
oh no
View GitHub Profile
@catermelon
catermelon / me.pub
Created February 12, 2022 06:01
gpg public key
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBGIHRHkBEADocq8TrwFZB4JjEgjzCCm7qakBf7VcNjl3ZaXTWC7o/mnpf3Ts
MasFXmi01c/F3jiowJstsrbLdCuYTr9vNegURF/BvGSIMpcwz3bNW9hz/HCrhqzw
jVo9JfER/mg+yJGIvFj3eqwNDg0pHI3iWXEgdbCBrQKgJTNjhQRfuqJCuPCAie4A
vX0G57qoQMu82q7K5D9uNRSd5+9PGWsypNTQVU/45gQa6WEXLWOYaw5ZChmhGQcV
AwnYWTxv3TK0WPbQRtpxcR1HqRtjugAV61YvIaaeWxqsXNnYkyYzC1WiLuhRqpLV
+oFbQyubwKT1D3PF9UkKKZLUgvI9MsQdGA5BUQNaxn0UkZc4t43FV2hJTG1t52iu
4mqPMAYsHpIug1BWFXqvkyTnOhfr6TUgle21/Qt7+KLdX+cR79ISn9WHBNf93+0H
vRb/Y1KH6dQP9ZwIWLF/N9gd9GD7r7zfcR4UsBnaSI2ZdoDqkyerWyascSaeOLVw

Keybase proof

I hereby claim:

  • I am catermelon on github.
  • I am ohnorainbow (https://keybase.io/ohnorainbow) on keybase.
  • I have a public key whose fingerprint is 852C 5FFC D2EE 9F6A D016 B0E5 BCA7 3947 7A89 393C

To claim this, I am signing this object:

'''
Allows scoring of text using n-gram probabilities
17/07/12
'''
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
17/07/12
'''
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
catermelon / sample.py
Created January 20, 2015 22:54
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'
USERNAME = u'DOMAIN\\user'
PASSWORD = u"password"
@catermelon
catermelon / exchange_test.py
Last active January 28, 2016 07:05
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
logging.basicConfig(level=logging.DEBUG)
@catermelon
catermelon / gist:f3b1d2e9e4d094d118fa
Last active August 29, 2015 14:12
Things to do in SF

Weather

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.

Food

SF has awesome food, with a lot of Asian and Mexican influence. Here's a great list from all price ranges: http://www.sfgate.com/food/top100/2014/

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
catermelon / example_response.xml
Created August 22, 2014 23:11
Search for calendar events in exchange
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" MajorVersion="14" MinorVersion="3" MajorBuildNumber="195" MinorBuildNumber="1"/>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<m:FindItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:FindItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:RootFolder TotalItemsInView="20" IncludesLastItemInRange="true">
from flask import current_app
class FeatureFlags(object):
def __init__(self, app=None):
if app is not None:
self.init_app(app)
def init_app(self, app):
@catermelon
catermelon / gist:7494177
Created November 16, 2013 00:31
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"
#"aabbbcccdde" => "a2b3c3d2e1"
def encode_string(unencoded):
if unencoded is None or unencoded == "":
return None
last_letter = None
count = 0