Skip to content

Instantly share code, notes, and snippets.

class DistanceCalculator
#radians per degree
RAD_PER_DEG = 0.017453293
#radius of the earth, in miles
Rmiles = 3956
def self.get_distance(lat1, lon1, lat2, lon2)
# [ ~/Projects/nuklei/smoothiewizard/public/javascripts ] $ cdu 4
# [ ~/Projects ] $
function cdu { # "cd up" - move up $1 directories
if [ -z $1 ]; then
num=1
else
num=$1
fi
while [ $num -gt "0" ]; do
%{
#include <ctype.h>
#include <stdio.h>
#define YYSTYPE double
%}
%token NUMBER
%left '+' '-'
%left '*' '/'
%left UNARYMINUS
%left UNARYPLUS
private def getBookList(url: String): List[Book] = {
var books = List[Book]();
(ConstructingParser.fromSource(Source.fromURL(url), false) .document()
.docElem\\ "Item")
.foreach((item: Node) => {
books = new Book(
(item \ "ItemAttributes" \ "Title").text,
(item \ "ASIN").text
) :: books
});
def page(query:String) = {
<html> <head>
<title>Book Search Results</title>
</head>
<body>
<h1>Book Search Results</h1>
<p>
You searched for
"<b>{ Text( query )}</b>"
package com.thinkminimo.booksearch;
import java.net._;
import scala.io._;
import scala.xml._ ;
import scala.xml.parsing._ ;
class AmazonResultPage {
val awskey = "02KVYA5XBEP8PMG4HAR2"
require 'rubygems'
require 'sinatra'
require 'json'
class Person
attr_accessor :first, :last
def initialize(first, last)
@first = first
_json_encode: function(inVal, out) {
out = out || new Array();
var undef; // undefined
switch (typeof inVal) {
case 'object':
if (!inVal) {
out.push('null');
} else {
if (inVal.constructor == Array) {
var testVal = inVal.length;
function tableize(wrapper, row, field, data, columns) {
return $("<"+wrapper+"/>").append(
A(data).map(function() {
var ret = $("<"+row+"/>");
$.each($.map(this, function(prop) {
for(c in columns) {
if(columns[c] == prop) {
return prop;
}
}
function tableize(data, selector) {
return $("<table/>").append(
A(data).find(selector).map(function() {
var ret = "<tr/>";
$.each(this, function(k,v) { ret += "<td>"+v+"</td>" });
return ret + "</tr>";
}).get().join("")
);
}