Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Pragmatic Glitch (#rubykaigi 2013 LT)

The Pragmatic Glitch (#rubykaigi 2013 LT)

one of lightning talks in RubyKaigi 2013
31st May, 2013

Shimpei Makimoto

May 31, 2013
Tweet

More Decks by Shimpei Makimoto

Other Decks in Design

Transcript

  1. The Pragmatic Glitch Shimpei Makimoto https://github.com/makimoto https://twitter.com/makimoto one of lightning

    talks in RubyKaigi 2013 | 31st May, 2013 Έͳ͞Μ͜Μʹͪ͸ɻ 5IF1SBHNBUJD(MJUDIͱ͍͏࿩Λ͠·͢ɻ
  2. data = ARGF.read.force_encoding('ascii-8bit') 36.times do |from| from = from.to_s(36) 36.times

    do |to| to = to.to_s(36) open("#{from}_#{to}.jpg", 'wb').write(data.gsub(from, to)) end end ͍ͬͺ͍ը૾͕΄͚͠Ε͹͜ΜͳίʔυΛॻ͍ͯ΋͍͍Ͱ͢ɻ
  3. get '/glitch' do data = open(params[:url]).read data_a = data[0 ..

    data.size / 2] data_b = data[data.size / 2 .. -1] content_type :jpeg data_a + data_b.force_encoding('ascii-8bit').gsub('a', 'b') end ͬ͟ͱݟͯ΋ΒͬͨΒΘ͔ΔΜͰ͕͢ɺ؆୯ͳϩδοΫͰ͢ɻ
  4. get '/glitch' do data = open(params[:url]).read data_a = data[0 ..

    data.size / 2] data_b = data[data.size / 2 .. -1] content_type :jpeg data_a + data_b.force_encoding('ascii-8bit').gsub('a', 'b') end ը૾ϑΝΠϧΛಡΈࠐΜͰɺͭͷϒϩοΫʹΘ͚·͢ɻ
  5. get '/glitch' do data = open(params[:url]).read data_a = data[0 ..

    data.size / 2] data_b = data[data.size / 2 .. -1] content_type :jpeg data_a + data_b.force_encoding('ascii-8bit').gsub('a', 'b') end ࠷ॳͷϒϩοΫ͸ͦͷ··ʹɺ࣍ͷϒϩοΫͰ͸HTVC͠·ͯग़ྗ͠·͢ɻ
  6. def show respond_to do |format| format.html do # snip end

    format.glitch do data = open(IMAGES_PATH.join(params[:id])) data = data.force_encoding('ascii-8bit').gsub('a', 'b') send_data data, type: 'image/jpeg', disposition: 'inline' end end end ͪͳΈʹ3BJMTͰಉ༷ͷॲཧΛߦ͓͏ͱͨ͠Β͜Μͳײ͡ʹͳΓ·͢ɻ protip: Case in Rails
  7. Glitch is quick and easy Glitch is useful for web

    applications (JPEG is good) ͱ͍͏͜ͱͰɺάϦον͸ૉૣ͘Ͱ͖ͯ؆୯Ͱ͢ɻ ΢ΣϒΞϓϦέʔγϣϯͱͷ਌࿨ੑ΋ߴ͍Ͱ͢ɻͥͻࢼ͍ͯͩ͘͠͞ɻ You can try it!!1;
  8. The Pragmatic Glitch one of lightning talks in RubyKaigi 2013

    | 31st May, 2013 Shimpei Makimoto https://github.com/makimoto https://twitter.com/makimoto