This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
text = """ | |
The Eagle has landed. The regret on our side is, they used to say years ago, we are reading about you in science class. Now they say, we are reading about you in history class. | |
Never in all their history have men been able truly to conceive of the world as one: a single sphere, a globe, having the qualities of a globe, a round earth in which all the directions eventually meet, in which there is no center because every point, or none, is center, an equal earth which all men occupy as equals. The airman's earth, if free men make it, will be truly round: a globe in practice, not in theory. | |
For those who have seen the Earth from space, and for the hundreds and perhaps thousands more who will, the experience most certainly changes your perspective. The things that we share in our world are far more valuable than those which divide us. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from unittest.mock import patch | |
class Patcher(): | |
""" | |
This class provides a central place for managing | |
commonly used patches for tests. | |
Example:: | |
p = Patcher([ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Required for vim's copy and paste to work in tmux. | |
# Install this first: | |
# brew install reattach-to-user-namespace --wrap-pbcopy-pbpaste && brew link reattach-to-user-namespace | |
set-option -g default-command "reattach-to-user-namespace -l bash" | |
# Set Ctrl-a as prefix | |
# (instead of Ctrl-b) | |
unbind C-b | |
set -g prefix C-a | |
bind C-a send-prefix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adapted from | |
# http://pytables.github.io/usersguide/libref/homogenous_storage.html#the-carray-class | |
import os | |
import numpy | |
import tables | |
from itertools import groupby | |
from operator import itemgetter | |
from time import time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import operator | |
from itertools import combinations | |
from functools import reduce | |
import numpy as np | |
def hac(vecs, sim_func, threshold): | |
""" | |
Hierarchical Agglomerative Clustering. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import networkx as nx | |
class Person(): | |
def __init__(self, name, stance=None): | |
self.name = name | |
if stance is None: | |
self.stance = random.randrange(0, 2) | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import logging | |
import numpy | |
import gensim | |
logging.basicConfig(level=logging.INFO) | |
train_sentences = gensim.models.doc2vec.LabeledLineSentence(sys.argv[1]) | |
model = gensim.models.Doc2Vec(train_sentences, size=400, window=8, min_count=2, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var NodeChatController = { | |
init: function() { | |
this.socket = io.connect('http://localhost'); | |
var mysocket = this.socket; | |
this.model = new models.NodeChatModel(); | |
this.view = new NodeChatView({model: this.model, socket: this.socket, el: $('#content')}); | |
var view = this.view; | |
this.socket.on('message', function(msg) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'yaml'# Load auth config | |
AUTH_CONFIG = YAML.load_file("#{::Rails.root}/config/auth.yml")[::Rails.env] | |
Rails.application.config.middleware.use OmniAuth::Builder do | |
provider :google_oauth2, AUTH_CONFIG["client_id"], AUTH_CONFIG["client_secret"], { | |
scope: 'https://www.googleapis.com/auth/userinfo.email https://www.google.com/reader/api/' | |
} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
development: | |
client_id: [your client id] | |
client_secret: [your client secret] | |
test: | |
client_id: [your client id] | |
client_secret: [your client secret] | |
production: |
OlderNewer