Skip to content

Instantly share code, notes, and snippets.

View BFalkner's full-sized avatar

Brennan Falkner BFalkner

View GitHub Profile
{
"auto_complete_commit_on_tab": true,
"color_scheme": "Packages/Color Scheme - Default/Solarized (Light).tmTheme",
"default_line_ending": "unix",
"ensure_newline_at_eof_on_save": true,
"folder_exclude_patterns":
[
".svn",
".git",
".hg",
file added adapters/.unison.session.js.0fdafcf26b5d53a778ebfb5b50061b12.unison.tmp
file changed adapters/.unison.session.js.0fdafcf26b5d53a778ebfb5b50061b12.unison.tmp
file changed adapters/.unison.session.js.0fdafcf26b5d53a778ebfb5b50061b12.unison.tmp
Build successful - 7217ms.
Slowest Trees | Total
-------------------------------+----------------
TreeMerger (stylesAndVendor) | 1701ms
StaticCompiler | 1646ms
> this._pendingFetch instanceof Ember.Map
true
> this._pendingFetch.keys.list
[(subclass of DS.Model), "type"]
> this._pendingFetch.values
Object {ember249: Array[1], st269: "value"}
> this._pendingFetch.forEach(function(k, v) { console.debug(k, v); })
[Object, _super: function, nextObject: function, firstObject: undefined, lastObject: undefined, contains: function…] (subclass of DS.Model)
value type
undefined
Server Error in '/' Application.
Value cannot be null.
Parameter name: row
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: row
Source Error:
[Component]
public class CSVList : List<string>
{
// ReSharper disable UnusedPrivateMember
private string Value
// ReSharper restore UnusedPrivateMember
{
get { return string.Join(",", this.ToArray()); }
set
{
var conf = new MapConfiguration();
conf.DefaultStore = new DatabaseStore(conf, Settings.Database);
conf.Initialize();
DataContext = new DataContext(conf);
Keywords = Request.Form["Keywords"]
.Replace("\r\n", ",")
.Split(',')
.Where(k => k.Length > 0)
.Select(k => k.Trim()).ToList()
def self.find_by_probability(user)
links = Link.find :all, :include => :votes
users = User.select { |u| u.votes.id }.to_a
links.map do |link|
link.probability = bayes(
link,
users_with_link(link, users),
proc{|e, h| common_links(e, user, h) / all_links(e, user, h) },
proc{|e| e.votes.size.to_f / links.size },

Notes

The original subs actually making a query with printing the query, so no real queries here either.

The 'transaction' from the original doesn't appear to do anything except close over the connection argument. I didn't implement any transactional functionality because the original didn't appear to have any.

It doesn't make sense to memoize the non-query stuff and always run the query which is going to be your slowest thing. It also doesn't make sense to memoize inserts which always need to run.

Output

class RenameThingsToRecords < ActiveRecord::Migration
def self.up
command = OrderedHash.new
command['renameCollection'] = "#{MongoMapper.database.name}.things"
command['to'] = "#{MongoMapper.database.name}.records"
MongoMapper.connection.db('admin').command(command)
end
def self.down
command = OrderedHash.new