Skip to content

Instantly share code, notes, and snippets.

@marciol
marciol / designer.html
Created November 17, 2014 13:33
designer
<link rel="import" href="../google-map/google-map.html">
<link rel="import" href="../google-map/google-map-directions.html">
<link rel="import" href="../google-map/google-map-search.html">
<link rel="import" href="../yt-video/yt-search-video.html">
<link rel="import" href="../smoothie-chart/smoothie-chart.html">
<link rel="import" href="../topeka-elements/category-icons.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../speech-mic/speech-mic.html">
<polymer-element name="my-element">

I'm hunting for the best solution on how to handle keeping large sets of DB records "sorted" in a performant manner.

Problem Description

Most of us have work on projects at some point where we have needed to have ordered lists of objects. Whether it be a to-do list sorted by priority, or a list of documents that a user can sort in whatever order they want.

A traditional approach for this on a Rails project is to use something like the acts_as_list gem, or something similar. These systems typically add some sort of "postion" or "sort order" column to each record, which is then used when querying out the records in a traditional order by position SQL query.

This approach seems to work fine for smaller datasets, but can be hard to manage on large data sets with hundreds (or thousands) of records needing to be sorted. Changing the sort position of even a single object will require updating every single record in the database that is in the same sort group. This requires potentially thousands of wri

@marciol
marciol / app.fsx
Last active August 29, 2015 14:06 — forked from eulerfx/app.fsx
#load "HyperF.fsx"
open HyperF
open Route
let service =
[
Get("/resource/:id") => fun (req,ri) -> "hello world!" |> HttpRes.plainText
@marciol
marciol / custom_plan.rb
Created October 4, 2013 22:36
Require pry-byebug from outside of bundle with zeus
require 'zeus/rails'
class CustomPlan < Zeus::Rails
# def my_custom_command
# # see https://github.com/burke/zeus/blob/master/docs/ruby/modifying.md
# end
def default_bundle
super
Gem.post_reset_hooks.reject!{ |hook| hook.source_location.first =~ %r{/bundler/} }
/* =============================================================
* bootstrap-typeahead.js v2.2.2
* http://twitter.github.com/bootstrap/javascript.html#typeahead
* =============================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
@marciol
marciol / script_rails.rb
Last active December 16, 2015 16:09
In order to allow the requirement of gems that aren't in Gemfile, remember that the gems must be installed in global gemset as made below with the pry-debugger.
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
# In order to allow the requirement of gems that aren't in Gemfile
# remember that the gems must be installed in global gemset
@marciol
marciol / gist:5071576
Last active December 14, 2015 10:19
.emacs
;; initialize packages
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)
(defun ruby-align-hash (begin end)
"Aligns ruby symbol-keyed hashes"
(interactive "r")
(align-regexp begin end "\\(\\s-*\\)[a-z_]+:" 1 1))
(define-key ruby-mode-map "\C-xrh" 'ruby-align-hash)
jQuery.download = function (url, data, callback) {
if (jQuery.browser.msie) {
download(url, data, callback);
} else {
setTimeout(function() {
download(url, data, callback);
}, 100);
}
};
@marciol
marciol / Shell.fs
Created December 20, 2012 20:55 — forked from dvdsgl/Shell.fs
// Demo:
//
// let files = sh "ls -a /Users/david" |> lines
// let install = sh "cp -r %s /Applications"
// install "/Volumes/Awareness/Awareness.app"
//
module Campari.Shell
open System