Skip to content

Instantly share code, notes, and snippets.

View pkpp1233's full-sized avatar

Paul Katsen pkpp1233

View GitHub Profile
console.log('hi');
@pkpp1233
pkpp1233 / gist:606818de22072f9929c2
Created February 12, 2015 20:37
Verbose curl command to Blockspring test function.
curl -v -H "Content-Type: application/json" -d "{ \"first_name\": \"Paul\", \"age\": 26 }" "https://sender.blockspring.com/api_v2/blocks/455dfb41d40d13281ef87e613a669827?api_key=YOUR_API”_KEY
@pkpp1233
pkpp1233 / block.js
Created December 11, 2014 21:02
Blockspring wordcloud.
var blockspring = require('blockspring');
var d3 = global.d3 = require('d3');
var fs = require('fs');
var cloud = require('d3.layout.cloud');
blockspring.define(function(request, response){
var text = request.params.text,
width = request.params.width,
height = request.params.height,
rotate_words = request.params.rotate_flag,
@pkpp1233
pkpp1233 / cloud.svg
Created December 11, 2014 02:48
svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pkpp1233
pkpp1233 / wordcloud.js
Last active January 20, 2019 20:39
node wordcloud
var d3 = global.d3 = require('d3');
var cloud = require('d3.layout.cloud');
// Declare inputs and initiate wordcloud draw.
(function(){
var text = "SCENE II. Paris. The KING's palace.\n\nFlourish of cornets. Enter the KING of France, with letters, and divers Attendants\nKING\nThe Florentines and Senoys are by the ears;\nHave fought with equal fortune and continue\nA braving war.\nFirst Lord\nSo 'tis reported, sir.\nKING\nNay, 'tis most credible; we here received it\nA certainty, vouch'd from our cousin Austria,\nWith caution that the Florentine will move us\nFor speedy aid; wherein our dearest friend\nPrejudicates the business and would seem\nTo have us make denial.\nFirst Lord\nHis love and wisdom,\nApproved so to your majesty, may plead\nFor amplest credence.\nKING\nHe hath arm'd our answer,\nAnd Florence is denied before he comes:\nYet, for our gentlemen that mean to see\nThe Tuscan service, freely have they leave\nTo stand on either part.\nSecond Lord\nIt well may serve\nA nursery to our gentry, wh
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="cloud.js"></script>
</head>
<body>
<script>
// Declare inputs and initiate wordcloud draw.
(function(){
var text = "SCENE II. Paris. The KING's palace.\n\nFlourish of cornets. Enter the KING of France, with letters, and divers Attendants\nKING\nThe Florentines and Senoys are by the ears;\nHave fought with equal fortune and continue\nA braving war.\nFirst Lord\nSo 'tis reported, sir.\nKING\nNay, 'tis most credible; we here received it\nA certainty, vouch'd from our cousin Austria,\nWith caution that the Florentine will move us\nFor speedy aid; wherein our dearest friend\nPrejudicates the business and would seem\nTo have us make denial.\nFirst Lord\nHis love and wisdom,\nApproved so to your majesty, may plead\nFor amplest credence.\nKING\nHe hath arm'd our answer,\nAnd Florence is denied before he comes:\nYet, for our gentlemen that mean to see\nThe Tuscan service, freely have th
@pkpp1233
pkpp1233 / cloud.js
Created December 11, 2014 01:01
wordcloud
// Word cloud layout by Jason Davies, http://www.jasondavies.com/word-cloud/
// Algorithm due to Jonathan Feinberg, http://static.mrfeinberg.com/bv_ch03.pdf
(function() {
function cloud() {
var size = [256, 256],
text = cloudText,
font = cloudFont,
fontSize = cloudFontSize,
fontStyle = cloudFontNormal,
fontWeight = cloudFontNormal,
@pkpp1233
pkpp1233 / block.py
Last active August 29, 2015 14:10
fuzzy matcher block
import blockspring
from fuzzywuzzy import fuzz
from fuzzywuzzy import process
import os
import pandas as pd
import numpy as np
def block(request, response):
primary_ids = [str(row[0]) for row in request.params["proper_ids"]]
header_primary_ids = primary_ids.pop(0)
@pkpp1233
pkpp1233 / block.py
Created December 4, 2014 20:36
scraper block
import blockspring
import urllib
from bs4 import BeautifulSoup
def block(request, response):
sport = request.params["sport"]
html = urllib.urlopen("http://www.espn.com/" + sport).read()
headlines = [headline.get_text() for headline in BeautifulSoup(html).find(class_="headlines").find_all('li')]
@pkpp1233
pkpp1233 / index.html
Created December 4, 2014 20:24
Scraper UI
<html>
<body>
<form accept-charset="UTF-8" action="/scrape" method="post">
<input autofocus="autofocus" placeholder="nba" type="text" name="sport">
<input type="submit" value="Get my headlines!">
<br>
</form>
</body>
</html>