Skip to content

Instantly share code, notes, and snippets.

View tanordheim's full-sized avatar

Trond Nordheim tanordheim

View GitHub Profile
@tanordheim
tanordheim / model.rb
Created January 20, 2012 22:11
Yr Dataa Source Mapping
> ds = DataSources::XML.new(:url => 'http://www.yr.no/place/Norway/S%C3%B8r-Tr%C3%B8ndelag/Trondheim/Trondheim/varsel.xml')
> ds.mappings.build(:name => 'copyright', :input => 'weatherdata/credit/link/@text')
> ds.mappings.build(:name => 'location', :input => 'weatherdata/forecast/text/location/@name')
> ds.mappings.build(:name => 'forecast_period', :input => 'weatherdata/forecast/text/location/time/title/text')
> ds.mappings.build(:name => 'forecast', :input => 'weatherdata/forecast/text/location/time/body/text')
> ds.mappings.build(:name => 'weather_symbol_id', :input => 'weatherdata/forecast/tabular/time/symbol/@number')
> ds.mappings.build(:name => 'weather_symbol_name', :input => 'weatherdata/forecast/tabular/time/symbol/@name')
> ds.mappings.build(:name => 'wind_speed_mps', :input => 'weatherdata/forecast/tabular/time/windSpeed/@mps')
> ds.mappings.build(:name => 'wind_speed_name', :input => 'weatherdata/forecast/tabular/time/windSpeed/@name')
> ds.mappings.build(:name => 'wind_direction_code', :input =
@tanordheim
tanordheim / schema.txt
Created January 20, 2012 13:13
Yr Data Source Schema
> ds.schema.pretty_print
weatherdata
location
name
text
type
text
country
text
timezone
@tanordheim
tanordheim / flat-mapping.json
Created January 19, 2012 11:03
Complex Data Source Mappings
[
{
"Stedsnavn": "Trondheim",
"Copyright": "Værvarsel fra yr.no, levert av Meteorologisk institutt og NRK",
"Sist Oppdatert": "2012-01-19T07:08:00",
"Soloppgang": "2012-01-19T09:29:52",
"Vind": "Lett bris"
}
]
@tanordheim
tanordheim / gist:1605269
Created January 13, 2012 09:26
node-agent-output
Jan 13 10:25:28 INFO Attempting to reconnect to the content distribution server 127.0.0.1:31337
Jan 13 10:25:28 DEBUG Connection against content delivery server established, attempting to authenticate
Jan 13 10:25:39 INFO Successfully authenticated againt the content distribution server
Jan 13 10:25:39 INFO First connection since node agent startup established, asking for re-distribution of channel content.
Jan 13 10:25:52 INFO Received message from content distributor: SUCCESS Redistribution requested, data will be coming shortly.
Jan 13 10:26:23 INFO Starting new content delivery transaction
Jan 13 10:26:23 INFO Committing transaction containing 11277 bytes of data
Jan 13 10:26:23 INFO Written 86 bytes to /Users/trond/code/global-illumination/node-agent/data/stage.json
Jan 13 10:26:23 INFO Written 343 bytes to /Users/trond/code/global-illumination/node-agent/data/channel.json
Jan 13 10:26:23 INFO Written 223 bytes to /Users/trond/code/global-illumination/node-agent/data/templates/6cb7b9f
@tanordheim
tanordheim / Gemfile
Created January 11, 2012 21:08
Error when using Chef-gem in Rails3.1.3
source 'http://rubygems.org'
gem 'rails', '3.1.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
gem 'json'
[Thu, 03 Nov 2011 01:19:02 +0100] DEBUG: Sending HTTP Request via GET to www.skype.com:80/go/getskype-macosx.dmg
[Thu, 03 Nov 2011 01:19:03 +0100] DEBUG: Streaming download from http://www.skype.com/go/getskype-macosx.dmg to tempfile /var/folders/zz/zyxvpxvq
6csfxvn_n0000000000000/T/chef-rest20111103-30418-1p92hzb-0
[Thu, 03 Nov 2011 01:19:03 +0100] DEBUG: Following redirect 1/10
[Thu, 03 Nov 2011 01:19:03 +0100] DEBUG: Sending HTTP Request via GET to www.skype.com:80/go/getskype-macosx
[Thu, 03 Nov 2011 01:19:03 +0100] DEBUG: Streaming download from http://www.skype.com/go/getskype-macosx to tempfile /var/folders/zz/zyxvpxvq6csf
xvn_n0000000000000/T/chef-rest20111103-30418-1f87yiu-0
[Thu, 03 Nov 2011 01:19:03 +0100] DEBUG: Following redirect 2/10
[Thu, 03 Nov 2011 01:19:03 +0100] DEBUG: Sending HTTP Request via GET to www.skype.com:80/go/getskype-samplingb
[Thu, 03 Nov 2011 01:19:03 +0100] DEBUG: Streaming download from http://www.skype.com/go/getskype-samplingb to tempfile /var/folders/zz/zyxvpxvq6
[Wed, 26 Oct 2011 16:11:20 +0000] ERROR: Running exception handlers
[Wed, 26 Oct 2011 16:11:20 +0000] ERROR: Report handler Chef::Handler::ErrorReport raised #<Encoding::InvalidByteSequenceError: "\xC3" on US-ASCII>
[Wed, 26 Oct 2011 16:11:20 +0000] ERROR: /usr/lib/ruby/gems/1.9.1/gems/chef-0.10.4/lib/chef/node.rb:501:in `encode'
[Wed, 26 Oct 2011 16:11:20 +0000] ERROR: /usr/lib/ruby/gems/1.9.1/gems/chef-0.10.4/lib/chef/node.rb:501:in `to_json'
[Wed, 26 Oct 2011 16:11:20 +0000] ERROR: /usr/lib/ruby/gems/1.9.1/gems/chef-0.10.4/lib/chef/node.rb:501:in `to_json'
[Wed, 26 Oct 2011 16:11:20 +0000] ERROR: /usr/lib/ruby/gems/1.9.1/gems/chef-0.10.4/lib/chef/node.rb:501:in `to_json'
[Wed, 26 Oct 2011 16:11:20 +0000] ERROR: /usr/lib/ruby/gems/1.9.1/gems/chef-0.10.4/lib/chef/node.rb:501:in `to_json'
[Wed, 26 Oct 2011 16:11:20 +0000] ERROR: /usr/lib/ruby/gems/1.9.1/gems/chef-0.10.4/lib/chef/node.rb:501:in `to_json'
[Wed, 26 Oct 2011 16:11:20 +0000] ERROR: /usr/lib/ruby/gems/1.9.1/gems/chef-0.10.4/lib/chef/node.rb:501:in
/Users/Trond/Code/Clients/BinaryMarbles/Sherlock/node_modules/mongoose/lib/schema.js:203
return new Types[type.name](path, obj);
^
TypeError: undefined is not a function
at CALL_NON_FUNCTION_AS_CONSTRUCTOR (native)
at Function.interpretAsType (/Users/Trond/Code/Clients/BinaryMarbles/Sherlock/node_modules/mongoose/lib/schema.js:203:10)
at Schema.path (/Users/Trond/Code/Clients/BinaryMarbles/Sherlock/node_modules/mongoose/lib/schema.js:162:29)
at Schema.add (/Users/Trond/Code/Clients/BinaryMarbles/Sherlock/node_modules/mongoose/lib/schema.js:110:12)
at new Schema (/Users/Trond/Code/Clients/BinaryMarbles/Sherlock/node_modules/mongoose/lib/schema.js:38:10)
at MetricCollector.<anonymous> (/Users/Trond/Code/Clients/BinaryMarbles/Sherlock/lib/metric_collector.coffee:69:29)
{{ 'nyhetsarkiv' | node | assign_to: 'news_archive' }}
<div id='news'>
{% for post in news_archive.recent_posts limit:2 %}
<article>
<section class='article-image'>
<img src="{{ post.data.ingressbilde | resource | attribute: 'url' }}" alt="{{ post.name }}" />
</section>
<section class='article-content'>
<h2>{{ post.name }}</h2>
% bundle exec rake sunspot:reindex
bundle exec rake sunspot:reindex 19.08s user 1.64s system 92% cpu 22.367 total
% rails c
>> DesignResource.count
=> 603
>> q = Sunspot.search DesignResource
>> q.total
=> 336