Skip to content

Instantly share code, notes, and snippets.

View robotastic's full-sized avatar
🖖

Luke Berndt robotastic

🖖
View GitHub Profile
@lashex
lashex / aws-iot-mosquitto
Created May 23, 2016 21:05
Example Mosquitto CLI pub/sub using AWS IoT MQTT endpoint
The Mosquitto Pub CLI
$> mosquitto_pub --cert thing-0.pem --key thing-0.prv --cafile aws-iot-rootCA.crt -h XXXXXXXXYYYYY.iot.us-west-2.amazonaws.com -p 8883 -t 'test/thing' -m "Hello from Mosquitto"
The Mosquitto Sub CLI
$ mosquitto_sub --cert thing-0.pem --key thing-0.prv --cafile aws-iot-rootCA.crt -h XXXXXXXXYYYYY.iot.us-west-2.amazonaws.com -p 8883 -t 'test/+'
@xiongjia
xiongjia / 0_main.cxx
Last active September 11, 2022 01:39
A simple sample of Boost Log #devsample #boost
/**
* A simple sample of Boost Log
*/
#pragma warning(push)
#pragma warning(disable:4819)
# include <boost/shared_ptr.hpp>
# include <boost/date_time/posix_time/posix_time_types.hpp>
# include <boost/log/trivial.hpp>
# include <boost/log/core.hpp>
@andrewburgess
andrewburgess / bootstrap-infiniteScroll.js
Last active January 24, 2024 23:49
Twitter Bootstrap plugin that enables infinite scrolling
/* ============================================
* bootstrap-infiniteScroll.js
* ============================================ */
!function ($) {
'use strict';
var InfiniteScroll = function (el, options) {
this.$element = $(el);
this.$data = $(el).data();
this.$options = options;
@endJunction
endJunction / config.xml
Created November 7, 2012 11:08
boost::property_tree and xml config example
<coupling>
<P algorithm="serial">
<M name="flow1" type="GROUNDWATER_FLOW" />
<P algorithm="parallel">
<M name="compoundA" type="MASS_TRANSPORT" />
<M name="compoundB" type="MASS_TRANSPORT" />
</P>
</P>
</coupling>
@geddski
geddski / nesting.js
Created January 14, 2012 05:08
helper function for nesting backbone collections.
function nestCollection(model, attributeName, nestedCollection) {
//setup nested references
for (var i = 0; i < nestedCollection.length; i++) {
model.attributes[attributeName][i] = nestedCollection.at(i).attributes;
}
//create empty arrays if none
nestedCollection.bind('add', function (initiative) {
if (!model.get(attributeName)) {
model.attributes[attributeName] = [];
@mloskot
mloskot / boost_property_tree_json_array.cpp
Created December 22, 2011 11:11
Simple example of parsing and consuming JSON array with boost::property_tree
#ifdef _MSC_VER
#include <boost/config/compiler/visualc.hpp>
#endif
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/foreach.hpp>
#include <cassert>
#include <exception>
#include <iostream>
#include <sstream>
.ancestor {
shield-name: something;
shield-name: something;
shield-size: something;
shield-fill: something;
shield-min-distance: something;
shield-spacing: something;
shield-spacing: something;
shield-line-spacing: something;
shield-file: something;
@jacob414
jacob414 / backbone-tutorial.js
Created November 18, 2010 12:54
Minimal example of data handling in Backbone.js
/* Scaled-down Backbone.js demonstration
* By Jacob Oscarson (http://twitter.com/jacob414), 2010
* MIT Licenced, see http://www.opensource.org/licenses/mit-license.php */
$(function() {
window.ulog = function(msg) { $('#log').append($('<div>'+msg+'</div>')); }
// Faking a little bit of Backbone.sync functionallity
Backbone.sync = function(method, model, succeeded) {
ulog('<strong>'+method + ":</strong> " + model.get('label'));
if(typeof model.cid != 'undefined') {
anonymous
anonymous / xmlTest.js
Created November 5, 2010 20:27
Fetches a XML file and iterates of price elements - node.js + jquery
var fs = require('fs'), util = require('util'),
jsdom = require('jsdom'), http = require('http');
var jQueryHome = '/home/woidda/libs/js/jquery-1.4.2.min.js';
var xmlFileUrl = 'http://www.w3schools.com/xml/plant_catalog.xml';
var host = 'www.w3schools.com';
var client = http.createClient(80, host);
var db = new mongo.Db('mydatabase', new mongo.Server("127.0.0.1", 27017, {}));
db.open(function(e, db) {
get('/', function() {
var $this = this
db.collection('some-collection', function(e, col){
col.find({}, {}, function(e, items) {
items.each(function(err, item) {
sys.puts(sys.inspect(item))
})