Skip to content

Instantly share code, notes, and snippets.

;; Jaime Moran 2011
(ns parser
(:use [clojure.contrib.duck-streams :only (read-lines)]
clojure.contrib.json))
;; This processes a CSV file, with all energy consumption data from
;; 1960-2009 accross all US states
;;
;; MSN,StateCode,Year,Data
# These are my notes from the PragProg book on CoffeeScript of things that either
# aren't in the main CS language reference or I didn't pick them up there. I wrote
# them down before I forgot, and put it here for others but mainly as a reference for
# myself.
# assign arguments in constructor to properties of the same name:
class Thingie
constructor: (@name, @url) ->
# is the same as:
/*
Excenlente,
unas observaciones.
*/
var items =
Array(
{ valor:"A", probabilidad: (5/10) },
{ valor:"B", probabilidad: (1/10) },
var res = ({
query:{
"count": 3,
"created": "2011-02-28T07:15:39Z",
"lang": "en-US",
"results": {
"rss": [{
"channel": {
"item": {
"title": "Post 1 Title",
### Getting entries from my blog (Posterous)
getBlogPosts = ->
req = $.ajax 'http://query.yahooapis.com/v1/public/yql',
jsonp:'callback'
dataType:'jsonp'
data:
q: "select channel.item.title, channel.item.pubDate,
channel.item.link from xml where
url = 'http://blog.jrmoran.com/rss' limit 6"
format: 'json'
var PortfolioBuilder = function() {
var $context = "";
var symbols = [];
var that = this;
return{
init: function(context) {
$context = $(context);
this.initSymbols();
this.updateButtons();
def build_portfolio
# preparing portfolio data for charts
stocks, eps, pm, industries, price_performance = [], [], [], {}, []
Portfolio.first.portfolio_companies.each do |pc|
# create arrays from data
stocks << pc.company.symbol if pc.company.symbol
eps << pc.company.diluted_eps if pc.company.diluted_eps
pm << (pc.company.profit_margin*100).round(1) if pc.company.profit_margin