Skip to content

Instantly share code, notes, and snippets.

View robertbrook's full-sized avatar

Robert Brook robertbrook

View GitHub Profile
@robertbrook
robertbrook / searchlink.rb
Created October 16, 2012 19:56 — forked from ttscoff/searchlink.rb
SearchLink creates Markdown links from automatic searches based on special syntax.
# Copyright 2013, Small Picture, Inc.
op =
expand: ->
$(getActiveOutliner()).concord().op.expand()
expandAllLevels: ->
$(getActiveOutliner()).concord().op.expandAllLevels()
expandEverything: ->
$(getActiveOutliner()).concord().op.fullExpand()
require 'rake/clean'
require 'redcarpet'
require 'erb'
CLEAN.include '*.html'
# https://sites.google.com/site/spontaneousderivation/rake-quick-reference#TOC-Defining-Tasks
# https://github.com/sivers/sivers.org/blob/master/Rakefile
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true)
local template =
[[
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>feeds</title>
<meta content='width=device-width, initial-scale=1.0' name='viewport'>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
var request = require('request');
var cheerio = require("cheerio");
// http://matthewmueller.github.io/cheerio/
request('http://data.parliament.uk/writtenevidence/WrittenEvidence.svc/EvidenceHtml/5533', function (error, response, body) {
if (!error && response.statusCode == 200) {
var $ = cheerio.load(body);
var myString = "";
var myState = "default";
@robertbrook
robertbrook / getter.coffee.md
Last active August 29, 2015 13:55
getter.coffee.md

Getter is a utility to fetch evidence to Parliamentary committees from data.parliament.uk and make their content available for onward use.

request = require("request")

Cheerio is a helper from Matthew Mueller: http://matthewmueller.github.io/cheerio/

cheerio = require("cheerio")

request "http://data.parliament.uk/writtenevidence/WrittenEvidence.svc/EvidenceHtml/5533", (error, response, body) ->

if not error and response.statusCode is 200

@robertbrook
robertbrook / 0_reuse_code.js
Created February 6, 2014 11:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
Terrain = (detail) ->
@size = Math.pow(2, detail) + 1
@max = @size - 1
@map = new Float32Array(@size * @size)
return
Terrain::get = (x, y) ->
return -1 if x < 0 or x > @max or y < 0 or y > @max
@map[x + @size * y]
Terrain::set = (x, y, val) ->
targeturl = "https://openlibrary.org/api/books?bibkeys=ISBN:" + book.isbn.tr(' ','') + "&format=json"
open(targeturl) { |io|
jsonstring = io.read
puts JSON.parse(jsonstring).inspect
parsed = JSON.parse(jsonstring)
parsedvalues = parsed.values[0]
if parsedvalues
html << "<img src='#{parsedvalues['thumbnail_url'].tr('S','M')}' style='float:right;'>"
end
set runtimepath^=~/Dropbox/vim
source ~/Dropbox/vim/vimrc.vim