Skip to content

Instantly share code, notes, and snippets.

/**
* Example of using an angular provider to build an api service.
* @author Jeremy Elbourn ([email protected])
*/
/** Namespace for the application. */
var app = {};
/******************************************************************************/
@brycesch
brycesch / tire_bulk_import.rake
Created October 2, 2013 15:25
tire bulk importer
module Tire
module Tasks
module Import
def bulk_import_model(index, klass, options = {})
unless progress_bar(klass)
puts "[IMPORT] Importing '#{klass.to_s}'"
end
klass.scoped.find_in_batches(options) do |batch|
documents = batch.map(&:to_indexed_json)
progress_bar(klass).inc documents.size if progress_bar(klass)
@brycesch
brycesch / filtered_search.rb
Last active December 22, 2015 20:48
general purpose search method to be used with the tire gem.
module FilteredSearch
extend ActiveSupport::Concern
module ClassMethods
def filtered_search(conditions, filters = {}, options = {})
return [] unless self.respond_to?(:tire) or conditions.nil?
FilteredSearch::CustomSearch.new(self, conditions, filters, options).search
end
end
@brycesch
brycesch / .bash_profile
Last active December 21, 2015 09:29 — forked from ehlertij/.bash_profile
# Set terminal window name to current git repo (and branch) or current directory
git-repo() {
git remote -v | grep '(fetch)' | grep -o "\/[a-z,A-Z,\_,\-]*\." | tail -1 | cut -c 2- | grep -o "[a-z,A-Z,\_,\-]*"
}
git-branch() {
git branch | grep \* | cut -c 3-
}
git-term() {