Given a set of documents, each associated with multiple tags, how can I retrieve the documents tagged with an arbitrary set of tags?
My solution
| Thread.current[:foo] = 3 | |
| p Thread.current[:foo] # prints 3 | |
| Fiber.new { | |
| Thread.current[:foo] = 4 | |
| p Thread.current[:foo] # prints 4 | |
| }.resume | |
| p Thread.current[:foo] # prints 3 |
| #!/usr/bin/env ruby | |
| # | |
| # Put this script in your PATH and download from onemanga.com like this: | |
| # onemanga_downloader.rb Bleach [chapter number] | |
| # | |
| # You will find the downloaded chapters under $HOME/Documents/OneManga/Bleach | |
| # | |
| # If you run this script without arguments, it will check your local manga downloads | |
| # and check if there are any new chapters | |
| # |
| module CouchDBAttachments | |
| def attachment(*args) | |
| lambda do |env| | |
| request = ActionDispatch::Request.new(env) | |
| doc = DocWithAttachments.get(request.params[:doc]) | |
| serve_attachment(doc, request.params[:path]) | |
| end | |
| end | |
| private |
| #!/usr/bin/env ruby | |
| # | |
| # A quick script to dump an overview of all the open issues in all my github projects | |
| # | |
| require 'octokit' | |
| require 'awesome_print' | |
| require 'rainbow' |
| //Customise Backbone.sync to work with Titanium rather than jQuery | |
| Backbone.sync = (function() { | |
| var methodMap = { | |
| 'create': 'POST', | |
| 'read' : 'GET', | |
| 'update': 'PUT', | |
| 'delete': 'DELETE' | |
| }; | |
| var xhr = Ti.Network.createHTTPClient({ timeout: 5000 }); |
| =begin | |
| Copyright (c) 2012, Nathaniel Ritmeyer | |
| All rights reserved. | |
| Redistribution and use in source and binary forms, with or without | |
| modification, are permitted provided that the following conditions are met: | |
| 1. Redistributions of source code must retain the above copyright notice, | |
| this list of conditions and the following disclaimer. |
| namespace :db do | |
| desc 'Drop all database connections' | |
| task :drop_connections => :environment do | |
| database = Rails::Application.config.database_configuration[RAILS_ENV]["database"] | |
| field = if ActiveRecord::Base.connection.send( :postgresql_version ) < 90200 | |
| 'pg_stat_activity.procpic' # PostgreSQL <= 9.1.x | |
| else | |
| 'pg_stat_activity.pid' # PostgreSQL >= 9.2.x | |
| end |
| simpleFormat = (text) -> | |
| re1 = /\r\n?/g | |
| re2 = /\n\n+/g | |
| re3 = /([^\n]\n)(?=[^\n])/g | |
| fstr = text | |
| fstr = fstr.replace(re1, "\n") # \r\n and \r -> \n | |
| fstr = fstr.replace(re2, "</p>\n\n<p>") # 2+ newline -> paragraph | |
| fstr = fstr.replace(re3, "$1<br/>") # 1 newline -> br | |
| "<p>#{fstr}</p>" |
| module Tire | |
| module Disable | |
| module ClassMethods | |
| def mock_es_response_doc | |
| @mock_es_response_doc ||= | |
| '{"took": 1,"timed_out": false,"_shards": {"total": 5,"successful": 5,"failed": 0},"hits": {"total": 0,"max_score": null,"hits": []}}' | |
| end | |
| def enable! &blk | |
| old_enabled = @tire_enabled || false |