Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#netaporter_bookmarklet_table{
border: 3px solid #333;
position: fixed;
_position:absolute;
top: 0;
right: 0;
width: 570px;
height: 80px;
z-index: 10000000;
margin: 0;
  • Update HISTORY.rst
  • Update version number in my_project/__init__.py
  • Update version number in setup.py
  • Install the package again for local development, but with the new version number:
python setup.py develop
  • Run the tests:
python setup.py test
@tpeng
tpeng / crf.py
Last active August 29, 2015 14:10 — forked from neubig/crf.py
#!/usr/bin/python
# crf.py (by Graham Neubig)
# This script trains conditional random fields (CRFs)
# stdin: A corpus of WORD_POS WORD_POS WORD_POS sentences
# stdout: Feature vectors for emission and transition properties
from collections import defaultdict
from math import log, exp
import sys
diff --git a/webstruct/model.py b/webstruct/model.py
index f77ab36..941cd8f 100644
--- a/webstruct/model.py
+++ b/webstruct/model.py
@@ -111,6 +111,13 @@ class NER(object):
Return annotated HTML data in WebAnnotator format.
"""
html_tokens, tags = self.extract_raw(bytes_data)
+ return self.annotate_tokens(html_tokens, tags)
+

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
@tpeng
tpeng / crfsuite.build.patch
Last active August 9, 2017 09:51
Build crfsuite on macos
diff --git a/configure.in b/configure.in
index dafbcf6..743037c 100644
--- a/configure.in
+++ b/configure.in
@@ -30,7 +30,7 @@ dnl ------------------------------------------------------------------
AM_INIT_AUTOMAKE(crfsuite, 0.12)
AC_CONFIG_HEADERS(config.h)
AM_MAINTAINER_MODE
-AM_C_PROTOTYPES
+
@tpeng
tpeng / makefile
Created February 15, 2014 15:18
patch to allow rnnlm build on macos
#CC = x86_64-linux-g++-4.6
CC = llvm-gcc
WEIGHTTYPE = float
CFLAGS = -D WEIGHTTYPE=$(WEIGHTTYPE) -lm -O2 -Wall -funroll-loops -ffast-math -lstdc++
#CFLAGS = -D WEIGHTTYPE=$(WEIGHTTYPE) -lm -O2 -Wall -funroll-loops -ffast-math
#CFLAGS = -lm -O2 -Wall
all: rnnlmlib.o rnnlm
rnnlmlib.o : rnnlmlib.cpp
import re
_SPACING_RE = re.compile(ur'\n[\s]+', re.DOTALL)
text = "\r\n Grand Hotel, Malahide, County Dublin, Ireland\r\n Tel. +353 1 845 0000 Fax +353 1 816 8225\r\n Email: [email protected]"
print _SPACING_RE.sub(u'', text)
print _SPACING_RE.sub(u'\n', text)
# output on my machine:
#Email: [email protected] +353 1 816 8225eland
@tpeng
tpeng / gist:5235674
Created March 25, 2013 08:29
MDS example
# MDS example from http://www.analytictech.com/networks/mds.htm
import numpy as np
from sklearn import manifold
import matplotlib.pyplot as plt
cities = ["BOST", "NY", "DC", "MIAM", "CHIC", "SEAT", "SF", "LA", "DENV"]
dis = np.array([[0, 206, 429, 1504, 963, 2976, 3095, 2979, 1949],
[206, 0, 233, 1308, 802, 2815, 2934, 2786, 1771],
[429, 233, 0, 1075, 671, 2684, 2799, 2631, 1616],
[1504, 1308, 1075, 0, 1329, 3273, 3053, 2687, 2037],