Skip to content

Instantly share code, notes, and snippets.

Lance Pollard lancejpollard

Block or report user

Report or block lancejpollard

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View viterbi.js
// Viterbi algorithm for finding hidden relationships
function Viterbi(data) {
var V = [{}];
var path = {};
// Initialize base cases (t == 0)
for(var i=0;i<data.states.length;i++) {
var state = data.states[i];
V[0][state] = data.start_probability[state] * data.emission_probability[state][data.observations[0]];
path[state] = [state];
View gist:9042712

HLS streaming from node

Provided that you already have a file or stream segmenter generating your .m3u8 playlist and .ts segment files (such as the ffmpeg 'hls' muxer), this little node server will serve up those files to an HLS compatible client (e.g. Safari). If you're using node for your streaming app already, this obviates the need to serve the HLS stream from a separate web server.

loosely based on https://gist.github.com/bnerd/2011232

// loosely based on https://gist.github.com/bnerd/2011232
// requires node.js >= v0.10.0
// assumes that HLS segmenter filename base is 'out'
// and that the HLS playlist and .ts files are in the current directory
@lancejpollard
lancejpollard / Readme.md
Last active Aug 29, 2015
The Client-Side Rendering Problem
View Readme.md

The Client-Side Rendering Problem

The core problem with UI rendering boils down to these two questions:

  1. How do you know when something has changed?
  2. How do you most optimally update the UI with those changes?

What has changed?

There are several implementations that can tell you what has been changed, some of which are:

@lancejpollard
lancejpollard / Flex Keyboard Handler
Created Jan 18, 2010
Simple Example of Using Keyboard Events from Javascript to Actionscript, so you can hijack Browser Keyboard Handlers
View Flex Keyboard Handler
var FlexKeyboardHandler = FlexKeyboardHandler || {}
FlexKeyboardHandler.setup = function ()
{
window.addEventListener("keypress", FlexKeyboardHandler.keydownHandler, true);
window.addEventListener("keydown", FlexKeyboardHandler.keydownHandler, true);
getFlexApplication("MyApp").addEventListener("keypress", FlexKeyboardHandler.keydownHandler, true);
getFlexApplication("MyApp").addEventListener("keypress", FlexKeyboardHandler.keydownHandler, false);
window.focus();
};
View Post with Slug DB Call
SQL (0.4ms) SELECT COUNT(*) AS count_id FROM "posts" WHERE ("posts"."parent_id" IS NULL)
Post Load (0.7ms) SELECT "posts".* FROM "posts" WHERE ("posts"."parent_id" IS NULL) ORDER BY "lft"
Slug Load (0.4ms) SELECT "slugs".* FROM "slugs" WHERE ("slugs".sluggable_id = 13 AND "slugs".sluggable_type = 'Post') ORDER BY id DESC LIMIT 1
SQL (0.3ms) SELECT COUNT(*) AS count_id FROM "posts" WHERE ("posts".parent_id = 13)
Post Load (0.7ms) SELECT "posts".* FROM "posts" WHERE ("posts".parent_id = 13) ORDER BY "lft"
Post Load (0.4ms) SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 13) LIMIT 1
CACHE (0.0ms) SELECT "slugs".* FROM "slugs" WHERE ("slugs".sluggable_id = 13 AND "slugs".sluggable_type = 'Post') ORDER BY id DESC LIMIT 1
Slug Load (0.4ms) SELECT "slugs".* FROM "slugs" WHERE ("slugs".sluggable_id = 39 AND "slugs".sluggable_type = 'Post') ORDER BY id DESC LIMIT 1
SQL (0.4ms) SELECT COUNT(*) AS count_id FROM "posts" WHERE ("posts".parent_id = 39)
CACHE (0.0ms) SELECT "posts".* FROM "po
View jquery.parse-child-html-document-from-remote-string.js
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Parent Page wanting to Parse Children</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<meta name="keywords" content="parent, html, parsing">
</head>
<body>
<script type="text/javascript">
$(document).ready(function() {
View basic-html5-layout.html
<body>
<section class="top" role="definition">
<div class="header">
<div class="frame">
<header></header>
<nav></nav>
</div>
</div>
</section>
<section class="main" role="main">
View scss-structure.markdown
stylesheets/
  application.scss
  base/
    _base.scss
    _grid.scss
    _reset.scss
    _typography.scss
  components/
    editor/
      _design.scss
View html5-dom.html
<div class='document' role='document'>
<section class='header container' role='definition'>
<div class='navigation'>
<div class='frame'>
<header class='logo'>
<h1></h1>
</header>
<nav class='menu' role='directory'>
<ul>
<li>
View How to Install Node.js on a Mac.sh
git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install
You can’t perform that action at this time.