This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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(' ')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'cgi' | |
IO.popen 'open http://twitter.com/?status=' << CGI::escape(ARGV.collect { |word| word[0] == 64 ? word : "##{word}" }.join(' ')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tosti | |
def self.validate(*ingredients) | |
ingredients.include?(:brood) && ingredients.include?(:kaas) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class @Appsignal | |
constructor: -> | |
@action = "" | |
@tags = {} | |
set_action: (action) -> | |
@action = action | |
tag_request: (tags) -> |