sogger 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ tmp/*
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Maxim Chernyak
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,33 @@
1
+ Sogger
2
+ ======
3
+
4
+ The word "sogger" was derived by ingeniously abbreviating "Stack Overflow Growler Written in Ruby During a Time of Procrastination When Doing Real Work has Become Unbearable". That is what it is.
5
+
6
+ Install
7
+ -------
8
+
9
+ sudo gem install sogger
10
+
11
+ Run
12
+ ---
13
+
14
+ Get growl all new questions.
15
+
16
+ sogger
17
+
18
+ Growl questions with either ruby or ruby-on-rails tags.
19
+
20
+ sogger ruby ruby-on-rails
21
+
22
+ When you run this command the app will take up your terminal session, and start monumentally logging into your life. That's cause it's unstable. Sometimes it segfaults pretty quickly, sometimes it manages to stay on for hours. Mostly depends on your luck. Please fix if you know how.
23
+
24
+ The Thing Is
25
+ ------------
26
+
27
+ The thing is, currently I'm not very proficient in the area of threads, forking, race conditions, etc. This app has 2 threads. One downloads updates, one growls. Since it's a small app, it's not hard to fix whatever it is I screwed up, so please do if you like the idea.
28
+
29
+ Known Issues
30
+ ------------
31
+
32
+ * It likes to segfault once in a while.
33
+ * RubyCocoa has issues with this app, probably because I use "meow" for growler. You'll see in the log.
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "sogger"
8
+ gem.summary = %Q{Stack overflow growler written in Ruby.}
9
+ gem.description = %Q{Simple tool that growls new questions from Stack Overflow. Supports filtering by tags.}
10
+ gem.email = "max@bitsonnet.com"
11
+ gem.homepage = "http://github.com/maxim/sogger"
12
+ gem.authors = ["Maxim Chernyak"]
13
+ gem.add_dependency "meow"
14
+ gem.add_dependency "nokogiri"
15
+ gem.add_development_dependency "shoulda"
16
+ gem.add_development_dependency "fakeweb"
17
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+ rescue LoadError
21
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
+ end
23
+
24
+ require 'rake/testtask'
25
+ Rake::TestTask.new(:test) do |test|
26
+ test.libs << 'lib' << 'test'
27
+ test.pattern = 'test/**/test_*.rb'
28
+ test.verbose = true
29
+ end
30
+
31
+ begin
32
+ require 'rcov/rcovtask'
33
+ Rcov::RcovTask.new do |test|
34
+ test.libs << 'test'
35
+ test.pattern = 'test/**/test_*.rb'
36
+ test.verbose = true
37
+ end
38
+ rescue LoadError
39
+ task :rcov do
40
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
41
+ end
42
+ end
43
+
44
+ task :test => :check_dependencies
45
+
46
+ task :default => :test
47
+
48
+ require 'rake/rdoctask'
49
+ Rake::RDocTask.new do |rdoc|
50
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "sogger #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'sogger'))
4
+
5
+ sogger = Sogger::Runner.new(:filter => ARGV, :logging => true)
6
+ sogger.log "Filtering tags: #{sogger.filter.inspect}." unless sogger.filter.empty?
7
+ puts "Press CTRL+C to stop..."
8
+ sogger.run
@@ -0,0 +1,8 @@
1
+ require 'tempfile'
2
+ require 'open-uri'
3
+ require 'nokogiri'
4
+ require 'meow'
5
+
6
+ require File.dirname(__FILE__) + "/sogger/question.rb"
7
+ require File.dirname(__FILE__) + "/sogger/sogger.rb"
8
+ require File.dirname(__FILE__) + "/sogger/runner.rb"
@@ -0,0 +1,38 @@
1
+ module Sogger
2
+ class Question
3
+ include Comparable
4
+ attr_accessor :attributes
5
+
6
+ def initialize(attributes = {})
7
+ @attributes = attributes
8
+ end
9
+
10
+ def self.from_xml(xml_element)
11
+ attributes = { :title => xml_element.css('title').text,
12
+ :url => xml_element.css('id').text,
13
+ :tags => xml_element.css('category').map{|c| c['term']},
14
+ :published => DateTime.parse(xml_element.css('published').text) }
15
+ new attributes
16
+ end
17
+
18
+ def title
19
+ @attributes[:title]
20
+ end
21
+
22
+ def url
23
+ @attributes[:url]
24
+ end
25
+
26
+ def tags
27
+ @attributes[:tags]
28
+ end
29
+
30
+ def published
31
+ @attributes[:published]
32
+ end
33
+
34
+ def <=>(other)
35
+ other.published <=> published
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,92 @@
1
+ module Sogger
2
+ class Runner
3
+ class << self
4
+ attr_accessor :update_interval, :growl_interval, :logging
5
+ end
6
+
7
+ attr_reader :filter
8
+
9
+ Runner.update_interval = 60
10
+ Runner.growl_interval = 20
11
+ Runner.logging = true
12
+
13
+ def initialize(options = {})
14
+ options[:update_interval] ||= Runner.update_interval
15
+ options[:growl_interval] ||= Runner.growl_interval
16
+ options[:logging] = options[:logging].nil? ? Runner.logging : options[:logging]
17
+
18
+ Runner.update_interval = options[:update_interval]
19
+ Runner.growl_interval = options[:growl_interval]
20
+ Runner.logging = options[:logging]
21
+
22
+ @filter = [*options[:filter]].compact
23
+ @cached_sogger = Sogger.new
24
+ @remote_sogger = Sogger.new
25
+ @questions_buffer = []
26
+ @growler = Meow.new("Sogger")
27
+ end
28
+
29
+ def run
30
+ updater = Thread.new("updater") do
31
+ while true
32
+ log "Updater: Downloading feed..."
33
+ @remote_sogger.download_feed!
34
+
35
+ new_questions = []
36
+ unless @cached_sogger.questions.empty?
37
+ log "Updater: Comparing feeds..."
38
+ new_questions = (@remote_sogger - @cached_sogger).questions
39
+ end
40
+
41
+ unless new_questions.empty?
42
+ log "Updater: Adding #{new_questions.size} questions to buffer..."
43
+ @questions_buffer += new_questions
44
+ end
45
+
46
+ log "Updater: Caching feed..."
47
+ @remote_sogger.save!
48
+
49
+ log "Updater: Loading cached feed..."
50
+ @cached_sogger.load!
51
+
52
+ log "Updater: Sleeping for #{Runner.update_interval} seconds..."
53
+ sleep Runner.update_interval
54
+ end
55
+ end
56
+
57
+ notifier = Thread.new("notifier") do
58
+ while true
59
+ unless @questions_buffer.empty?
60
+ log "\nNotifier: Filtering questions..."
61
+ while question = @questions_buffer.pop
62
+ if @filter.empty? || question.tags.any?{ |t| @filter.include?(t) }
63
+ log "\nNotifier: Growling..."
64
+ growl(question)
65
+ break
66
+ end
67
+ end
68
+ end
69
+
70
+ sleep Runner.growl_interval
71
+ end
72
+ end
73
+
74
+ trap("INT") do
75
+ puts " Exiting, please wait..."
76
+ [updater, notifier].map(&:kill)
77
+ end
78
+
79
+ [updater, notifier].map(&:join)
80
+ end
81
+
82
+ def growl(question)
83
+ @growler.notify(question.tags.join(', '), question.title) do
84
+ system "open", question.url
85
+ end
86
+ end
87
+
88
+ def log(text)
89
+ puts text if Runner.logging
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,45 @@
1
+ module Sogger
2
+ class Sogger
3
+ class << self; attr_accessor :save_path end
4
+ attr_reader :raw_data
5
+
6
+ SO_FEED_URL = "http://stackoverflow.com/feeds"
7
+ DEFAULT_SAVE_PATH = ::Tempfile.new("sogger_feed.xml").path
8
+ self.save_path = DEFAULT_SAVE_PATH
9
+
10
+ def initialize(questions = [])
11
+ @questions = questions
12
+ end
13
+
14
+ def questions
15
+ @questions.sort
16
+ end
17
+
18
+ def download_feed!
19
+ @raw_data = open(SO_FEED_URL).read
20
+ parse_raw_data
21
+ end
22
+
23
+ def save!
24
+ File.open(self.class.save_path, "w") do |file|
25
+ file.write @raw_data
26
+ end
27
+ end
28
+
29
+ def load!
30
+ @raw_data = File.read(self.class.save_path)
31
+ parse_raw_data
32
+ end
33
+
34
+ def -(other)
35
+ newest_other = other.questions.first
36
+ Sogger.new(questions.select{|q| q < newest_other })
37
+ end
38
+
39
+ private
40
+ def parse_raw_data
41
+ @data = Nokogiri::XML(@raw_data)
42
+ @questions = @data.css('entry').map{ |e| Question.from_xml(e) }
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,74 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{sogger}
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Maxim Chernyak"]
12
+ s.date = %q{2009-12-08}
13
+ s.default_executable = %q{sogger}
14
+ s.description = %q{Simple tool that growls new questions from Stack Overflow. Supports filtering by tags.}
15
+ s.email = %q{max@bitsonnet.com}
16
+ s.executables = ["sogger"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "LICENSE",
25
+ "README.md",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/sogger",
29
+ "lib/sogger.rb",
30
+ "lib/sogger/question.rb",
31
+ "lib/sogger/runner.rb",
32
+ "lib/sogger/sogger.rb",
33
+ "sogger.gemspec",
34
+ "test/fixtures/so_feed_sample.xml",
35
+ "test/helper.rb",
36
+ "test/test_question.rb",
37
+ "test/test_runner.rb",
38
+ "test/test_sogger.rb"
39
+ ]
40
+ s.homepage = %q{http://github.com/maxim/sogger}
41
+ s.rdoc_options = ["--charset=UTF-8"]
42
+ s.require_paths = ["lib"]
43
+ s.rubygems_version = %q{1.3.5}
44
+ s.summary = %q{Stack overflow growler written in Ruby.}
45
+ s.test_files = [
46
+ "test/helper.rb",
47
+ "test/test_question.rb",
48
+ "test/test_runner.rb",
49
+ "test/test_sogger.rb"
50
+ ]
51
+
52
+ if s.respond_to? :specification_version then
53
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
54
+ s.specification_version = 3
55
+
56
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
57
+ s.add_runtime_dependency(%q<meow>, [">= 0"])
58
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
59
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
60
+ s.add_development_dependency(%q<fakeweb>, [">= 0"])
61
+ else
62
+ s.add_dependency(%q<meow>, [">= 0"])
63
+ s.add_dependency(%q<nokogiri>, [">= 0"])
64
+ s.add_dependency(%q<shoulda>, [">= 0"])
65
+ s.add_dependency(%q<fakeweb>, [">= 0"])
66
+ end
67
+ else
68
+ s.add_dependency(%q<meow>, [">= 0"])
69
+ s.add_dependency(%q<nokogiri>, [">= 0"])
70
+ s.add_dependency(%q<shoulda>, [">= 0"])
71
+ s.add_dependency(%q<fakeweb>, [">= 0"])
72
+ end
73
+ end
74
+
@@ -0,0 +1,1150 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <feed xmlns="http://www.w3.org/2005/Atom" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:re="http://purl.org/atompub/rank/1.0">
3
+ <title type="text">Recent Questions - Stack Overflow</title>
4
+ <link rel="self" href="http://stackoverflow.com/feeds" type="application/atom+xml" />
5
+ <link rel="alternate" href="http://stackoverflow.com/questions" type="text/html" />
6
+ <subtitle>most recent 30 from stackoverflow.com</subtitle>
7
+ <updated>2009-12-07T01:03:53Z</updated>
8
+ <id>http://stackoverflow.com/feeds</id>
9
+ <creativeCommons:license>http://www.creativecommons.org/licenses/by-nc/2.5/rdf</creativeCommons:license>
10
+
11
+ <entry>
12
+ <id>http://stackoverflow.com/questions/1856203/windows-and-minibuffer-floating-over-the-frame</id>
13
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
14
+ <title type="text">Windows and Minibuffer floating over the frame</title>
15
+ <category scheme="http://stackoverflow.com/feeds/tags" term="emacs"/>
16
+ <author><name>konr</name></author>
17
+ <link rel="alternate" href="http://stackoverflow.com/questions/1856203/windows-and-minibuffer-floating-over-the-frame" />
18
+ <published>2009-12-06T18:48:09Z</published>
19
+ <updated>2009-12-07T01:03:42Z</updated>
20
+ <summary type="html">
21
+ &lt;p&gt;Hi!&lt;/p&gt;
22
+
23
+ &lt;p&gt;When I start Emacs, its windows and its minibuffer start up floating on the main frame, leaving a lot of empty space (see: &lt;a href=&quot;http://scorciapino.com/pub/fotos/erroemacs.jpg&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;http://scorciapino.com/pub/fotos/erroemacs2.jpg&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;). Any idea of what is going on and how to fix it?&lt;/p&gt;
24
+
25
+ &lt;p&gt;Thanks!&lt;/p&gt;
26
+
27
+ </summary>
28
+ </entry>
29
+
30
+ <entry>
31
+ <id>http://stackoverflow.com/questions/1853653/hidden-features-of-coldfusion</id>
32
+ <re:rank scheme="http://stackoverflow.com">2</re:rank>
33
+ <title type="text">Hidden features of ColdFusion</title>
34
+ <category scheme="http://stackoverflow.com/feeds/tags" term="coldfusion"/><category scheme="http://stackoverflow.com/feeds/tags" term="subjective"/><category scheme="http://stackoverflow.com/feeds/tags" term="hidden-features"/><category scheme="http://stackoverflow.com/feeds/tags" term="easter-eggs"/>
35
+ <author><name>Sergii</name></author>
36
+ <link rel="alternate" href="http://stackoverflow.com/questions/1853653/hidden-features-of-coldfusion" />
37
+ <published>2009-12-05T22:20:49Z</published>
38
+ <updated>2009-12-07T01:02:45Z</updated>
39
+ <summary type="html">
40
+ &lt;p&gt;Let's try to make this for our favourite technology too, how do you think?&lt;/p&gt;
41
+
42
+ &lt;p&gt;Hidden code tricks, unknown usages of known features, application server easter eggs are what are we looking for.&lt;/p&gt;
43
+
44
+ &lt;p&gt;So, proposed rules are simple:&lt;/p&gt;
45
+
46
+ &lt;ul&gt;
47
+ &lt;li&gt;One feature per answer.&lt;/li&gt;
48
+ &lt;li&gt;Code example, if it is the CFML/CFScript feature.&lt;/li&gt;
49
+ &lt;li&gt;Application server name and version where it can be reproduced.&lt;/li&gt;
50
+ &lt;li&gt;Link on the source, if re-posting someone (let's be honest).&lt;/li&gt;
51
+ &lt;li&gt;Any additional requirements/tips to reproduce.&lt;/li&gt;
52
+ &lt;/ul&gt;
53
+
54
+ &lt;p&gt;&lt;hr&gt;&lt;/p&gt;
55
+
56
+ &lt;p&gt;Example (old one, many of us should remember)&lt;/p&gt;
57
+
58
+ &lt;p&gt;&lt;strong&gt;Credits easter egg with custom IE language&lt;/strong&gt;&lt;/p&gt;
59
+
60
+ &lt;p&gt;Open your IE (6+), go to: Tools -&gt; Internet Options -&gt; Languages. &lt;/p&gt;
61
+
62
+ &lt;p&gt;Add a new custom language called &quot;CFML&quot; (without quotes) and shift it to the top of list. &lt;/p&gt;
63
+
64
+ &lt;p&gt;Then log into your ColdFusion Administrator and click on System Information. &lt;/p&gt;
65
+
66
+ &lt;p&gt;Funny pop-up should show up. &lt;/p&gt;
67
+
68
+ &lt;p&gt;It works in CFMX 6, 7.2 and Adobe CF 8 (9 not checked).&lt;/p&gt;
69
+
70
+ </summary>
71
+ </entry>
72
+
73
+ <entry>
74
+ <id>http://stackoverflow.com/questions/1857204/objective-c-problem-with-strings</id>
75
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
76
+ <title type="text">Objective c, problem with strings</title>
77
+ <category scheme="http://stackoverflow.com/feeds/tags" term="nsstring"/><category scheme="http://stackoverflow.com/feeds/tags" term="sqlite"/>
78
+ <author><name>unknown (google)</name></author>
79
+ <link rel="alternate" href="http://stackoverflow.com/questions/1857204/objective-c-problem-with-strings" />
80
+ <published>2009-12-07T00:53:30Z</published>
81
+ <updated>2009-12-07T01:02:36Z</updated>
82
+ <summary type="html">
83
+ &lt;p&gt;Hi,
84
+ first of all please let me say that I am quite new to objective c development. I am writing a small app for personal use for the iphone, but I have some problems executing the following code:&lt;/p&gt;
85
+
86
+ &lt;pre&gt;&lt;code&gt;NSString *sql = [[NSString alloc] initWithFormat:@&quot;select color_r, color_g, color_b from Calendar where ROWID = %@&quot;, [calendarsID objectForKey:[arrayColors objectAtIndex:row]]];
87
+
88
+ sqlite3_stmt *selectstmt;
89
+
90
+ if(sqlite3_prepare_v2(database, sql, -1, &amp;amp;selectstmt, NULL) == SQLITE_OK)
91
+ &lt;/code&gt;&lt;/pre&gt;
92
+
93
+ &lt;p&gt;The compiler tells me that I am passing argument 2 of sqlite3_prepare_v2 from an incompatible pointer type. The program gets, anyhow, compiled and runs but, when it has to execute the code that I've just shown you, it produces an error. It says that there is a syntax error in the query, and the syntax error is just in the last part of the query. Instead of having:&lt;/p&gt;
94
+
95
+ &lt;p&gt;select color_, color_g, color_b from Calendar where ROWID = 63 (for example)&lt;/p&gt;
96
+
97
+ &lt;p&gt;I get strange characters in the place of the last number (63). I guess this is a problem related to string conversion. Can please anyhone help me?&lt;/p&gt;
98
+
99
+ &lt;p&gt;Thank you very much for your attention.
100
+ Alessio&lt;/p&gt;
101
+
102
+ </summary>
103
+ </entry>
104
+
105
+ <entry>
106
+ <id>http://stackoverflow.com/questions/1854623/how-to-get-the-x-y-coordinate-of-a-mouse-click-with-win32-c-on-a-directx-object</id>
107
+ <re:rank scheme="http://stackoverflow.com">1</re:rank>
108
+ <title type="text">How to get the x,y coordinate of a mouse-click with win32 C++ on a directx object?</title>
109
+ <category scheme="http://stackoverflow.com/feeds/tags" term="c++"/><category scheme="http://stackoverflow.com/feeds/tags" term="directx"/><category scheme="http://stackoverflow.com/feeds/tags" term="win32"/>
110
+ <author><name>Chris</name></author>
111
+ <link rel="alternate" href="http://stackoverflow.com/questions/1854623/how-to-get-the-x-y-coordinate-of-a-mouse-click-with-win32-c-on-a-directx-object" />
112
+ <published>2009-12-06T07:14:23Z</published>
113
+ <updated>2009-12-07T01:01:46Z</updated>
114
+ <summary type="html">
115
+ &lt;p&gt;How can I get the x,y coordinate of a mouse click, to see if it is over my menu button drawn by directx? Currently, my codebase has the following mouse-related class that doesn't seem to be able to give me this..I'm not sure how this might work.&lt;/p&gt;
116
+
117
+ &lt;pre&gt;&lt;code&gt;InputMouse::InputMouse() :
118
+ m_LastX(-1),
119
+ m_LastY(-1)
120
+ {
121
+ m_MouseActionEvent.clear();
122
+ }
123
+
124
+ InputMouse::~InputMouse()
125
+ {
126
+
127
+ }
128
+
129
+ void InputMouse::PostUpdate()
130
+ {
131
+ m_CurrentAction.clear();
132
+ }
133
+
134
+ bool InputMouse::IsEventTriggered(int eventNumber)
135
+ {
136
+ for (unsigned int i = 0; i &amp;lt; m_CurrentAction.size(); i++)
137
+ {
138
+ if (m_MouseActionEvent.size() &amp;gt; 0 &amp;amp;&amp;amp; m_MouseActionEvent[m_CurrentAction[i]] == eventNumber)
139
+ {
140
+ return true;
141
+ }
142
+ }
143
+ return false;
144
+ }
145
+
146
+ void InputMouse::AddInputEvent(int action, int eventNumber)
147
+ {
148
+ m_MouseActionEvent[action] = eventNumber;
149
+ }
150
+
151
+ void InputMouse::SetMouseMouse(int x, int y)
152
+ {
153
+ if (m_LastX != -1)
154
+ {
155
+ if (x &amp;gt; m_LastX)
156
+ {
157
+ m_CurrentAction.push_back(MOUSE_RIGHT);
158
+ }
159
+ else if (x &amp;lt; m_LastX)
160
+ {
161
+ m_CurrentAction.push_back(MOUSE_LEFT);
162
+ }
163
+
164
+ if (y &amp;gt; m_LastY)
165
+ {
166
+ m_CurrentAction.push_back(MOUSE_UP);
167
+ }
168
+ else if (y &amp;lt; m_LastY)
169
+ {
170
+ m_CurrentAction.push_back(MOUSE_DOWN);
171
+ }
172
+ }
173
+
174
+ m_LastX = x;
175
+ m_LastY = y;
176
+ }
177
+ &lt;/code&gt;&lt;/pre&gt;
178
+
179
+ </summary>
180
+ </entry>
181
+
182
+ <entry>
183
+ <id>http://stackoverflow.com/questions/1856887/is-there-a-way-to-make-the-code-folding-stay-folded-in-delphi-2010</id>
184
+ <re:rank scheme="http://stackoverflow.com">1</re:rank>
185
+ <title type="text">Is there a way to make the &quot;Code Folding&quot; Stay Folded In Delphi 2010</title>
186
+ <category scheme="http://stackoverflow.com/feeds/tags" term="delphi"/><category scheme="http://stackoverflow.com/feeds/tags" term="delphi-2010"/><category scheme="http://stackoverflow.com/feeds/tags" term="code-folding"/>
187
+ <author><name>Cape Cod Gunny</name></author>
188
+ <link rel="alternate" href="http://stackoverflow.com/questions/1856887/is-there-a-way-to-make-the-code-folding-stay-folded-in-delphi-2010" />
189
+ <published>2009-12-06T22:39:14Z</published>
190
+ <updated>2009-12-07T01:01:38Z</updated>
191
+ <summary type="html">
192
+ &lt;p&gt;I absolutely love the &lt;b&gt;Code Folding&lt;/b&gt; feature inside Delphi 2010. However, each time start Delphi 2010 and reopen my project the code I had peviously folded down is no longer folded. Is there a way to keep the folded code, folded when you close down the IDE?&lt;/p&gt;
193
+
194
+ </summary>
195
+ </entry>
196
+
197
+ <entry>
198
+ <id>http://stackoverflow.com/questions/1857158/adding-floats-with-javascript</id>
199
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
200
+ <title type="text">Adding floats with javascript</title>
201
+ <category scheme="http://stackoverflow.com/feeds/tags" term="javascript"/><category scheme="http://stackoverflow.com/feeds/tags" term="jquery"/>
202
+ <author><name>jpsilvashy</name></author>
203
+ <link rel="alternate" href="http://stackoverflow.com/questions/1857158/adding-floats-with-javascript" />
204
+ <published>2009-12-07T00:36:19Z</published>
205
+ <updated>2009-12-07T01:01:03Z</updated>
206
+ <summary type="html">
207
+ &lt;p&gt;I'm using jQuery, and I want to sum up the values in my table column, everything seems to work fine, but my value is returned a string with all the values added like: &lt;code&gt;123.5013.0012.35&lt;/code&gt;&lt;/p&gt;
208
+
209
+ &lt;p&gt;How can I sum these properly?&lt;/p&gt;
210
+
211
+ &lt;pre&gt;&lt;code&gt;var totals
212
+
213
+ $(&quot;.add&quot;).each(function(i) {
214
+ totals += parseFloat($(this).text()).toFixed(2);
215
+ });
216
+
217
+ console.log(totals);
218
+ &lt;/code&gt;&lt;/pre&gt;
219
+
220
+ </summary>
221
+ </entry>
222
+
223
+ <entry>
224
+ <id>http://stackoverflow.com/questions/1857131/haskell-question-regarding-data</id>
225
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
226
+ <title type="text">Haskell question regarding data</title>
227
+ <category scheme="http://stackoverflow.com/feeds/tags" term="haskell"/>
228
+ <author><name>usr</name></author>
229
+ <link rel="alternate" href="http://stackoverflow.com/questions/1857131/haskell-question-regarding-data" />
230
+ <published>2009-12-07T00:28:27Z</published>
231
+ <updated>2009-12-07T01:00:55Z</updated>
232
+ <summary type="html">
233
+ &lt;p&gt;Code:&lt;/p&gt;
234
+
235
+ &lt;pre&gt;&lt;code&gt;data Exp = Const a | Eq Exp Exp
236
+ &lt;/code&gt;&lt;/pre&gt;
237
+
238
+ &lt;p&gt;I want the &lt;em&gt;Const a&lt;/em&gt; to contain a value of type show so that i can print it later. So in C# i would write:&lt;/p&gt;
239
+
240
+ &lt;pre&gt;&lt;code&gt;class Const : Exp { IShow X; }
241
+ class Eq : Exp { Exp X, Y; }
242
+ &lt;/code&gt;&lt;/pre&gt;
243
+
244
+ &lt;p&gt;How can i do that in Haskell?&lt;/p&gt;
245
+
246
+ </summary>
247
+ </entry>
248
+
249
+ <entry>
250
+ <id>http://stackoverflow.com/questions/1857050/using-apples-automator-to-pass-filenames-to-a-shell-script</id>
251
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
252
+ <title type="text">Using apple's Automator to pass filenames to a shell script.</title>
253
+ <category scheme="http://stackoverflow.com/feeds/tags" term="shell"/><category scheme="http://stackoverflow.com/feeds/tags" term="script"/><category scheme="http://stackoverflow.com/feeds/tags" term="automator"/>
254
+ <author><name>John </name></author>
255
+ <link rel="alternate" href="http://stackoverflow.com/questions/1857050/using-apples-automator-to-pass-filenames-to-a-shell-script" />
256
+ <published>2009-12-06T23:41:19Z</published>
257
+ <updated>2009-12-07T01:00:46Z</updated>
258
+ <summary type="html">
259
+ &lt;p&gt;I have an automator script that I'd like to run on a folder. I want the script to take each file in the folder and run my shell command on it. Automator is set to pass input to stdin, but I don't think I'm using stdin correctly below, can you help please?&lt;/p&gt;
260
+
261
+ &lt;pre&gt;&lt;code&gt;for f in &quot;$@&quot;
262
+ do
263
+ java -Xmx1000m -jar /Users/myprog/myprog.jar $f
264
+ done
265
+ &lt;/code&gt;&lt;/pre&gt;
266
+
267
+ </summary>
268
+ </entry>
269
+
270
+ <entry>
271
+ <id>http://stackoverflow.com/questions/1857222/masks-in-air-with-actionscript-3</id>
272
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
273
+ <title type="text">Masks in AIR with Actionscript 3</title>
274
+ <category scheme="http://stackoverflow.com/feeds/tags" term="air"/><category scheme="http://stackoverflow.com/feeds/tags" term="actionscript-3"/><category scheme="http://stackoverflow.com/feeds/tags" term="as3"/><category scheme="http://stackoverflow.com/feeds/tags" term="mask"/>
275
+ <author><name>webdreamer</name></author>
276
+ <link rel="alternate" href="http://stackoverflow.com/questions/1857222/masks-in-air-with-actionscript-3" />
277
+ <published>2009-12-07T01:00:18Z</published>
278
+ <updated>2009-12-07T01:00:18Z</updated>
279
+ <summary type="html">
280
+ &lt;p&gt;I'm trying to do a mask on a circle shape in ActionScript 3 (I'm using the Flex AIR framework). It has to do with the ecological footprint, each circle representing one earth.
281
+ This ecological footprint picture is inside a container. The problem is that the mask seems to be fixed, though the picture floats. When I scroll the container down, the picture will scroll just fine, but the mask won't, clipping out the top of the picture.&lt;/p&gt;
282
+
283
+ &lt;pre&gt;&lt;code&gt;mask = new UIMovieClip();
284
+ mask.graphics.beginFill(0xFFFFFF);
285
+ mask.graphics.drawRect(radius,radius+radius*2*(1-(ecoWeight-Math.floor(ecoWeight))),1000,1000);
286
+ mask.graphics.endFill();
287
+ earth = new UIMovieClip();
288
+ earth.graphics.beginFill(0xFFFFFF);
289
+ earth.graphics.drawCircle(radius,radius,radius);
290
+ earth.mask=mask;
291
+ earth.graphics.endFill();
292
+ &lt;/code&gt;&lt;/pre&gt;
293
+
294
+ </summary>
295
+ </entry>
296
+
297
+ <entry>
298
+ <id>http://stackoverflow.com/questions/1857191/jquery-is-mouse-still-over-the-element</id>
299
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
300
+ <title type="text">jQuery: is mouse still over the element?</title>
301
+ <category scheme="http://stackoverflow.com/feeds/tags" term="jquery"/><category scheme="http://stackoverflow.com/feeds/tags" term="mouseover"/>
302
+ <author><name>thedp</name></author>
303
+ <link rel="alternate" href="http://stackoverflow.com/questions/1857191/jquery-is-mouse-still-over-the-element" />
304
+ <published>2009-12-07T00:48:05Z</published>
305
+ <updated>2009-12-07T01:00:17Z</updated>
306
+ <summary type="html">
307
+ &lt;p&gt;Hello,&lt;/p&gt;
308
+
309
+ &lt;p&gt;I would like to be able to detect if the mouse is still over the element in the following scenario:&lt;/p&gt;
310
+
311
+ &lt;ol&gt;
312
+ &lt;li&gt;If mouseover then sleep for a few seconds.&lt;/li&gt;
313
+ &lt;li&gt;Once done sleeping check of the mouse is still over the same element.&lt;/li&gt;
314
+ &lt;li&gt;If true then do something.&lt;/li&gt;
315
+ &lt;/ol&gt;
316
+
317
+ &lt;p&gt;How can I achieve #2?&lt;/p&gt;
318
+
319
+ &lt;p&gt;Thank you.&lt;/p&gt;
320
+
321
+ </summary>
322
+ </entry>
323
+
324
+ <entry>
325
+ <id>http://stackoverflow.com/questions/1855773/avoid-slicing-of-exception-types-c</id>
326
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
327
+ <title type="text">Avoid slicing of exception types (C++)</title>
328
+ <category scheme="http://stackoverflow.com/feeds/tags" term="gcc"/><category scheme="http://stackoverflow.com/feeds/tags" term="exceptions"/><category scheme="http://stackoverflow.com/feeds/tags" term="slicing"/><category scheme="http://stackoverflow.com/feeds/tags" term="c++"/><category scheme="http://stackoverflow.com/feeds/tags" term="derived"/>
329
+ <author><name>shojtsy</name></author>
330
+ <link rel="alternate" href="http://stackoverflow.com/questions/1855773/avoid-slicing-of-exception-types-c" />
331
+ <published>2009-12-06T16:08:38Z</published>
332
+ <updated>2009-12-07T01:00:16Z</updated>
333
+ <summary type="html">
334
+ &lt;p&gt;I am designing an exception hierarchy in C++ for my library. The &quot;hierarchy&quot; is 4 classes derived from std::runtime_error. I would like to avoid the &lt;a href=&quot;http://stackoverflow.com/questions/274626/what-is-the-slicing-problem-in-c&quot;&gt;slicing problem&lt;/a&gt; for the exception classes so made the copy constructors protected. But apparently gcc requires to call the copy constructor when throwing instances of them, so complains about the protected copy constructors. Visual C++ 8.0 compiles the same code fine. Are there any portable way to defuse the slicing problem for exception classes? Does the standard say anything about whether an implementation could/should require copy constructor of a class which is to be thrown?&lt;/p&gt;
335
+
336
+ &lt;h3&gt;Edit: Answering my own questions&lt;/h3&gt;
337
+
338
+ &lt;p&gt;Thanks for the answers. The two portable ways I have found to stop clients of my library from catching exceptions incorrectly by value are&lt;/p&gt;
339
+
340
+ &lt;ol&gt;
341
+ &lt;li&gt;Throw exceptions from inside &lt;a href=&quot;http://www.parashift.com/c++-faq-lite/exceptions.html#faq-17.10&quot; rel=&quot;nofollow&quot;&gt;virtual raise&lt;/a&gt; methods of the exception classes, and make copy constructors protected. (Thanks D.Shawley)&lt;/li&gt;
342
+ &lt;li&gt;Throw derived exceptions from the library and publish exception base classes for clients to catch. The base classes could have protected copy constructors, which only allows the good way of catching them. (mentioned &lt;a href=&quot;http://stackoverflow.com/questions/1095225/exception-slicing-is-this-due-to-generated-copy-constructor&quot;&gt;here&lt;/a&gt; for a simmilar question)&lt;/li&gt;
343
+ &lt;/ol&gt;
344
+
345
+ &lt;p&gt;The C++ standard does state that copy constructor needs to be accessible at the point of throw. Visual C++ 8.0 in my configuration violated this part of the standard by not enforcing the presence of the copy constructor. In section 15.1.3:&lt;/p&gt;
346
+
347
+ &lt;blockquote&gt;
348
+ &lt;p&gt;A throw-expression initializes a temporary object, the type of which is determined by removing any top-level cv-qualifiers from the static type of the operand of throw and adjusting the type from “array of T” or “function returning T” to “pointer to T” or “pointer to function returning T”, respectively.&lt;/p&gt;
349
+
350
+ &lt;p&gt;If the use of the temporary object can be eliminated without changing the meaning of the program except for the execution of constructors and destructors associated with the use of the temporary object (12.2), then the exception in the handler can be initialized directly with the argument of the throw expression. When the thrown object is a class object, and the copy constructor used to initialize the temporary copy is not accessible, the program is ill-formed (even when the temporary object could otherwise be eliminated)&lt;/p&gt;
351
+ &lt;/blockquote&gt;
352
+
353
+ </summary>
354
+ </entry>
355
+
356
+ <entry>
357
+ <id>http://stackoverflow.com/questions/386576/multilingual-flex-app</id>
358
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
359
+ <title type="text">Multilingual Flex App</title>
360
+ <category scheme="http://stackoverflow.com/feeds/tags" term="flex"/><category scheme="http://stackoverflow.com/feeds/tags" term="multilanguage"/><category scheme="http://stackoverflow.com/feeds/tags" term="fonts"/><category scheme="http://stackoverflow.com/feeds/tags" term="runtime"/>
361
+ <author><name>unknown (google)</name></author>
362
+ <link rel="alternate" href="http://stackoverflow.com/questions/386576/multilingual-flex-app" />
363
+ <published>2008-12-22T15:53:12Z</published>
364
+ <updated>2009-12-07T01:00:00Z</updated>
365
+ <summary type="html">
366
+ &lt;p&gt;Hi,
367
+ I'm working on a multilingual flex application that has to run in 27+ languages, including asian, hebrew and arabic, as well as all european languages.&lt;/p&gt;
368
+
369
+ &lt;p&gt;We work with an embedded font (Myriad Pro) and have plenty of styles in a css that make use of that embedded font. We've tested with a modified version of Myriad including all non western unicode chars taken from Arial Unicode and it works ok, but the weight of the swf is unacceptable.&lt;/p&gt;
370
+
371
+ &lt;p&gt;We have this two lines in our css..&lt;/p&gt;
372
+
373
+ &lt;pre&gt;&lt;code&gt;@font-face
374
+ {
375
+ src: url(&quot;MyriadPro-Semibold.otf&quot;);
376
+ fontFamily: &quot;Default Font&quot;;
377
+ fontWeight: bold;
378
+ advancedAntiAliasing: true;
379
+ }
380
+ @font-face
381
+ {
382
+ src: url(&quot;MyriadPro-Regular.otf&quot;);
383
+ fontFamily: &quot;Default Font&quot;;
384
+ advancedAntiAliasing: true;
385
+ }
386
+ &lt;/code&gt;&lt;/pre&gt;
387
+
388
+ &lt;p&gt;and the rest of stlyes use the &quot;Default Font&quot; when needed.&lt;/p&gt;
389
+
390
+ &lt;p&gt;What is the best solution for implementing the multilingual apps with runtime loading fonts, while maintaining the current stylesheet?&lt;/p&gt;
391
+
392
+ </summary>
393
+ </entry>
394
+
395
+ <entry>
396
+ <id>http://stackoverflow.com/questions/1321256/type-code-in-to-a-text-input-form-how</id>
397
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
398
+ <title type="text">Type code in to a text input form, how?</title>
399
+ <category scheme="http://stackoverflow.com/feeds/tags" term="php"/><category scheme="http://stackoverflow.com/feeds/tags" term="input"/><category scheme="http://stackoverflow.com/feeds/tags" term="form"/><category scheme="http://stackoverflow.com/feeds/tags" term="echo"/>
400
+ <author><name>Per Magnusson</name></author>
401
+ <link rel="alternate" href="http://stackoverflow.com/questions/1321256/type-code-in-to-a-text-input-form-how" />
402
+ <published>2009-08-24T09:07:43Z</published>
403
+ <updated>2009-12-07T01:00:00Z</updated>
404
+ <summary type="html">
405
+ &lt;p&gt;Hello!
406
+ I want to know the best way of writing out my &quot;$imagepath&quot; in to this input &lt;/p&gt;
407
+
408
+ &lt;p&gt;This is my upload script&lt;/p&gt;
409
+
410
+ &lt;pre&gt;&lt;code&gt;&amp;lt;?php
411
+ if(isset($_POST['submit'])){
412
+ if (isset ($_FILES['new_image'])){
413
+ $imagename = $_FILES['new_image']['name'];
414
+ $source = $_FILES['new_image']['tmp_name'];
415
+ $target = &quot;temporary_images/&quot;.$imagename;
416
+ move_uploaded_file($source, $target);
417
+
418
+ $imagepath = $imagename;
419
+ $save = &quot;temporary_images/&quot; . $imagepath; //This is the new file you saving
420
+ $file = &quot;temporary_images/&quot; . $imagepath; //This is the original file
421
+
422
+ list($width, $height) = getimagesize($file) ;
423
+
424
+ $modwidth = 350;
425
+ $modheight = 100;
426
+
427
+ $tn = imagecreatetruecolor($modwidth, $modheight) ;
428
+ $image = imagecreatefromjpeg($file) ;
429
+ imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
430
+
431
+ imagejpeg($tn, $save, 100) ;
432
+
433
+ $save = &quot;temporary_images/sml_&quot; . $imagepath; //This is the new file you saving
434
+ $file = &quot;temporary_images/&quot; . $imagepath; //This is the original file
435
+
436
+ list($width, $height) = getimagesize($file) ;
437
+
438
+ $modwidth = 80;
439
+ $modheight = 100;
440
+
441
+ $tn = imagecreatetruecolor($modwidth, $modheight) ;
442
+ $image = imagecreatefromjpeg($file) ;
443
+ imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
444
+
445
+ imagejpeg($tn, $save, 100) ;
446
+ echo &quot;Large image: &amp;lt;img src='temporary_images/&quot;.$imagepath.&quot;'&amp;gt;&amp;lt;br&amp;gt;&quot;;
447
+ echo &quot;$imagepath&quot;
448
+ }
449
+ }
450
+ &lt;/code&gt;&lt;/pre&gt;
451
+
452
+ &lt;p&gt;And this is my form&lt;/p&gt;
453
+
454
+ &lt;pre&gt;&lt;code&gt;&amp;lt;form&amp;gt;
455
+ &amp;lt;input name=&quot;animeinput&quot; id=&quot;animeinput&quot; size=&quot;20&quot; class=&quot;textbox&quot;&amp;gt;
456
+ &amp;lt;/form&amp;gt;
457
+ &lt;/code&gt;&lt;/pre&gt;
458
+
459
+ </summary>
460
+ </entry>
461
+
462
+ <entry>
463
+ <id>http://stackoverflow.com/questions/1093731/creating-an-application-print-queue</id>
464
+ <re:rank scheme="http://stackoverflow.com">1</re:rank>
465
+ <title type="text">Creating an application print queue</title>
466
+ <category scheme="http://stackoverflow.com/feeds/tags" term=".net"/><category scheme="http://stackoverflow.com/feeds/tags" term="printing"/>
467
+ <author><name>Dan</name></author>
468
+ <link rel="alternate" href="http://stackoverflow.com/questions/1093731/creating-an-application-print-queue" />
469
+ <published>2009-07-07T17:41:06Z</published>
470
+ <updated>2009-12-07T01:00:00Z</updated>
471
+ <summary type="html">
472
+ &lt;p&gt;We've received a rather tricky business requirement.&lt;/p&gt;
473
+
474
+ &lt;p&gt;&lt;em&gt;Users should be able to store print jobs in the application, until the user explicitly decides to send the jobs to the actual printer.&lt;/em&gt;&lt;/p&gt;
475
+
476
+ &lt;p&gt;The easy solution (the way I see it) is to have a small windows application installed on the clients computers which stores the jobs in a queue locally on the clients computers. Anyone know if such a program exists?&lt;/p&gt;
477
+
478
+ &lt;p&gt;The implement-ourselves option seems rather complicated. Storing the printed files in a database in either, word, pdf, xps or prn format until the user decides to print.
479
+ This option is further complicated by that it should be possible to do it directly from MS Word. Any pointers to how to go about it?&lt;/p&gt;
480
+
481
+ </summary>
482
+ </entry>
483
+
484
+ <entry>
485
+ <id>http://stackoverflow.com/questions/855030/help-linq-to-sql</id>
486
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
487
+ <title type="text">Help Linq to Sql</title>
488
+ <category scheme="http://stackoverflow.com/feeds/tags" term="linq-to-sql"/><category scheme="http://stackoverflow.com/feeds/tags" term="asp.net-mvc"/>
489
+ <author><name>John Prado</name></author>
490
+ <link rel="alternate" href="http://stackoverflow.com/questions/855030/help-linq-to-sql" />
491
+ <published>2009-05-12T21:46:28Z</published>
492
+ <updated>2009-12-07T01:00:00Z</updated>
493
+ <summary type="html">
494
+ &lt;p&gt;Why am I getting a exception when ApplyPropertyChanges???&lt;/p&gt;
495
+
496
+ &lt;p&gt;The code is almost the same when I'm editing a user table but is not working with my news table.&lt;/p&gt;
497
+
498
+ &lt;p&gt;The create, delete and details are all working fine but when I try to edit a news I'm getting the exception below:&lt;/p&gt;
499
+
500
+ &lt;p&gt;&lt;strong&gt;The ObjectStateManager does not contain a ObjectStateEntry 'MagixCMS.Models.noticia'&lt;/strong&gt;&lt;/p&gt;
501
+
502
+ &lt;pre&gt;&lt;code&gt;using System;
503
+ using System.Collections.Generic;
504
+ using System.Linq;
505
+ using System.Web;
506
+
507
+ namespace MagixCMS.Models
508
+ {
509
+ public class NoticiaRepository : INoticiaRepository
510
+ {
511
+ #region INoticiaRepository Members
512
+
513
+ magixcmsEntities _entities = new magixcmsEntities();
514
+
515
+ public noticia CreateNoticia(noticia noticiaToCreate)
516
+ {
517
+ _entities.AddTonoticiaSet(noticiaToCreate);
518
+ _entities.SaveChanges();
519
+ return noticiaToCreate;
520
+ }
521
+
522
+ public void DeletaNoticia(noticia noticiaToDelete)
523
+ {
524
+ var noticiaOriginal = GetNoticia(noticiaToDelete.Id);
525
+ _entities.DeleteObject(noticiaOriginal);
526
+ _entities.SaveChanges();
527
+ }
528
+
529
+ public noticia EditNoticia(noticia noticiaToEdit)
530
+ {
531
+ var noticiaOriginal = GetNoticia(noticiaToEdit.Id);
532
+ _entities.ApplyPropertyChanges(noticiaToEdit.EntityKey.EntitySetName, noticiaToEdit); //EXCEPTION HERE
533
+ _entities.SaveChanges();
534
+ return noticiaToEdit;
535
+ }
536
+
537
+ public noticia GetNoticia(int id)
538
+ {
539
+ return (from c in _entities.noticiaSet where c.Id == id select c).FirstOrDefault();
540
+ }
541
+
542
+ public IEnumerable&amp;lt;noticia&amp;gt; ListNoticias()
543
+ {
544
+ return _entities.noticiaSet.ToList();
545
+ }
546
+
547
+ #endregion
548
+ }
549
+ }
550
+ &lt;/code&gt;&lt;/pre&gt;
551
+
552
+ &lt;p&gt;I google the exception and didn't found much help.&lt;/p&gt;
553
+
554
+ </summary>
555
+ </entry>
556
+
557
+ <entry>
558
+ <id>http://stackoverflow.com/questions/1736314/writing-to-an-xml-file-with-xmllite</id>
559
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
560
+ <title type="text">Writing to an xml file with xmllite?</title>
561
+ <category scheme="http://stackoverflow.com/feeds/tags" term="c++"/><category scheme="http://stackoverflow.com/feeds/tags" term="xml"/><category scheme="http://stackoverflow.com/feeds/tags" term="xmllite"/>
562
+ <author><name>Chris</name></author>
563
+ <link rel="alternate" href="http://stackoverflow.com/questions/1736314/writing-to-an-xml-file-with-xmllite" />
564
+ <published>2009-11-15T01:56:32Z</published>
565
+ <updated>2009-12-07T00:59:40Z</updated>
566
+ <summary type="html">
567
+ &lt;p&gt;I have an xml file which holds a set of &quot;&lt;code&gt;game&lt;/code&gt;&quot; nodes (which contain details about saved gameplay, as you'd save your game on any console game). All of this is contained within a &quot;&lt;code&gt;games&lt;/code&gt;&quot; root node. I'm implementing save functionality to this xml file and wish to be able to append or overwrite a &quot;&lt;code&gt;game&lt;/code&gt;&quot; node and its child nodes within the &quot;&lt;code&gt;games&lt;/code&gt;&quot; root node. &lt;/p&gt;
568
+
569
+ &lt;p&gt;How can this be accomplished with &lt;code&gt;xmllite.dll&lt;/code&gt;?&lt;/p&gt;
570
+
571
+ </summary>
572
+ </entry>
573
+
574
+ <entry>
575
+ <id>http://stackoverflow.com/questions/1856915/nice-way-to-pass-parameters-to-pdo</id>
576
+ <re:rank scheme="http://stackoverflow.com">1</re:rank>
577
+ <title type="text">Nice way to pass parameters to PDO</title>
578
+ <category scheme="http://stackoverflow.com/feeds/tags" term="php"/><category scheme="http://stackoverflow.com/feeds/tags" term="sql"/><category scheme="http://stackoverflow.com/feeds/tags" term="query"/><category scheme="http://stackoverflow.com/feeds/tags" term="parameters"/><category scheme="http://stackoverflow.com/feeds/tags" term="varargs"/>
579
+ <author><name>Ramon</name></author>
580
+ <link rel="alternate" href="http://stackoverflow.com/questions/1856915/nice-way-to-pass-parameters-to-pdo" />
581
+ <published>2009-12-06T22:48:22Z</published>
582
+ <updated>2009-12-07T00:59:29Z</updated>
583
+ <summary type="html">
584
+ &lt;p&gt;Positional parameters become a nightmare when dealing with more than 3 or 4 parameters. Named parameters are verbose. I'm thinking of doing this:&lt;/p&gt;
585
+
586
+ &lt;pre&gt;&lt;code&gt;query(&quot;SELECT * FROM users WHERE username = &quot;, $username, &quot; AND password = &quot;, $password)
587
+ &lt;/code&gt;&lt;/pre&gt;
588
+
589
+ &lt;p&gt;With dynamic parameters (using &lt;code&gt;func_get_args()&lt;/code&gt;), every second one being transformed into a positional parameter. &lt;/p&gt;
590
+
591
+ &lt;p&gt;I've never seen this before and wanted to know if anyone has done this before and why/why not?&lt;/p&gt;
592
+
593
+ </summary>
594
+ </entry>
595
+
596
+ <entry>
597
+ <id>http://stackoverflow.com/questions/1857083/how-functional-language-are-different-from-the-language-implementation-point-of-v</id>
598
+ <re:rank scheme="http://stackoverflow.com">1</re:rank>
599
+ <title type="text">How Functional language are different from the language implementation point of view.</title>
600
+ <category scheme="http://stackoverflow.com/feeds/tags" term="functional-programming"/><category scheme="http://stackoverflow.com/feeds/tags" term="haskell"/><category scheme="http://stackoverflow.com/feeds/tags" term="ml"/><category scheme="http://stackoverflow.com/feeds/tags" term="lisp"/>
601
+ <author><name>Dinesh Simkhada</name></author>
602
+ <link rel="alternate" href="http://stackoverflow.com/questions/1857083/how-functional-language-are-different-from-the-language-implementation-point-of-v" />
603
+ <published>2009-12-06T23:59:49Z</published>
604
+ <updated>2009-12-07T00:59:14Z</updated>
605
+ <summary type="html">
606
+ &lt;p&gt;There is whole new paradigm and needs total change of though of programming when using Functional programming languages compared to the procedural programming language, lazy, higher order functions, purity, monads..etc which we can normally doesn't see in many imperative and oop languages. but how implementation of these languages differs from imperative or oop languages here i mean memory management or the internal stuffs like pointers etc, there is the function languages which runs on top of JVM does this means the internal working of these languages are the same as other languages ?.&lt;/p&gt;
607
+
608
+ </summary>
609
+ </entry>
610
+
611
+ <entry>
612
+ <id>http://stackoverflow.com/questions/1857179/sql-server-replication-consolidation</id>
613
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
614
+ <title type="text">SQL Server Replication, Consolidation</title>
615
+ <category scheme="http://stackoverflow.com/feeds/tags" term="sql-server"/><category scheme="http://stackoverflow.com/feeds/tags" term="replication"/><category scheme="http://stackoverflow.com/feeds/tags" term="consolidation"/>
616
+ <author><name>BrainMan</name></author>
617
+ <link rel="alternate" href="http://stackoverflow.com/questions/1857179/sql-server-replication-consolidation" />
618
+ <published>2009-12-07T00:42:42Z</published>
619
+ <updated>2009-12-07T00:59:13Z</updated>
620
+ <summary type="html">
621
+ &lt;p&gt;How do I consolidate multiple publications into 1 consolidated table on the subscriber? For example. Consider a very simple sales model where we replicate sales data from the stores to the central office.&lt;/p&gt;
622
+
623
+ &lt;pre&gt;&lt;code&gt;Store 1 Sales Table
624
+ =====================
625
+ Item Qty Amt
626
+ =====================
627
+ 111 2 10.00
628
+ 222 1 7.00
629
+ 333 1 12.00
630
+
631
+ Store 2 Sales Table
632
+ =====================
633
+ Item Qty Amt
634
+ =====================
635
+ 111 2 18.00
636
+ 222 1 13.00
637
+ 333 1 4.00
638
+ &lt;/code&gt;&lt;/pre&gt;
639
+
640
+ &lt;p&gt;How do I replicate these two sales publications from the publisher to ONE consolidated sales table at the subscriber:&lt;/p&gt;
641
+
642
+ &lt;pre&gt;&lt;code&gt;Central Office
643
+ ==============================
644
+ Store Item Qty Amt
645
+ ==============================
646
+ 1 111 2 10.00
647
+ 1 222 1 7.00
648
+ 1 333 1 12.00
649
+ 2 111 2 18.00
650
+ 2 222 1 13.00
651
+ 2 333 1 4.00
652
+ &lt;/code&gt;&lt;/pre&gt;
653
+
654
+ </summary>
655
+ </entry>
656
+
657
+ <entry>
658
+ <id>http://stackoverflow.com/questions/1856963/python-soappy-add-header</id>
659
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
660
+ <title type="text">python soappy add header</title>
661
+ <category scheme="http://stackoverflow.com/feeds/tags" term="python"/><category scheme="http://stackoverflow.com/feeds/tags" term="soap"/><category scheme="http://stackoverflow.com/feeds/tags" term="soappy"/><category scheme="http://stackoverflow.com/feeds/tags" term="headers"/>
662
+ <author><name>dandu</name></author>
663
+ <link rel="alternate" href="http://stackoverflow.com/questions/1856963/python-soappy-add-header" />
664
+ <published>2009-12-06T23:13:08Z</published>
665
+ <updated>2009-12-07T00:57:17Z</updated>
666
+ <summary type="html">
667
+ &lt;p&gt;I have the following PHP example code:&lt;/p&gt;
668
+
669
+ &lt;pre&gt;&lt;code&gt;$client = new SoapClient(&quot;http://example.com/example.wsdl&quot;);
670
+
671
+ $h = Array();
672
+ array_push($h, new SoapHeader(&quot;http://example2.com/example2/&quot;, &quot;h&quot;, &quot;v&quot;));
673
+ $client-&amp;gt;__setSoapHeaders($h);
674
+
675
+ $s = $client-&amp;gt;__soapCall('Op', $data);
676
+ &lt;/code&gt;&lt;/pre&gt;
677
+
678
+ &lt;p&gt;My question: what's the SOAPpy equivalent for the SoapHeader() and __setSoapHeaders() part?&lt;/p&gt;
679
+
680
+ &lt;h3&gt;Related question&lt;/h3&gt;
681
+
682
+ &lt;ul&gt;
683
+ &lt;li&gt;&lt;a href=&quot;http://stackoverflow.com/questions/1481313/how-to-add-header-while-making-soap-request-using-soappy&quot;&gt;How to add header while making soap request using soappy&lt;/a&gt;&lt;/li&gt;
684
+ &lt;/ul&gt;
685
+
686
+ </summary>
687
+ </entry>
688
+
689
+ <entry>
690
+ <id>http://stackoverflow.com/questions/1808375/send-and-receive-data-trough-the-power-network</id>
691
+ <re:rank scheme="http://stackoverflow.com">3</re:rank>
692
+ <title type="text">Send and receive data trough the power network</title>
693
+ <category scheme="http://stackoverflow.com/feeds/tags" term="networking"/><category scheme="http://stackoverflow.com/feeds/tags" term="communication"/><category scheme="http://stackoverflow.com/feeds/tags" term="api"/><category scheme="http://stackoverflow.com/feeds/tags" term="library"/>
694
+ <author><name>luvieere</name></author>
695
+ <link rel="alternate" href="http://stackoverflow.com/questions/1808375/send-and-receive-data-trough-the-power-network" />
696
+ <published>2009-11-27T12:06:48Z</published>
697
+ <updated>2009-12-07T00:57:01Z</updated>
698
+ <summary type="html">
699
+ &lt;p&gt;I'm &lt;strong&gt;not&lt;/strong&gt; interested in a hardware solution, I want to know about software that may &quot;read&quot; modulated signal received trough the power supply - some sort of a low-level driver that would access the power signal in a convenient place and demodulate it.&lt;/p&gt;
700
+
701
+ &lt;p&gt;Is there a way to receive signal from the computer's power supply? I'm interested in an API or library that would allow the computer to be seen as a node in a &lt;a href=&quot;http://en.wikipedia.org/wiki/Power%5Fline%5Fcommunication&quot; rel=&quot;nofollow&quot;&gt;Power Line Communication&lt;/a&gt; network and receive data directly through the power cable, without the need for a converter. Is there any active research in this field?&lt;/p&gt;
702
+
703
+ &lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt;&lt;/p&gt;
704
+
705
+ &lt;p&gt;There is software that reads monitors and displays internal component voltages - DC voltage after being converted and filtered by the power supply - now I need is a method of data encoding that would be invariant to conversion and filtering, the original signal embedded in AC being present in some form within the converted DC signal.&lt;/p&gt;
706
+
707
+ </summary>
708
+ </entry>
709
+
710
+ <entry>
711
+ <id>http://stackoverflow.com/questions/1831273/dashcommerce-is-discontinued-where-to-look-for-support</id>
712
+ <re:rank scheme="http://stackoverflow.com">1</re:rank>
713
+ <title type="text">Dashcommerce is discontinued, where to look for support?</title>
714
+ <category scheme="http://stackoverflow.com/feeds/tags" term="storefront"/>
715
+ <author><name>ViktorBergman</name></author>
716
+ <link rel="alternate" href="http://stackoverflow.com/questions/1831273/dashcommerce-is-discontinued-where-to-look-for-support" />
717
+ <published>2009-12-02T07:49:47Z</published>
718
+ <updated>2009-12-07T00:56:54Z</updated>
719
+ <summary type="html">
720
+ &lt;p&gt;I was quite shocked to be welcomed by a simple message on dashCommerce.org yesterday telling me that the product has been discontinued. The projectowner did not even send out an email to the members of the forum informing about this.&lt;/p&gt;
721
+
722
+ &lt;p&gt;So here we stand we with an orphant storefront with no community at all to look for help at.&lt;/p&gt;
723
+
724
+ &lt;p&gt;Does anybody now &lt;strong&gt;why&lt;/strong&gt; they just left the surface of the earth?
725
+ And is there any interest in starting up a forum for the active users?&lt;/p&gt;
726
+
727
+ </summary>
728
+ </entry>
729
+
730
+ <entry>
731
+ <id>http://stackoverflow.com/questions/1857215/audio-libraries-for-digital-signal-processing-in-c</id>
732
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
733
+ <title type="text">Audio libraries for digital signal processing in C#</title>
734
+ <category scheme="http://stackoverflow.com/feeds/tags" term="xaudio2"/><category scheme="http://stackoverflow.com/feeds/tags" term="dsp"/>
735
+ <author><name>Roderick</name></author>
736
+ <link rel="alternate" href="http://stackoverflow.com/questions/1857215/audio-libraries-for-digital-signal-processing-in-c" />
737
+ <published>2009-12-07T00:56:46Z</published>
738
+ <updated>2009-12-07T00:56:46Z</updated>
739
+ <summary type="html">
740
+ &lt;p&gt;Hello all,&lt;/p&gt;
741
+
742
+ &lt;p&gt;My problem is this:&lt;/p&gt;
743
+
744
+ &lt;p&gt;I'm developing a reasonably small application (which needs to be able to grow in the future, but for now, limited functionality will suffice) which recieves audio (16bit mono @ 44.1kHz) and performs fourier transforms and filtering on the data. My experience with all the fields you can imagine this involves is limited, but i've been researching it a fair bit lately and have some understanding. My funding is limited, and I am unable to use any libraries which are under the GPL or similar licences (I need to be able to distruibute this app). For the signal processing I've settled on MathNet libraries, and this seems as though it can handle the bulk of the processing (and I'll write the necessary filters).&lt;/p&gt;
745
+
746
+ &lt;p&gt;The real problem is finding the sound library to use - I was hoping for something in C#, and while it seemed directSound was the best option, I'm reluctant to use it given microsoft has pretty much abandoned it (the company I work for will be upgrading its gear in the near future; I just want to increase the app.'s lifespan as best I can). Do I use XAudio2? I need to be able to record the raw pcm data from a USB device and process it (+write it out to .wav files), and read the data straight from .wav files. &lt;/p&gt;
747
+
748
+ &lt;p&gt;Any help is appreciated&lt;/p&gt;
749
+
750
+ </summary>
751
+ </entry>
752
+
753
+ <entry>
754
+ <id>http://stackoverflow.com/questions/1857214/changing-default-paper-tray-with-adobe-acrobat</id>
755
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
756
+ <title type="text">changing default paper tray with Adobe Acrobat</title>
757
+ <category scheme="http://stackoverflow.com/feeds/tags" term="adobe-acrobat"/><category scheme="http://stackoverflow.com/feeds/tags" term="adobe"/><category scheme="http://stackoverflow.com/feeds/tags" term="acrobat"/>
758
+ <author><name>PNG Programmer</name></author>
759
+ <link rel="alternate" href="http://stackoverflow.com/questions/1857214/changing-default-paper-tray-with-adobe-acrobat" />
760
+ <published>2009-12-07T00:56:23Z</published>
761
+ <updated>2009-12-07T00:56:23Z</updated>
762
+ <summary type="html">
763
+ &lt;p&gt;Does anybody know how you can change the default printer tray when printing from an Adobe Acrobat object? There are properties to change duplex settings but not paper tray.&lt;/p&gt;
764
+
765
+ </summary>
766
+ </entry>
767
+
768
+ <entry>
769
+ <id>http://stackoverflow.com/questions/1857213/linq-query-expression-translator</id>
770
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
771
+ <title type="text">LINQ query expression translator?</title>
772
+ <category scheme="http://stackoverflow.com/feeds/tags" term="c#"/><category scheme="http://stackoverflow.com/feeds/tags" term="linq"/><category scheme="http://stackoverflow.com/feeds/tags" term="query-expressions"/>
773
+ <author><name>naasking</name></author>
774
+ <link rel="alternate" href="http://stackoverflow.com/questions/1857213/linq-query-expression-translator" />
775
+ <published>2009-12-07T00:56:03Z</published>
776
+ <updated>2009-12-07T00:56:03Z</updated>
777
+ <summary type="html">
778
+ &lt;p&gt;I'm adding a LINQ interface to some custom objects, but the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb546090.aspx&quot; rel=&quot;nofollow&quot;&gt;C# compiler fails on type inference&lt;/a&gt;. However, I can write the equivalent query using the raw extension methods and type inference succeeds, so I'm not sure how the compiler is translating the query expression into extension method calls.&lt;/p&gt;
779
+
780
+ &lt;p&gt;Is there a tool or compiler flag so I can view what the compiler is generating from my query expression so I figure this out?&lt;/p&gt;
781
+
782
+ &lt;p&gt;This code is in an open source project, so I can provide links to source if that's helpful. Slight variations on the type signatures of the extension methods avoid this type inference error, but these variants don't have the semantics I'm after.&lt;/p&gt;
783
+
784
+ </summary>
785
+ </entry>
786
+
787
+ <entry>
788
+ <id>http://stackoverflow.com/questions/1857098/is-there-a-way-to-get-a-validationsummary-to-work-with-client-side-validators</id>
789
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
790
+ <title type="text">Is there a way to get a ValidationSummary to work with client-side validators?</title>
791
+ <category scheme="http://stackoverflow.com/feeds/tags" term=".net"/><category scheme="http://stackoverflow.com/feeds/tags" term="asp.net"/><category scheme="http://stackoverflow.com/feeds/tags" term="validation"/><category scheme="http://stackoverflow.com/feeds/tags" term="c#"/><category scheme="http://stackoverflow.com/feeds/tags" term="form-validation"/>
792
+ <author><name>David</name></author>
793
+ <link rel="alternate" href="http://stackoverflow.com/questions/1857098/is-there-a-way-to-get-a-validationsummary-to-work-with-client-side-validators" />
794
+ <published>2009-12-07T00:05:35Z</published>
795
+ <updated>2009-12-07T00:55:40Z</updated>
796
+ <summary type="html">
797
+ &lt;p&gt;The .NET ValidationSummary control aggregates error messages from validators that are fired on postback. Is there some way of getting it to also show error messages from client-side validators?&lt;/p&gt;
798
+
799
+ &lt;p&gt;The problem I am working on is that on a long page, it is possible to click a submit button, have some client-side validators fail, but never see the error message. I would like to have a validation summary near the button so that the user is never left without feedback.&lt;/p&gt;
800
+
801
+ &lt;p&gt;I would like any standard .NET validators that have client-side validation to be reflected in the validation summary, but I am most concerned with getting the RequiredFieldValidators to work.&lt;/p&gt;
802
+
803
+ &lt;p&gt;I could hack it so that on clicking the button would automatically, after a short delay, display a general message telling the user to check for errors on the page. This would work for when no postback has occurred, but it would be ugly.&lt;/p&gt;
804
+
805
+ </summary>
806
+ </entry>
807
+
808
+ <entry>
809
+ <id>http://stackoverflow.com/questions/1856654/git-how-to-add-commit-removals-made-via-vanilla-rm</id>
810
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
811
+ <title type="text">git: how to add/commit removals made via vanilla rm?</title>
812
+ <category scheme="http://stackoverflow.com/feeds/tags" term="git"/><category scheme="http://stackoverflow.com/feeds/tags" term="rm"/><category scheme="http://stackoverflow.com/feeds/tags" term="scm"/><category scheme="http://stackoverflow.com/feeds/tags" term="dvcs"/>
813
+ <author><name>kch</name></author>
814
+ <link rel="alternate" href="http://stackoverflow.com/questions/1856654/git-how-to-add-commit-removals-made-via-vanilla-rm" />
815
+ <published>2009-12-06T21:23:12Z</published>
816
+ <updated>2009-12-07T00:55:30Z</updated>
817
+ <summary type="html">
818
+ &lt;p&gt;I deleted a bunch of files / directories from a git repository using &lt;code&gt;rm&lt;/code&gt;, the Finder, etc.&lt;/p&gt;
819
+
820
+ &lt;p&gt;I'm looking for a git command that'll record these to the index as marked for removal. (As if I had called &lt;code&gt;git rm&lt;/code&gt; on them.)&lt;/p&gt;
821
+
822
+ &lt;p&gt;I understand &lt;code&gt;git add -u&lt;/code&gt; will do this, along with a bunch of other things. I'd like my command to exclusively handle removals.&lt;/p&gt;
823
+
824
+ </summary>
825
+ </entry>
826
+
827
+ <entry>
828
+ <id>http://stackoverflow.com/questions/1856794/how-would-you-convert-this-mutable-tree-into-an-immutable-one</id>
829
+ <re:rank scheme="http://stackoverflow.com">1</re:rank>
830
+ <title type="text">How would you convert this mutable tree into an immutable one?</title>
831
+ <category scheme="http://stackoverflow.com/feeds/tags" term="f#"/><category scheme="http://stackoverflow.com/feeds/tags" term="tree"/><category scheme="http://stackoverflow.com/feeds/tags" term="mutable"/><category scheme="http://stackoverflow.com/feeds/tags" term="immutable"/>
832
+ <author><name>gradbot</name></author>
833
+ <link rel="alternate" href="http://stackoverflow.com/questions/1856794/how-would-you-convert-this-mutable-tree-into-an-immutable-one" />
834
+ <published>2009-12-06T22:12:10Z</published>
835
+ <updated>2009-12-07T00:55:19Z</updated>
836
+ <summary type="html">
837
+ &lt;h2&gt;How would you convert type Node into an immutable tree?&lt;/h2&gt;
838
+
839
+ &lt;p&gt;This class implements a range tree that does not allow overlapping or adjacent ranges and instead joins them. For example if the root node is &lt;code&gt;{min = 10; max = 20}&lt;/code&gt; then it's right child and all its grandchildren must have a min and max value greater than 21. The max value of a range must be greater than or equal to the min. I included a test function so you can run this as is and it will dump out any cases that fail. &lt;/p&gt;
840
+
841
+ &lt;p&gt;I recommend starting with the Insert method to read this code.&lt;/p&gt;
842
+
843
+ &lt;pre&gt;&lt;code&gt;module StackOverflowQuestion
844
+
845
+ open System
846
+
847
+ type Range =
848
+ { min : int64; max : int64 }
849
+ with
850
+ override this.ToString() =
851
+ sprintf &quot;(%d, %d)&quot; this.min this.max
852
+
853
+ [&amp;lt;AllowNullLiteralAttribute&amp;gt;]
854
+ type Node(left:Node, right:Node, range:Range) =
855
+ let mutable left = left
856
+ let mutable right = right
857
+ let mutable range = range
858
+
859
+
860
+ // Symmetric to clean right
861
+ let rec cleanLeft(node : Node) =
862
+ if node.Left = null then
863
+ ()
864
+ elif range.max &amp;lt; node.Left.Range.min - 1L then
865
+ cleanLeft(node.Left)
866
+ elif range.max &amp;lt;= node.Left.Range.max then
867
+ range &amp;lt;- {min = range.min; max = node.Left.Range.max}
868
+ node.Left &amp;lt;- node.Left.Right
869
+ else
870
+ node.Left &amp;lt;- node.Left.Right
871
+ cleanLeft(node)
872
+
873
+ // Clean right deals with merging when the node to merge with is not on the
874
+ // left outside of the tree. It travels right inside the tree looking for an
875
+ // overlapping node. If it finds one it merges the range and replaces the
876
+ // node with its left child thereby deleting it. If it finds a subset node
877
+ // it replaces it with its left child, checks it and continues looking right.
878
+ let rec cleanRight(node : Node) =
879
+ if node.Right = null then
880
+ ()
881
+ elif range.min &amp;gt; node.Right.Range.max + 1L then
882
+ cleanRight(node.Right)
883
+ elif range.min &amp;gt;= node.Right.Range.min then
884
+ range &amp;lt;- {min = node.Right.Range.min; max = range.max}
885
+ node.Right &amp;lt;- node.Right.Left
886
+ else
887
+ node.Right &amp;lt;- node.Right.Left
888
+ cleanRight(node)
889
+
890
+ // Merger left is called whenever the min value of a node decreases.
891
+ // It handles the case of left node overlap/subsets and merging/deleting them.
892
+ // When no more overlaps are found on the left nodes it calls clean right.
893
+ let rec mergeLeft(node : Node) =
894
+ if node.Left = null then
895
+ ()
896
+ elif range.min &amp;lt;= node.Left.Range.min - 1L then
897
+ node.Left &amp;lt;- node.Left.Left
898
+ mergeLeft(node)
899
+ elif range.min &amp;lt;= node.Left.Range.max + 1L then
900
+ range &amp;lt;- {min = node.Left.Range.min; max = range.max}
901
+ node.Left &amp;lt;- node.Left.Left
902
+ else
903
+ cleanRight(node.Left)
904
+
905
+ // Symmetric to merge left
906
+ let rec mergeRight(node : Node) =
907
+ if node.Right = null then
908
+ ()
909
+ elif range.max &amp;gt;= node.Right.Range.max + 1L then
910
+ node.Right &amp;lt;- node.Right.Right
911
+ mergeRight(node)
912
+ elif range.max &amp;gt;= node.Right.Range.min - 1L then
913
+ range &amp;lt;- {min = range.min; max = node.Right.Range.max}
914
+ node.Right &amp;lt;- node.Right.Right
915
+ else
916
+ cleanLeft(node.Right)
917
+
918
+
919
+ let (|Before|After|BeforeOverlap|AfterOverlap|Superset|Subset|) r =
920
+ if r.min &amp;gt; range.max + 1L then After
921
+ elif r.min &amp;gt;= range.min then
922
+ if r.max &amp;lt;= range.max then Subset
923
+ else AfterOverlap
924
+ elif r.max &amp;lt; range.min - 1L then Before
925
+ elif r.max &amp;lt;= range.max then
926
+ if r.min &amp;gt;= range.min then Subset
927
+ else BeforeOverlap
928
+ else Superset
929
+
930
+ member this.Insert r =
931
+ match r with
932
+ | After -&amp;gt;
933
+ if right = null then
934
+ right &amp;lt;- Node(null, null, r)
935
+ else
936
+ right.Insert(r)
937
+ | AfterOverlap -&amp;gt;
938
+ range &amp;lt;- {min = range.min; max = r.max}
939
+ mergeRight(this)
940
+ | Before -&amp;gt;
941
+ if left = null then
942
+ left &amp;lt;- Node(null, null, r)
943
+ else
944
+ left.Insert(r)
945
+ | BeforeOverlap -&amp;gt;
946
+ range &amp;lt;- {min = r.min; max = range.max}
947
+ mergeLeft(this)
948
+ | Superset -&amp;gt;
949
+ range &amp;lt;- r
950
+ mergeLeft(this)
951
+ mergeRight(this)
952
+ | Subset -&amp;gt; ()
953
+
954
+ member this.Left with get() : Node = left and set(x) = left &amp;lt;- x
955
+ member this.Right with get() : Node = right and set(x) = right &amp;lt;- x
956
+ member this.Range with get() : Range = range and set(x) = range &amp;lt;- x
957
+
958
+ static member op_Equality (a : Node, b : Node) =
959
+ a.Range = b.Range
960
+
961
+ override this.ToString() =
962
+ sprintf &quot;%A&quot; this.Range
963
+
964
+ type RangeTree() =
965
+ let mutable root = null
966
+
967
+ member this.Add(range) =
968
+ if root = null then
969
+ root &amp;lt;- Node(null, null, range)
970
+ else
971
+ root.Insert(range)
972
+
973
+ static member fromArray(values : Range seq) =
974
+ let tree = new RangeTree()
975
+ values |&amp;gt; Seq.iter (fun value -&amp;gt; tree.Add(value))
976
+ tree
977
+
978
+ member this.Seq
979
+ with get() =
980
+ let rec inOrder(node : Node) =
981
+ seq {
982
+ if node &amp;lt;&amp;gt; null then
983
+ yield! inOrder node.Left
984
+ yield {min = node.Range.min; max = node.Range.max}
985
+ yield! inOrder node.Right
986
+ }
987
+ inOrder root
988
+
989
+ let TestRange() =
990
+ printf &quot;\n&quot;
991
+
992
+ let source(n) =
993
+ let rnd = new Random(n)
994
+ let rand x = rnd.NextDouble() * float x |&amp;gt; int64
995
+ let rangeRnd() =
996
+ let a = rand 1500
997
+ {min = a; max = a + rand 15}
998
+ [|for n in 1 .. 50 do yield rangeRnd()|]
999
+
1000
+ let shuffle n (array:_[]) =
1001
+ let rnd = new Random(n)
1002
+ for i in 0 .. array.Length - 1 do
1003
+ let n = rnd.Next(i)
1004
+ let temp = array.[i]
1005
+ array.[i] &amp;lt;- array.[n]
1006
+ array.[n] &amp;lt;- temp
1007
+ array
1008
+
1009
+ let testRangeAdd n i =
1010
+ let dataSet1 = source (n+0)
1011
+ let dataSet2 = source (n+1)
1012
+ let dataSet3 = source (n+2)
1013
+ let result1 = Array.concat [dataSet1; dataSet2; dataSet3] |&amp;gt; shuffle (i+3) |&amp;gt; RangeTree.fromArray
1014
+ let result2 = Array.concat [dataSet2; dataSet3; dataSet1] |&amp;gt; shuffle (i+4) |&amp;gt; RangeTree.fromArray
1015
+ let result3 = Array.concat [dataSet3; dataSet1; dataSet2] |&amp;gt; shuffle (i+5) |&amp;gt; RangeTree.fromArray
1016
+ let test1 = (result1.Seq, result2.Seq) ||&amp;gt; Seq.forall2 (fun a b -&amp;gt; a.min = b.min &amp;amp;&amp;amp; a.max = b.max)
1017
+ let test2 = (result2.Seq, result3.Seq) ||&amp;gt; Seq.forall2 (fun a b -&amp;gt; a.min = b.min &amp;amp;&amp;amp; a.max = b.max)
1018
+ let test3 = (result3.Seq, result1.Seq) ||&amp;gt; Seq.forall2 (fun a b -&amp;gt; a.min = b.min &amp;amp;&amp;amp; a.max = b.max)
1019
+
1020
+ let print dataSet =
1021
+ dataSet |&amp;gt; Seq.iter (fun r -&amp;gt; printf &quot;%s &quot; &amp;lt;| string r)
1022
+
1023
+ if not (test1 &amp;amp;&amp;amp; test2 &amp;amp;&amp;amp; test3) then
1024
+ printf &quot;\n\nTest# %A: &quot; n
1025
+ printf &quot;\nSource 1: %A: &quot; (n+0)
1026
+ dataSet1 |&amp;gt; print
1027
+ printf &quot;\nSource 2: %A: &quot; (n+1)
1028
+ dataSet2 |&amp;gt; print
1029
+ printf &quot;\nSource 3: %A: &quot; (n+2)
1030
+ dataSet3 |&amp;gt; print
1031
+ printf &quot;\nResult 1: %A: &quot; (n+0)
1032
+ result1.Seq |&amp;gt; print
1033
+ printf &quot;\nResult 2: %A: &quot; (n+1)
1034
+ result2.Seq |&amp;gt; print
1035
+ printf &quot;\nResult 3: %A: &quot; (n+2)
1036
+ result3.Seq |&amp;gt; print
1037
+ ()
1038
+
1039
+ for i in 1 .. 10 do
1040
+ for n in 1 .. 1000 do
1041
+ testRangeAdd n i
1042
+ printf &quot;\n%d&quot; (i * 1000)
1043
+
1044
+ printf &quot;\nDone&quot;
1045
+
1046
+ TestRange()
1047
+
1048
+ System.Console.ReadLine() |&amp;gt; ignore
1049
+ &lt;/code&gt;&lt;/pre&gt;
1050
+
1051
+ &lt;p&gt;Test cases for Range&lt;/p&gt;
1052
+
1053
+ &lt;pre&gt;&lt;code&gt;After (11, 14) | | &amp;lt;--&amp;gt;
1054
+ AfterOverlap (10, 14) | |&amp;lt;---&amp;gt;
1055
+ AfterOverlap ( 9, 14) | +----&amp;gt;
1056
+ AfterOverlap ( 6, 14) |&amp;lt;--+----&amp;gt;
1057
+ &quot;Test Case&quot; ( 5, 9) +---+
1058
+ BeforeOverlap ( 0, 8) &amp;lt;----+--&amp;gt;|
1059
+ BeforeOverlap ( 0, 5) &amp;lt;----+ |
1060
+ BeforeOverlap ( 0, 4) &amp;lt;---&amp;gt;| |
1061
+ Before ( 0, 3) &amp;lt;--&amp;gt; | |
1062
+ Superset ( 4, 10) &amp;lt;+---+&amp;gt;
1063
+ Subset ( 5, 9) +---+
1064
+ Subset ( 6, 8) |&amp;lt;-&amp;gt;|
1065
+ &lt;/code&gt;&lt;/pre&gt;
1066
+
1067
+ </summary>
1068
+ </entry>
1069
+
1070
+ <entry>
1071
+ <id>http://stackoverflow.com/questions/1832522/telerik-radcombobox-javascript-api-problem</id>
1072
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
1073
+ <title type="text">Telerik RadComboBox javascript API problem</title>
1074
+ <category scheme="http://stackoverflow.com/feeds/tags" term="javascript"/><category scheme="http://stackoverflow.com/feeds/tags" term="asp.net"/><category scheme="http://stackoverflow.com/feeds/tags" term="telerik"/>
1075
+ <author><name>Grubl3r</name></author>
1076
+ <link rel="alternate" href="http://stackoverflow.com/questions/1832522/telerik-radcombobox-javascript-api-problem" />
1077
+ <published>2009-12-02T12:07:05Z</published>
1078
+ <updated>2009-12-07T00:54:50Z</updated>
1079
+ <summary type="html">
1080
+ &lt;p&gt;Hi all, I've been having a problem using the javascript API of the RadComboBox from Telerik. And no I don't have the power to switch over from Telerik to jQuery or another framework.. Suffice to say I have hardly any hair left on my head now :P&lt;/p&gt;
1081
+
1082
+ &lt;p&gt;&lt;strong&gt;In a nutshell&lt;/strong&gt; I want to grab the selected index of one RadComboBox, and update another RadComboBox to this index. Eg. selecting a value in the first RCB automatically updates the second on the client side. My problem really is that I can't find a way to set the index on the second RCB, even though the docs says there is an easy way to do it .. (you heard that one before right :) &lt;/p&gt;
1083
+
1084
+ &lt;p&gt;I've followed the API docs at this page (&lt;a href=&quot;http://www.telerik.com/help/aspnet/combobox/combo%5Fclient%5Fmodel.html&quot; rel=&quot;nofollow&quot;&gt;telerik docs&lt;/a&gt;), and also used the javascript debugger in IE8 and the excellent FireBug in Firefox. I'm using Telerik.Web.UI assembly version 2009.2.826.20&lt;/p&gt;
1085
+
1086
+ &lt;p&gt;&lt;strong&gt;I don't need full source for a solution, but a nudge in the right direction would be much appreciated! :)&lt;/strong&gt;&lt;/p&gt;
1087
+
1088
+ &lt;p&gt;Here's some example code I cooked together: &lt;/p&gt;
1089
+
1090
+ &lt;p&gt;&lt;hr&gt;&lt;/p&gt;
1091
+
1092
+ &lt;pre&gt;&lt;code&gt; &amp;lt;form id=&quot;form1&quot; runat=&quot;server&quot;&amp;gt;
1093
+ &amp;lt;asp:ScriptManager ID=&quot;ScriptManager1&quot; runat=&quot;server&quot; /&amp;gt;
1094
+
1095
+ &amp;lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot;&amp;gt;
1096
+ function masterChanged(item)
1097
+ {
1098
+ var detailCB = &amp;lt;%= DetailCB.ClientID %&amp;gt;;
1099
+
1100
+ var index = item.get_selectedIndex();
1101
+ detailCB.SetSelected(index); //method does not exist, but should according to the docs..
1102
+
1103
+ }
1104
+ &amp;lt;/script&amp;gt;
1105
+
1106
+ &amp;lt;div&amp;gt;
1107
+ &amp;lt;telerik:RadComboBox ID=&quot;MasterCB&quot; runat=&quot;server&quot; OnClientSelectedIndexChanged=&quot;masterChanged&quot;&amp;gt;
1108
+ &amp;lt;Items&amp;gt;
1109
+ &amp;lt;telerik:RadComboBoxItem Text=&quot;One&quot; Value=&quot;1&quot; runat=&quot;server&quot; /&amp;gt;
1110
+ &amp;lt;telerik:RadComboBoxItem Text=&quot;Two&quot; Value=&quot;2&quot; runat=&quot;server&quot; /&amp;gt;
1111
+ &amp;lt;telerik:RadComboBoxItem Text=&quot;Three&quot; Value=&quot;3&quot; runat=&quot;server&quot; /&amp;gt;
1112
+ &amp;lt;/Items&amp;gt;
1113
+ &amp;lt;/telerik:RadComboBox&amp;gt;
1114
+ &amp;lt;/div&amp;gt;
1115
+
1116
+ &amp;lt;div&amp;gt;
1117
+ &amp;lt;telerik:RadComboBox ID=&quot;DetailCB&quot; runat=&quot;server&quot;&amp;gt;
1118
+ &amp;lt;Items&amp;gt;
1119
+ &amp;lt;telerik:RadComboBoxItem Text=&quot;One&quot; Value=&quot;1&quot; runat=&quot;server&quot; /&amp;gt;
1120
+ &amp;lt;telerik:RadComboBoxItem Text=&quot;Two&quot; Value=&quot;2&quot; runat=&quot;server&quot; /&amp;gt;
1121
+ &amp;lt;telerik:RadComboBoxItem Text=&quot;Three&quot; Value=&quot;3&quot; runat=&quot;server&quot; /&amp;gt;
1122
+ &amp;lt;/Items&amp;gt;
1123
+ &amp;lt;/telerik:RadComboBox&amp;gt;
1124
+ &amp;lt;/div&amp;gt;
1125
+ &amp;lt;/form&amp;gt;
1126
+ &lt;/code&gt;&lt;/pre&gt;
1127
+
1128
+ &lt;p&gt;I don't need full source for a solution, but a kick in the right direction would be much appreciated! :)&lt;/p&gt;
1129
+
1130
+ </summary>
1131
+ </entry>
1132
+
1133
+ <entry>
1134
+ <id>http://stackoverflow.com/questions/544162/looking-for-a-datagridview-that-allows-grouping</id>
1135
+ <re:rank scheme="http://stackoverflow.com">0</re:rank>
1136
+ <title type="text">Looking for a DataGridView that allows grouping</title>
1137
+ <category scheme="http://stackoverflow.com/feeds/tags" term="vb.net"/><category scheme="http://stackoverflow.com/feeds/tags" term="controls"/><category scheme="http://stackoverflow.com/feeds/tags" term="c#"/>
1138
+ <author><name>ohu812</name></author>
1139
+ <link rel="alternate" href="http://stackoverflow.com/questions/544162/looking-for-a-datagridview-that-allows-grouping" />
1140
+ <published>2009-02-13T00:07:30Z</published>
1141
+ <updated>2009-12-07T00:54:45Z</updated>
1142
+ <summary type="html">
1143
+ &lt;p&gt;Basically I'm looking for a control that allows for grouping in a DataGridView control that can also be editted (I.E. somthing like DataGridView and TreeView into a single control). &lt;/p&gt;
1144
+
1145
+ &lt;p&gt;Thanks in advance.&lt;/p&gt;
1146
+
1147
+ </summary>
1148
+ </entry>
1149
+
1150
+ </feed>