Skip to content

Instantly share code, notes, and snippets.

View matsimitsu's full-sized avatar

Robert Beekman matsimitsu

View GitHub Profile
@matsimitsu
matsimitsu / hashtagerize.rb
Created November 26, 2009 15:43 — forked from jeffkreeftmeijer/hashtagerize.rb
Improved Jeff's Version, made it more awesome-o
#!/usr/bin/ruby
require 'cgi'
puts 'please type the text you want to #hashtagerize and press [ENTER]...'
IO.popen 'open http://twitter.com/?status=' << CGI::escape(gets.split(' ').collect { |word| word[0] == 64 ? word : "##{word}" }.join(' '))
#!/usr/bin/ruby
require 'cgi'
IO.popen 'open http://twitter.com/?status=' << CGI::escape(ARGV.collect { |word| word[0] == 64 ? word : "##{word}" }.join(' '))
@matsimitsu
matsimitsu / mongo_mapper_problem.rb
Created December 18, 2009 21:24
something like this? (from mongo activerecord docs)
# multiple options; works fine
User.all(:age => [1,2,3])
# >> [#<User age: 3>]
# using the $lt operator; works fine
User.all(:age => {'$lt' => 10})
# >> [#<User age: 3>]
# combining multiple options with the $lt operator; fails.
User.all(:age => {'$lt' => 10, '$in' => [50])
class Tosti
def self.validate(*ingredients)
ingredients.include?(:brood) && ingredients.include?(:kaas)
end
end
# rails metal to be used with carrierwave (gridfs) and MongoMapper
# Now works with MongoMapper 0.7.5 and Mongo 1.0
# Begin/rescue is a bit lame, but mongo 1.0 doesn't have the exist? method yet (only from 1.0.1)
require 'mongo'
# Allow the metal piece to run in isolation
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
class Gridfs
A backup of http://sites.google.com/site/redcodenl/creating-shazam-in-java-1 just in case
Why is this necessary? Read http://sites.google.com/site/redcodenl/patent-infringement
Please fork, tweet about, etc.
----
Creating Shazam in Java
A couple of days ago I encountered this article: How Shazam Works
This got me interested in how a program like Shazam works… And more importantly, how hard is it to program something similar in Java?
def show
@user = User.find_by(username: params[:id])
respond_to do |format|
format.html {
render action: 'show'
}
format.json {
your_friend = false
if user_signed_in?
class @Appsignal
constructor: ->
@action = ""
@tags = {}
set_action: (action) ->
@action = action
tag_request: (tags) ->