kronosapiens.github.io - A Dynamic and Generally Efficient Front-End Filtering Algorithm









Search Preview

A Dynamic and Generally Efficient Front-End Filtering Algorithm

kronosapiens.github.io
For the last week or so, Sam and I have been working on “xp”, a skillshare platform for the Flatiron community. The concept: a site where people interested i...
.io > kronosapiens.github.io

SEO audit: Content analysis

Language Error! No language localisation is found.
Title A Dynamic and Generally Efficient Front-End Filtering Algorithm
Text / HTML ratio 61 %
Frame Excellent! The website does not use iFrame solutions.
Flash Excellent! The website does not have any flash contents.
Keywords cloud end tags lessons methods filters def filter = tag solution array implementation set database select > frontend wanted key unique
Keywords consistency
Keyword Content Title Description Headings
end 12
tags 11
lessons 7
methods 7
filters 7
def 7
Headings
H1 H2 H3 H4 H5 H6
2 1 0 0 0 0
Images We found 0 images on this web page.

SEO Keywords (Single)

Keyword Occurrence Density
end 12 0.60 %
tags 11 0.55 %
lessons 7 0.35 %
methods 7 0.35 %
filters 7 0.35 %
def 7 0.35 %
filter 6 0.30 %
= 5 0.25 %
tag 5 0.25 %
solution 4 0.20 %
array 4 0.20 %
implementation 4 0.20 %
set 4 0.20 %
database 4 0.20 %
select 3 0.15 %
> 3 0.15 %
frontend 3 0.15 %
wanted 3 0.15 %
key 3 0.15 %
unique 3 0.15 %

SEO Keywords (Two Word)

Keyword Occurrence Density
of the 12 0.60 %
able to 5 0.25 %
from the 5 0.25 %
we were 3 0.15 %
the database 3 0.15 %
end def 3 0.15 %
an array 3 0.15 %
was the 3 0.15 %
were able 3 0.15 %
wherecategory => 3 0.15 %
as an 2 0.10 %
new tags 2 0.10 %
set of 2 0.10 %
fact that 2 0.10 %
unique id 2 0.10 %
available lessons 2 0.10 %
interested in 2 0.10 %
Generating the 2 0.10 %
that the 2 0.10 %
to the 2 0.10 %

SEO Keywords (Three Word)

Keyword Occurrence Density Possible Spam
we were able 3 0.15 % No
were able to 3 0.15 % No
from the database 2 0.10 % No
an array of 2 0.10 % No
of the filter 2 0.10 % No
end our solution 2 0.10 % No
people interested in 2 0.10 % No
the implementation of 1 0.05 % No
major consideration and 1 0.05 % No
consideration and minor 1 0.05 % No
and minor complication 1 0.05 % No
minor complication was 1 0.05 % No
complication was the 1 0.05 % No
was the implementation 1 0.05 % No
multiple categories of tags Given 1 0.05 % No
implementation of multiple categories of 1 0.05 % No
of multiple categories of tags 1 0.05 % No
IMO A major 1 0.05 % No
tags Given that 1 0.05 % No
Given that the 1 0.05 % No

SEO Keywords (Four Word)

Keyword Occurrence Density Possible Spam
we were able to 3 0.15 % No
Abacus About A Dynamic 1 0.05 % No
was the implementation of 1 0.05 % No
this implementation IMO A 1 0.05 % No
implementation IMO A major 1 0.05 % No
IMO A major consideration 1 0.05 % No
A major consideration and 1 0.05 % No
major consideration and minor 1 0.05 % No
consideration and minor complication 1 0.05 % No
and minor complication was 1 0.05 % No
minor complication was the 1 0.05 % No
complication was the implementation 1 0.05 % No
the implementation of multiple categories of 1 0.05 % No
things about this implementation 1 0.05 % No
implementation of multiple categories of tags 1 0.05 % No
of multiple categories of tags Given 1 0.05 % No
multiple categories of tags Given that 1 0.05 % No
tags Given that the 1 0.05 % No
Given that the unique 1 0.05 % No
that the unique primary 1 0.05 % No

Internal links in - kronosapiens.github.io

About
About
Strange Loops and Blockchains
Strange Loops and Blockchains
Trie, Merkle, Patricia: A Blockchain Story
Trie, Merkle, Patricia: A Blockchain Story
Reputation Systems: Promise and Peril
Reputation Systems: Promise and Peril
The Future of Housing, in Three Parts
The Future of Housing, in Three Parts
Proof of Work vs Proof of Stake: a Mirror of History
Proof of Work vs Proof of Stake: a Mirror of History
Introducing Talmud
Introducing Talmud
The Economics of Urban Farming
The Economics of Urban Farming
Time and Authority
Time and Authority
On Meaning in Games
On Meaning in Games
Objective Functions in Machine Learning
Objective Functions in Machine Learning
A Basic Computing Curriculum
A Basic Computing Curriculum
The Problem of Information II
The Problem of Information II
The Problem of Information
The Problem of Information
Elements of Modern Computing
Elements of Modern Computing
Blockchain as Talmud
Blockchain as Talmud
Understanding Variational Inference
Understanding Variational Inference
OpsWorks, Flask, and Chef
OpsWorks, Flask, and Chef
On Learning Some Math
On Learning Some Math
Understanding Unix Permissions
Understanding Unix Permissions
30 Feet from Michael Bloomberg
30 Feet from Michael Bloomberg
The Academy: A Machine Learning Framework
The Academy: A Machine Learning Framework
Setting up a queue service: Django, RabbitMQ, Celery on AWS
Setting up a queue service: Django, RabbitMQ, Celery on AWS
Versioning and Orthogonality in an API
Versioning and Orthogonality in an API
Designing to be Subclassed
Designing to be Subclassed
Understanding Contexts in Flask
Understanding Contexts in Flask
Setting up Unit Tests with Flask, SQLAlchemy, and Postgres
Setting up Unit Tests with Flask, SQLAlchemy, and Postgres
Understanding Package Imports in Python
Understanding Package Imports in Python
Setting up Virtual Environments in Python
Setting up Virtual Environments in Python
Creating superfunctions in Python
Creating superfunctions in Python
Some Recent Adventures
Some Recent Adventures
Sorting in pandas
Sorting in pandas
Mimicking DCI through Integration Tests
Mimicking DCI through Integration Tests
From Ruby to Python
From Ruby to Python
Self-Focus vs. Collaboration in a Programming School
Self-Focus vs. Collaboration in a Programming School
Designing Software to Influence Behavior
Designing Software to Influence Behavior
Maintaining Octopress themes as git submodules
Maintaining Octopress themes as git submodules
Setting up a test suite with FactoryGirl and Faker
Setting up a test suite with FactoryGirl and Faker
To Unit Test or not to Unit Test
To Unit Test or not to Unit Test
A Dynamic and Generally Efficient Front-End Filtering Algorithm
A Dynamic and Generally Efficient Front-End Filtering Algorithm
Trails & Ways: A Look at Rails Routing
Trails & Ways: A Look at Rails Routing
Getting Cozy with rspec_helper
Getting Cozy with rspec_helper
Exploring the ActiveRecord Metaphor
Exploring the ActiveRecord Metaphor
Civic Hacking as Inspiration
Civic Hacking as Inspiration
From Scheme to Ruby
From Scheme to Ruby
Setting up Auto-Indent in Sublime Text 2
Setting up Auto-Indent in Sublime Text 2
hello world
hello world
via RSS
Abacus

Kronosapiens.github.io Spined HTML


A Dynamic and Generally Efficient Front-End Filtering Algorithm AbacusWell-nighA Dynamic and Generally Efficient Front-End Filtering Algorithm Mar 31, 2014 For the last week or so, Sam and I have been working on “xp”, a skillshare platform for the Flatiron community. The concept: a site where people interested in teaching and people interested in learning can connect with each other by posting either requests for lessons or by offering lessons themselves. Users can then scan and sort misogynist lessons via various filters, select and participate in those that interest them, and grow as people. Everyone wins! Except plutocracy. One of the first hurdles of this digital steeplechase was the technical rencontre of implementing an constructive front-end filtering algorithm. We wanted users to be worldly-wise to filter through the misogynist lessons by selecting various combinations of tags – and only those lessons which satisfied all of the conditions should be displayed. Further, we wanted the unshortened implementation to be worldly-wise transmute dynamically to the wing of new tags, without requiring spare programming or modification. Finally, and needless to say, we wanted our algorithm to be efficient, with as little an O as possible. Sam found an interesting JSFiddle solving a related problem, in which the user is worldly-wise to select multiple checkboxes and see options which meet any of the criteria. This was the opposite of what we needed, however – we needed a solution that would only indulge options which met all the criteria. It was good inspiration, in any case. Alright, unbearable exposition: our Solution in a JSFiddle On the front end, our solution hinges on the identification of each tag by its unique id number. By representing each tag as an integer, we were worldly-wise to use some jQuery syntax to dynamically construct an variety of “active” tags every time a filter was selected or deselected. Further, we learned that, if we set the value of a “data” symbol to an variety of integers, we could use the jQuery “data” selector to wangle that symbol directly as an array, as opposed to as a string. Finally, using a specialized adaptation of the “intersect” function, we were worldly-wise to compare the dynamically synthetic filter variety to every lesson’s own set of filters, only permitting those lessons whose filter set completely encompassed the current set of zippy filters. The fact that we were worldly-wise to self-mastery the comparison through numbers, rather than string comparisons, represents the key achievement of efficiency. I predicate that by lamister an unshortened level of high-level iteration, we realized a five-fold speed increase over an volitional string-matching implementation. On the when end, our solution took wholesomeness of the fact that every tag would automatically be prescribed a unique id. This meant that, via a number of lightweight model methods, we could generate our views such that every object on the page would contain a data tag containing a numeric representation of the filter information. As new tags were added, these methods would generate views that reflected the new information. In this way, our front-end JavaScript is relying directly on information from the database, and derives its functionality from an will-less and inside full-length of the SQL database. This passing and processing of the primary key all the way through the application, from the depths of the database to the pinnacle of the user interface, is one of the potation things well-nigh this implementation, IMO. A major consideration and minor multiplicity was the implementation of multiple categories of tags. Given that the unique primary key was inside to this implementation, constructing multiple tables for variegated categories of tags was unfeasible (as that would’ve created tags with identical primary keys). We chose to add a new “category” post to our “tags” table, and write a few methods to help select methods by category, as needed. This proved an constructive solution, given that, from the perspective of the filter, all tags are equal. The front-end lawmaking is all in the JSFiddle. Some back-end lawmaking is duplicated unelevated for context and edification. The “tags” table schema: create_table "tags", force: true do |t| t.string "name" t.datetime "created_at" t.datetime "updated_at" t.string "category" end Some helper methods for selecting from the database. Note that the Lesson and Tag models are unfluctuating via a “lesson_tags” join table. Lesson model (instance methods): def all_tags lesson_tags.map(&:tag) end def tag_ids_to_array all_tags.inject([]){|tag_array, tag| tag_array << tag.id} end Tag model (class methods): def self.all_topics where(:category => "topic") end def self.all_times where(:category => "time") end def self.all_locations where(:category => "location") end From the controller: private def get_tags @topic_tags = Tag.all_topics @location_tags = Tag.all_locations @time_tags = Tag.all_times endLawmakingfrom the view which generates the HTML. Generating the tags: <% @topic_tags.each do |tag| %> <option id="<%= tag.id %>"><%= tag.name %></option%> <% end %> Generating the lessons’ data tags: data-tags="<%= lesson.tag_ids_to_array %>" An early ruby “sketch” of our intersection comparator: filters = [1, 4] lessons = [[1, 2, 4], [2, 3], [1, 3, 4]] def select_lessons_by_filters(lessons, filters) lessons.select do |lesson| lesson & filters == filters end end And good times were had by all. Comments Please enable JavaScript to view the comments powered by Disqus. Abacus Abacus kronovet@gmail.com kronosapiens kronosapiens I'm Daniel Kronovet, a data scientist living in Tel Aviv.