Skip to content

Instantly share code, notes, and snippets.

View davisford's full-sized avatar

Davis Ford davisford

View GitHub Profile
@davisford
davisford / CMakeLists.txt
Created September 26, 2012 17:16
Issue with CMake cross-compile and find_library()
# add ZeroMQ library
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if (${CMAKE_CROSSCOMPILING})
# build with Arm / Pi-compiled libraries
find_library(ZEROMQ_LIB zmq ${PROJECT_SOURCE_DIR}/../lib/linux/pi)
find_library(CZMQ_LIB czmq ${PROJECT_SOURCE_DIR}/../lib/linux/pi)
else()
@davisford
davisford / CMakeLists.txt
Created September 24, 2012 15:20
CMake static linker issue
project(foo)
SET(CMAKE_EXE_LINKER_FLAGS -static)
# add ZeroMQ library
add_library(imp_zeromq STATIC IMPORTED)
set_property(TARGET imp_zeromq PROPERTY
IMPORTED_LOCATION $ENV{ZEROMQ_HOME}/libzmq.a)
# add C bindings for ZeroMQ library
@davisford
davisford / client.c
Created September 19, 2012 20:43
zeromq bad address
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <msgpack.h>
#include <zmq.h>
#include <string.h>
#include <unistd.h>
#include "zhelpers.h"
#include <czmq.h>
#include <errno.h>
@davisford
davisford / launch_sublime_from_terminal.markdown
Created September 14, 2012 19:32 — forked from olivierlacan/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@davisford
davisford / phantom-header.js
Created July 27, 2012 13:45
Phantom/Casper request/response JSON
// how to dump headers and what they look like
casper.on('resource.requested', function (request) {
console.log('Request ' + JSON.stringify(request, undefined, 4));
});
casper.on('resource.received', function (response) {
console.log('Receive ' + JSON.stringify(response, undefined, 4));
});
@davisford
davisford / SocketStream.publish.spy.js
Created June 18, 2012 16:03
Using sinon.js to stub net.Socket and SocketStream pub/sub
// Example test that spies on SocketStream.publish.channel() calls
// Using Mocha to drive: http://visionmedia.github.com/mocha/
// sinon.js for stubs/mocks/spies: http://sinonjs.org
// should.js for assertions: https://github.com/visionmedia/should.js
var sinon = require('sinon')
, should = require('should')
, ss = require('socketstream').start();
describe("Spying on SocketStream for testing", function() {
@davisford
davisford / foo.js
Created June 17, 2012 14:43
JavaScript scope - demo showing JS private, privileged, etc. scope
var FooWrapper = (function() {
// private module scope, shared among all Foo instances
var _private1 = "private1";
var _private3 = "private3";
var Foo = function(arg1, arg2, arg3) {
// private instance var, only visible to privileged methods
// in models/user.js
var mongoose = require('mongoose');
var Schema = mongoose.Schema
, ObjectId = mongoose.SchemaTypes.ObjectId
// example model
var UserSchema = new Schema({
email: { type: String, unique: true, index: true }
});
@davisford
davisford / editor.css
Created February 2, 2012 19:59
HTML/css/js editor using backbone.js, jquery-ui, and jsPlumb; jsPlumb endpoints are not behaving as expected here. They are transparent, and they do not drag along with their source or target.
body {
background-color:white; font-size:90%;
/*background-image:url(../images/dynamicAnchorBg.jpg); */
background-image:url(http://colourlovers.com.s3.amazonaws.com/images/patterns/222/222733.png?1221244242);
font-family:Helvetica;
height: 100%;
}
#editorCanvas {
position: absolute;
@davisford
davisford / txrx.mxml
Created August 8, 2011 22:59
Transmit and Receive
<?xml version="1.0" encoding="utf-8"?>
<s:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:swiz="http://swiz.swizframework.org"
backgroundColor="#bdcdf4"
width="100%" height="100%" >
<fx:Script>
<![CDATA[