Skip to content

Instantly share code, notes, and snippets.

View samplereality's full-sized avatar

Mark Sample samplereality

View GitHub Profile
@samplereality
samplereality / longlive.js
Last active August 29, 2015 13:57
longlive.js
// This is a code comment.
// Any line preceded by two slashes
// will not be executed as code.
// (Even if the line has otherwise functioning code in it.)
// You can also use these double slashes _after_ a line of code,
// to serve as an in-line comment on that line of code.
// (Kinda like a note in the margin.)
// This little program requires "libraries"--other programs that extend the functionality of the base node.js code
@samplereality
samplereality / metro.js
Created March 26, 2014 13:13
In a Station of the Metro bot
var Twit = require('twit');
var rita = require('rita');
// In a Station of the Metro
//
// The apparition of these faces in the crowd:
// Petals on a wet, black bough.
@samplereality
samplereality / markovmelville.js
Last active August 29, 2015 13:57
Markov Chains using Moby-Dick
var rita = require('rita');
var fs = require('fs');
rm = new rita.RiMarkov(2), file = 'moby-dick.txt';
rm.minSentenceLength = 5;
rm.maxSentenceLength = 20;
@samplereality
samplereality / through_the_park.py
Created June 28, 2014 14:29
Nick Montfort's "Through the Park" short story generator
#!/usr/bin/python
# Through the Park, copyright (c) 2013 Nick Montfort <nickm@nickm.com>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
@samplereality
samplereality / bookimages.js
Last active August 29, 2015 14:06
Bookmarklet Code for Historical Book Images Search on Flickr
javascript:void(q=prompt('Enter%20search%20term:',getSelection()));if(q)void(location.href='https://www.flickr.com/search/?w=126377022@N07&q='+escape(q))
import random
possibleKings = ['king', 'queen', 'Elvis impersonator']
possibleVerbs = ['dead', 'sleeping', 'dying', 'singing']
king = random.choice(possibleKings)
dead = random.choice(possibleVerbs)
print 'The ' + king + ' is ' + dead + '. Long live the ' + king + '.'
# Any line that begins with a hash (pound sign) is ignored by the program
# Like this one
# These are called comments
# Think of comments in code as marginalia
# This Is Just To Say
# William Carlos Williams, 1883 - 1963
#
# I have eaten
# the plums
@samplereality
samplereality / plums.html
Created February 11, 2015 11:53
A web-based version of JustToSayBot
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>This Is Just To Say</title>
<meta name="description" content="This Is Just To Say" />
<style type="text/css">
body
@samplereality
samplereality / gist:4176962
Created November 30, 2012 16:54
Zotero Bookmarklet
javascript:var d=document,s=d.createElement('script');s.src='https://www.zotero.org/bookmarklet/loader.js';(d.body?d.body:d.documentElement).appendChild(s);void(0);
@samplereality
samplereality / whales.html
Created February 11, 2015 11:51
Moby Dick in Markov Chains
<html>
<head>
<canvas id="canvas" width=1200 height=400 style="border: 0px dashed #000000; display: block; margin:0 auto;"></canvas>
<script src="rita.js"></script>
<script>
RiTa.p5Compatible(true);
RiText.defaultFont("Georgia",18);
var rm = new RiMarkov(RiTa.random(2,5));