This file contains hidden or 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
@mixin table-base | |
th | |
text-align: center | |
font-weight: bold | |
td, th | |
padding: 2px | |
@mixin left($dist) | |
float: left | |
margin-left: $dist |
This file contains hidden or 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 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, | |
}); |
This file contains hidden or 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
there should be js here but there isn't so this should throw an error. |
This file contains hidden or 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
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); |
This file contains hidden or 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
// 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']; |
This file contains hidden or 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 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); | |
}); | |
}); |
This file contains hidden or 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
// 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 |
This file contains hidden or 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 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 () { | |
// |
This file contains hidden or 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 sys = require('sys') | |
, url = require('url') | |
, http = require('http') | |
, eyes = require('eyes') | |
, querystring = require('querystring') | |
, io = require(__dirname + '/lib/socket.io-node') | |
, PORT = 80 // MAKE SURE THIS IS SAME AS SOCKET.IO | |
, static = require('node-static') | |
This file contains hidden or 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
public class Bitops { | |
// Takes a character and returns the number of ones | |
// contained in its binary representation | |
static int numOnes(char c) { | |
int hex = (int) c; | |
int sum = 0; | |
// we want unsigned comparison | |
// this works fine if java uses 2s complement (it does I think). | |
while (hex > 0) { |
OlderNewer