This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
this.MysqlBinlogTailer = MysqlBinlogTailer; | |
var EventEmitter = require('events').EventEmitter; | |
var fs = require('fs'); | |
var path = require('path'); | |
/** | |
* Tails a Mysql binlog and emits an event for every query executed. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a hacked-together form validation KnockoutJS plugin. | |
// The formatting is a bit messed up in places too. | |
// TODO: Refactor to allow more than one form on a page! | |
console.log("baz"); | |
(function() { | |
var handlers = { required |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Choose a ticket class: <select id="tickets"></select> | |
<p id="ticketOutput"></p> | |
<script id="ticketTemplate" type="text/x-jquery-tmpl"> | |
{{if chosenTicket}} | |
You have chosen <b>${ chosenTicket().name }</b> | |
($${ chosenTicket().price }) | |
<button data-bind="click: resetTicket">Clear</button> | |
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var flashTime = new Date(); | |
ko.bindingHandlers.flashOnChange = { | |
update: function (element, valueAccessor) { | |
// If the page has just loaded, don't flash all the data. | |
if (new Date().getTime() < flashTime.getTime() + 1000) return; | |
// Whenever the value subsequently changes, flash it | |
var value = valueAccessor(); | |
$(element).addClass('new'); | |
setTimeout(function() { $(element).removeClass('new'); }, 2000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/mman.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#define SIZE 4096 | |
int main(void) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Network.Socket hiding (send, sendTo, recv, recvFrom) | |
import Network.Socket.ByteString | |
import qualified Data.ByteString.Lazy as LBS | |
import qualified Data.ByteString as BS | |
import Text.ProtocolBuffers.WireMessage (messageGet) | |
import AddressBookProtos.Person | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def class-keyword-map (atom {})) | |
(defn class-keyword | |
[instance] | |
(@class-keyword-map (class instance))) | |
(defmacro defadrec | |
[klass & body] | |
`(do | |
; create the record as normal | |
(defrecord ~klass ~@body) | |
; and add the type to the keyword lookup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A task on a task list (and also possibly on an outstanding_task_list. | |
struct task { | |
int priority; | |
struct list_node task_list; | |
const char *task_name; | |
struct list_node outstanding_task_list; | |
}; | |
void list() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('should provide a many to one relation', function() { | |
var ic = util.ManyToOne('imei', 'callsign'); | |
ic.add('345123123123', 'ROMEO1'); | |
ic.add('345456456456', 'DELTA2'); | |
ic.add('345678678678', 'ROMEO1'); | |
assert.equal(ic.imei_to_callsign['345123123123'], 'ROMEO1'); | |
assert.equal(ic.imei_to_callsign['345456456456'], 'DELTA2'); | |
assert.equal(ic.imei_to_callsign['345678678678'], 'ROMEO1'); | |
assert.equal(ic.callsign_to_imeis['ROMEO1'], ['345123123123', '345678678678']); | |
assert.equal(ic.callsign_to_imeis['DELTA2'], ['345678678678']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IState { | |
public void GuiBookOn() throws InvalidStateException; | |
public void GuiBookOff() throws InvalidStateException; | |
public void NetBookedOn() throws InvalidStateException; | |
public void NetBookedOff() throws InvalidStateException; | |
} | |
public enum State implements IState { | |
BOOKED_OFF { | |
@Override |
OlderNewer