Skip to content

Instantly share code, notes, and snippets.

Alan Dipert alandipert

Block or report user

Report or block alandipert

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:78784
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)
View gist:79230
# [ ~/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
View hoc.y
%{
#include <ctype.h>
#include <stdio.h>
#define YYSTYPE double
%}
%token NUMBER
%left '+' '-'
%left '*' '/'
%left UNARYMINUS
%left UNARYPLUS
View gist:99548
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
});
View gist:99584
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>"
View gist:99585
package com.thinkminimo.booksearch;
import java.net._;
import scala.io._;
import scala.xml._ ;
import scala.xml.parsing._ ;
class AmazonResultPage {
val awskey = "02KVYA5XBEP8PMG4HAR2"
View gist:102817
require 'rubygems'
require 'sinatra'
require 'json'
class Person
attr_accessor :first, :last
def initialize(first, last)
@first = first
View gist:102985
_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;
View gist:108639
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;
}
}
View gist:108648
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("")
);
}
You can’t perform that action at this time.