Skip to content

Instantly share code, notes, and snippets.

@brigand
brigand / Arrays.html
Last active December 19, 2015 08:19
Knockout Observable Arrays
<!DOCTYPE html>
<html>
<head>
<title>My First Knockout App</title>
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.css"/>
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap-responsive.css"/>
<link rel="stylesheet" type="text/css" href="assets/css/myfirstko.css" />
</head>
<body>
<div class="container-fluid">
@brigand
brigand / events.html
Created July 4, 2013 05:38
Knockout Event Handling
<!DOCTYPE html>
<html>
<head>
<title>My First Knockout App</title>
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.css"/>
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap-responsive.css"/>
<link rel="stylesheet" type="text/css" href="assets/css/myfirstko.css" />
</head>
<body data-bind="event: {keypress: handleKeypress}">
<div class="container-fluid">
<!DOCTYPE html>
<html>
<head>
<title>My First Knockout App</title>
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.css"/>
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap-responsive.css"/>
<link rel="stylesheet" type="text/css" href="assets/css/myfirstko.css" />
</head>
<body>
<div class="container-fluid">
<!DOCTYPE html>
<html>
<head>
<title>My First Knockout App</title>
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.css"/>
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap-responsive.css"/>
<link rel="stylesheet" type="text/css" href="assets/css/myfirstko.css" />
</head>
<body>
<div class="container-fluid">
(function ($, root) {
var DEBUG = true;
var queue = [], waitingFor = 0, pagesComplete = 0, pagesStarted = 0;
var inteliscroll = function (options) {
var opts = $.extend({}, inteliscroll['defaults'], options);
var pagesToLoadAtOnce = opts.startPages, lastPage = 0;
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks Menu</H1>
<DL><p>
<DL>
@brigand
brigand / a.md
Created December 14, 2013 08:44

This is 50 <br />s.

















































This is the next line.

@brigand
brigand / basic_example.js
Last active December 31, 2015 14:59
simple promise wrapper for web workers; it allows calling their functions and getting promises for the values depends on the Q promise library, but could easily be modified to work with any.
// create a new worker
// we provide a list of convience methods for the worker
var worker = new PromiseWorker("basic_worker.js", ["add"]);
worker.add(5, 7).then(function (sum) {
console.log("5 + 7 = " + sum);
});
// this also works if you don't include the convience array
worker.perform("add", 5, 7).then(function (sum) {
console.log("5 + 7 = " + sum);
@brigand
brigand / bookmarklet.js
Last active January 1, 2016 11:49
find unknown bindings (potential typos) for knockout.js
/**
* this is a bookmarklet you can use to load the following script on a page
* the results will be in the console
*/
javascript:(function(){var s=document.createElement("script");s.src="https://gist.github.com/brigand/8140449/raw/b42af3eea883b9f3da7e5442a742c2350622e843/findUnknownBindings.js";document.body.appendChild(s)})(); void 0;
var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
console.log(computerChoice);
if(computerChoice <= 1/3){
computerChoice = "rock";
} else if(computerChoice <= 2/3){
computerChoice = "paper";
} else if(computerChoice <= 1){
computerChoice = "scissors";
}