Created
April 29, 2011 11:48
-
-
Save swdyh/948199 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 glitch s | |
| s.gsub(/0/m) { (rand > 0.9 ? rand(10) : 0).to_s } | |
| end | |
| if /darwin/ === RUBY_PLATFORM | |
| cmd :ggyast, '', 'post glitched screencapture' do | |
| now = Time.now.to_i | |
| file_jpg = "/tmp/#{now}.jpg" | |
| system "screencapture -i -t jpg \"#{file_jpg}\"" | |
| sleep 2 | |
| g = glitch IO.read(file_jpg) | |
| open(file_jpg, 'wb') {|f| f.write g } | |
| unless File.exist? file_jpg | |
| exit | |
| end | |
| begin | |
| url = @g.create file_jpg | |
| rescue Gisty::InvalidFileException => e | |
| puts "Error: invalid file" | |
| rescue Exception => e | |
| puts "Error: #{e}" | |
| else | |
| id = url.split('/').last | |
| @g.clone id | |
| system "open https://gist.github.com/raw/#{id}/#{now}.jpg" if /darwin/ === RUBY_PLATFORM | |
| end | |
| File.delete file_jpg | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment