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
| # /server.coffee | |
| ... | |
| {TwitterNode} = require 'twitter-node' | |
| # create our interface to the Twitter Streaming API | |
| twitter = new TwitterNode | |
| user: 'yourtwitterusername' | |
| password: 'yourtwitterpassword' | |
| track: ["why"] |
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
| sys = require('sys') | |
| _ = require('underscore') | |
| io = require('socket.io') | |
| express = require('express') | |
| TwitterNode = require('twitter-node').TwitterNode | |
| # vs. | |
| sys = require 'sys' | |
| _ = require 'underscore' |
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
| class Docdata < ActiveRecord::Base | |
| belongs_to :document | |
| after_save :index_document | |
| def self.to_hstore(hash) | |
| hash.map {|k, v| "\"#{sanitize(k)}\"=>\"#{sanitize(v)}\"" }.join(',') | |
| end | |
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
| require 'rubygems' | |
| gem 'rails', '>= 3.0.7' | |
| # Skip ActiveResource. | |
| require 'active_record/railtie' | |
| require 'action_controller/railtie' | |
| require 'action_mailer/railtie' | |
| require 'rails/test_unit/railtie' |
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
| (= gravity* 1.8 timebase* 120 front-threshold* 1 | |
| nourl-factor* .4 lightweight-factor* .3 ) | |
| (def frontpage-rank (s (o scorefn realscore) (o gravity gravity*)) | |
| (* (/ (let base (- (scorefn s) 1) | |
| (if (> base 0) (expt base .8) base)) | |
| (expt (/ (+ (item-age s) timebase*) 60) gravity)) | |
| (if (no (in s!type 'story 'poll)) .5 | |
| (blank s!url) nourl-factor* | |
| (lightweight s) (min lightweight-factor* |
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
| # If the request is asking for JSONP (eg. has a 'callback' parameter), then | |
| # short-circuit, and return the rendered JSONP. | |
| def jsonp_request? | |
| return false unless params[:callback] | |
| @callback = params[:callback] | |
| render :partial => 'common/jsonp.js', :type => :js | |
| true | |
| end |
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
| ~/Desktop/nyt/work(v2) > sudo npm uninstall coffee-script | |
| npm info it worked if it ends with ok | |
| npm info using npm@0.3.16 | |
| npm info using node@v0.4.2 | |
| npm info preuninstall coffee-script@1.0.1 | |
| npm info uninstall coffee-script@1.0.1 | |
| npm info predeactivate coffee-script@1.0.1 | |
| npm info deactivate coffee-script@1.0.1 | |
| npm info postdeactivate coffee-script@1.0.1 | |
| npm info postuninstall coffee-script@1.0.1 |
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
| if images = settings.preloadImages | |
| (new Image).src = image for image in images.reverse() |
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
| select document_id, ts_headline('english', text, plainto_tsquery('#{search}'), | |
| 'minWords=10,maxWords=20,maxFragments=1') | |
| as highlight from pages | |
| where pages.document_id in (#{documents.map(&:id).join(',')}) | |
| and pages.text @@ plainto_tsquery('#{search}') | |
| limit 5 |