Created
December 25, 2010 20:11
-
-
Save qoobaa/755030 to your computer and use it in GitHub Desktop.
Magic
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
gem install magic |
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
sudo apt-get install file |
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
set PATH=C:\Program Files\GnuWin32\bin;%PATH% |
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
Magic.guess_string_mime( | |
"Magic® File™", | |
:database => 'C:\Program Files\GnuWin32\share\misc\magic.mgc' | |
) |
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
require "magic" | |
Magic.guess_file_mime("public/images/rails.png") | |
# => "image/png; charset=binary" | |
Magic.guess_file_mime_encoding("public/images/rails.png") | |
# => "binary" | |
Magic.guess_file_mime_type("public/images/rails.png") | |
# => "image/png" | |
Magic.guess_string_mime("Magic® File™") | |
# => "text/plain; charset=utf-8" | |
Magic.guess_string_mime_encoding("Magic® File™") | |
# => "utf-8" | |
Magic.guess_string_mime_type("Magic® File™") | |
# => "text/plain" | |
Magic.guess(:mime_type, :database => "/etc/magic") { |db| db.buffer("Magic® File™") } | |
# => "text/plain" |
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
sudo port install file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment