Skip to content

Instantly share code, notes, and snippets.

View particlebanana's full-sized avatar

Cody Stoltman particlebanana

View GitHub Profile
@particlebanana
particlebanana / feed-eater.rb
Created June 27, 2011 21:12
Parse an Instapaper RSS Folder Feed
require 'net/http'
require 'uri'
require 'rexml/document'
uri = URI.parse("ADD YOUR INSTAPAPER RSS FEED LINK HERE")
data = Net::HTTP.get_response(uri)
doc = REXML::Document.new(data.body)
doc.elements.each('rss/channel/item') do |s|
puts s[1][0]
if (typeof define !== 'function') { var define = require('amdefine')(module); }
define(function() {
return {
indexOf : function(arr, item) {
return arr.indexOf( item );
},
sum : function(arr) {
var sum = 0;
@particlebanana
particlebanana / app.js
Created August 9, 2012 17:18
Card Catalog Example
var http = require('http'),
setup = require('./setup'),
card_catalog = require('cardcatalog'),
obj;
var setupFn = new setup();
setupFn.on('ready', function(res) {
obj = res;
});
@particlebanana
particlebanana / scrap.js
Created August 26, 2013 20:26
Simple Backbone View Manager
/**
* scrap
* v0.0.1
*
* 07/15/13
*/
(function() {
var _, root, Scrap, Backbone;
// Simple User model
// /api/models/User.js
module.exports = {
attributes: {
name: 'string'
}
};
@particlebanana
particlebanana / StoreController.js
Created September 5, 2013 03:38
An example of injecting dynamic routes for a language based app. See: https://github.com/balderdashy/sails/issues/821
// An example controller from /api/controllers/StoreController.js
module.exports = {
typeA: function(req, res) {
res.send('typeA action with Lang Type: ' + req.languageType);
},
typeB: function(req, res) {
res.send('typeB action with Lang Type: ' + req.languageType);
@particlebanana
particlebanana / bootstrap.js
Created September 18, 2013 21:43
Mocha before helper to show how to lift Sails
/**
* Bootstrap
*/
var Sails = require('sails');
/**
* Before ALL the test bootstrap the server
*/
@particlebanana
particlebanana / waterline-express-example.js
Last active October 31, 2019 15:53
How to load the beta of Waterline v0.10 when using Express.js Make sure to use the `associations` branch of any adapters you plan on loading.
/**
* A simple example of how to use Waterline v0.10 with Express
*/
var express = require('express'),
_ = require('lodash'),
app = express(),
Waterline = require('waterline');
var _ = require('lodash'),
async = require('async'),
Waterline = require('waterline');
// Instantiate a new instance of the ORM
var orm = new Waterline();
var mysqlAdapter = require('sails-mysql');
var config = {
@particlebanana
particlebanana / User.js
Created March 29, 2015 21:23
Mongo association examples
/**
* User.js
*
* @description :: TODO: You might write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
attributes: {