Skip to content

Instantly share code, notes, and snippets.

@swdyh
Created April 29, 2011 11:48
Show Gist options
  • Select an option

  • Save swdyh/948199 to your computer and use it in GitHub Desktop.

Select an option

Save swdyh/948199 to your computer and use it in GitHub Desktop.
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