Skip to content

Instantly share code, notes, and snippets.

(defn find-cycle
"finds a single cycle in the parents
starting at the seed index"
[a b seed]
(loop [coll (mapv vector a b)
cyl #{}
cur (get-in coll [seed 0])]
(let [idx (first (keep-indexed #(if (= (first %2) cur) %1) coll))]
(if (nil? idx)
(vec cyl)
@cshepp
cshepp / static-blog.js
Created June 27, 2014 18:35
Static Blog Generator
/*
Static Site Generator
Author: Cody Shepp 6/27/2014
License: MIT
The only outside dependency is mustache (npm install mustache)
The basic folder structure I used is as follows:
/
@cshepp
cshepp / gyro.html
Last active December 15, 2015 02:19
Excuse the ugly code - this was just a proof-of-concept. Because my "server" wasn't always at the same IP address, I made my phonegap app load a generic index.html file (from the /assets/www directory within the app) that would allow me to specify a page to load - in this case, I would load my.server.ip.address:port/gyro.html. Gyro.html takes ca…
<!doctype html>
<head>
<title>controller</title>
<!--<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" />-->
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<!--<script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>-->
<script src="socket.io/socket.io.js"></script>
<script src="cordova-2.0.0.js"></script>
<script>
var transmit = false;
@cshepp
cshepp / socket.iodisconnect.js
Created August 3, 2012 15:10
Socket.io disconnect
socket.on('disconnect', function(socket){
socket.get('room', function(err, room){
socket.get('nick', function(err, nick){
socket.broadcast.to(room).emit('client-left', nick);
});
});
});