Skip to content

Instantly share code, notes, and snippets.

@appendjeff
appendjeff / MatchTagAlways Issue #25
Created November 13, 2015 21:30
The plugin does not pick up the outermost div tag
<div id="marquee_text" class="col-xs-8 col-xs-offset-4 col-sm-6 col-sm-offset-4 col-md-5 col-md-offset-2">
<h1>Introducing</br>HBO NOW<sup>SM</sup><span id="nowMDash">&#8212;</span><br />all you need</br>is the Internet.</h1>
<h5>Stream the standalone service, <br />free* for 30 days.</h5>
<button type="button" class="btn btn-default">Start your trial
<span><span class="arrow-btn"></span></span>
</button>
</div>
@appendjeff
appendjeff / twisted_django.py
Last active February 20, 2016 17:43
Twisted implementation to run Django asynchronously on the network layer
import sys, os
from twisted.application import internet, service
from twisted.web import server, resource, wsgi, static
from twisted.python import threadpool
from twisted.internet import reactor, protocol
from twisted.internet import defer
from twisted.web.resource import Resource
class TwistedDjangoException(Exception):
"""@datascientist: mnest"""
import os
import time
import logging
import numpy as np
import pandas as pd
from sklearn.ensemble import RandomForestClassifier
from sklearn.externals import joblib
<html>
<head>
<link rel="stylesheet" href="https://storage.googleapis.com/code.getmdl.io/1.0.2/material.blue_grey-red.min.css" />
<script src="https://storage.googleapis.com/code.getmdl.io/1.0.0/material.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<style>
body {
display: flex;
}
import string
def scrabble_dist(a,b,tol):
lettersandnumbers = string.ascii_uppercase + " " + ''.join(map(str, range(10)))
letterValues = dict(zip(lettersandnumbers, [1,3,3,2,1,4,2,4,1,8,5,1,3,1,1,3,10,1,1,1,1,4,4,8,4,10,1,1,1,1,1,1,1,1,1,1,1]))
a_set = set(a.upper())
b_set = set(b.upper())
diff_set = a_set.union(b_set) - a_set.intersection(b_set)
def get_sum(letters):
"""
Return the sum of each value in a string of letters.
from datetime import datetime
import time
import logging
import requests
logger = logging.getLogger(__name__)
class Etsy(object):
"""Python Etsy API wrapper mainly used for analytics"""
@appendjeff
appendjeff / models.py
Created September 22, 2016 15:27
Database schema for scarletlabs etsy tables
from django.db import models
class Listing(models.Model):
listing_id = models.CharField(max_length=20)
user_id = models.CharField(max_length=20)
shop_section_id = models.CharField(max_length=20, null=True)
price = models.IntegerField(null=True)
quantity = models.IntegerField()
@appendjeff
appendjeff / LittleRegex.java
Last active December 1, 2016 03:06
exploring java and all of the regex it has to offer
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class LittleRegex {
public static void printMatches(String text, String regex) {
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(text);
// Check all occurrences
while (matcher.find()) {
@appendjeff
appendjeff / analyze_google_search_history.py
Last active December 2, 2016 23:34
Performs analytics on personal google search history.
"""Performs analytics on personal google search history.
Installation:
1) Get your search history: https://takeout.google.com/settings/takeout
2) Put this file in the Searches directory
3) python analyze_google_search_history.py
"""
import glob
import os
import json
@appendjeff
appendjeff / match_date.py
Created December 12, 2016 03:37
Comparing java to python for education!
import re
class MatchDate(object):
"""A date object matched from a syllabus."""
day = 0
month = 0
year = 0
value_words = ["exam","project","assignment","homework","presentation"]