Chibimagic's Weblog

Archive for October 2013

After I updated my machine to Mavericks, I remembered that every OS X update kills your custom Apache settings. Here’s the minimum changes you need to get Python working again.

  1. Edit the Apache config file as root
    • sudo pico /etc/apache2/httpd.conf
    • Enter your password if prompted
  2. Find “<Directory “/Library/WebServer/Documents”>”, then find the line the starts with “Options” and add “ExecCGI” to it. Example:
    • <Directory "/Library/WebServer/Documents">
          #
          # Possible values for the Options directive are "None", "All",
          # or any combination of:
          #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
          #
          # Note that "MultiViews" must be named *explicitly* --- "Options All"
          # doesn't give it to you.
          #
          # The Options directive is both complicated and important.  Please see
          # http://httpd.apache.org/docs/2.2/mod/core.html#options
          # for more information.
          #   
          Options Indexes FollowSymLinks MultiViews ExecCGI
       
          #
          # AllowOverride controls what directives may be placed in .htaccess files.
          # It can be "All", "None", or any combination of the keywords:
          #   Options FileInfo AuthConfig Limit
          #
          AllowOverride None
       
          #
          # Controls who can get stuff from this server.
          #
          Order allow,deny
          Allow from all
      </Directory>
  3. If you have an index file with a python extension, add “index.py” to the “DirectoryIndex” module. Example:
    • <IfModule dir_module>
          DirectoryIndex index.html index.py
      </IfModule>
  4. Tell Apache to process “.py” files as CGI. Find “AddHandler” and add the following line:
    • AddHandler cgi-script .py
  5. Restart Apache.
    • sudo apachectl graceful

Done!

  1. View a webpage on your iPad
  2. Wonder what the URL is for an image on the page
  3. Wonder if you can view the source for the entire page
  4. Google (Yahoo) “view source iOS”
  5. Read JS snippet of first result, decide you don’t want to send the source of all your pages to a random site on the internet and decide to write your own
  6. Bookmark the current page as a starting point for your bookmarklet
  7. Copy their JS as a starting point for your bookmarklet
  8. Switch over to FioWriter on your iPad, which automatically sees your clipboard text and offers to create a new document with it
  9. Create a new document in Dropbox
  10. Tweak JS to your liking
  11. Copy and paste into Safari bookmarklet
  12. Test
  13. Repeat last 3 steps ad nauseam
  14. Get tired of not being able to view the DOM
  15. Switch over to your laptop to repeat the tweak/copy/paste/test cycle in Safari and TextWrangler
  16. Switch over to Chrome after some errant JS tries to append a node into itself, insta-crashing Safari
  17. Get the code working, then tweak some more to your satisfaction
  18. Paste final code into TextWrangler and save to Dropbox
  19. Switch back to your iPad and copy/paste into Safari one last time
  20. Test out code
  21. Rejoice
  22. Forget why you wanted to view source in the first place


javascript:(function(){var a=document.documentElement.innerHTML,b=window.open('about:blank'),c=b.document,d=c.createTextNode(a);c.write('');c.getElementsByTagName('body')[0].appendChild(d)})()

Tags: