Skip to content

Instantly share code, notes, and snippets.

View DTrejo's full-sized avatar

David Trejo DTrejo

View GitHub Profile
require 'sinatra'
require 'infusionsoft'
require 'logger'
Infusionsoft.configure do |config|
config.api_url = 'XXXX.infusionsoft.com'
config.api_key = 'XXXXXXXXXXXXXXX'
config.api_logger = Logger.new("./infusionsoft_api.log")
end
@DTrejo
DTrejo / README.md
Last active August 29, 2015 14:10
Use the lobotomized owl selector in conjunction with margin auto and max-width for easy responsive single column sites. Inspired by http://alistapart.com/article/axiomatic-css-and-lobotomized-owls
@mixin table-base
th
text-align: center
font-weight: bold
td, th
padding: 2px
@mixin left($dist)
float: left
margin-left: $dist
var response = require('ringo/webapp/response');
var model = require('./model');
exports.index = function index(req) {
//last 10 posts
var posts = model.Post.query().select();//.slice(0,10);
return response.skinResponse('skins/index.html', {
posts: posts,
});
there should be js here but there isn't so this should throw an error.
function getDescription(barcode) {
var exec = require('child_process').exec,
child,
description;
// async command line call, takes its time to finish
child = exec('curl http://www.upcdatabase.com/item/' + barcode + ' -s | grep Description',
function (error, stdout, stderr) {
if(stderr.length > 0){
sys.puts('exec stderr: ' + stderr);
var item = { "hdbarcode": hdbarcode, "description": description };
// 2nd argument is callback
getDescription(item.hdbarcode, function(upcDescrip){
db.save(null, item, function (err, meta) {
// This does not change item on line 1. Why?
item.key = meta.key;
sys.puts('saved ' + JSON.stringify(item) + ' as '+ meta.key);
});
});
// Used to run code in a directory and rerun it if any files are changed.
// usage: node run.js servercode.js
// servercode.js is whatever js file you want to run with node.
// Excludes filetypes in the ignoreExtensions array
var sys = require('sys'),
fs = require('fs'),
spawn = require('child_process').spawn,
child, // child process which runs the actual code
ignoreExtensions = ['.dirtydb', '.db'];
// Used to run code in a directory and rerun it if any files are changed.
// usage: node run.js servercode.js
// servercode.js is whatever js file you want to run with node.
// Excludes filetypes in the ignoreExtensions array
var sys = require('sys'),
fs = require('fs'),
spawn = require('child_process').spawn,
child, // child process which runs the actual code
ignoreExtensions = ['.dirtydb', '.db']; // Change this to your liking
var static = require('node-static');
//
// Create a node-static server instance to serve the './public' folder
//
var file = new(static.Server)('./public');
require('http').createServer(function (request, response) {
request.addListener('end', function () {
//