Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Katsen pkpp1233

View GitHub Profile
@pkpp1233
pkpp1233 / gist:606818de22072f9929c2
Created Feb 12, 2015
Verbose curl command to Blockspring test function.
View gist:606818de22072f9929c2
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 Dec 11, 2014
Blockspring wordcloud.
View block.js
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,
View cloud.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 Jan 20, 2019
node wordcloud
View wordcloud.js
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
View index.html
<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
View cloud.js
// 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 Aug 29, 2015
fuzzy matcher block
View block.py
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)
View block.py
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')]
View index.html
<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>