Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Joe http://bitshaker.com

« Newer Snippets
Older Snippets »
5 total  XML / RSS feed 

TWiki Backlinks Embedded Search

// This code is pretty specific to what I'm doing, but can easily be modified. The regex in the search may need some tweaking based on your purposes

---
Links To This Card
| *Topic* | *Summary* |
%SEARCH{ search="%TOPIC%[^0-9]" type="regex" scope="text" excludetopic="%TOPIC%, PublishContribHistory" nosearch="on" web="Main" format="| [[$topic]] | $summary  |"}%

Speed up Mail.app

// Speed up Mail.app with this shell command (backup the file first)

sqlite3 "~/Library/Mail/Envelope Index" vacuum;

Ruby Autoit script to handle javascript popups

Run this code to take care of any javascript popups or security confirmations. It will always click "OK".

require 'win32ole'

begin
  autoit = WIN32OLE.new('AutoItX3.Control')
    
  loop do
   autoit.ControlClick("Microsoft Internet Explorer",'', 'OK')
   autoit.ControlClick("Security Information",'', '&Yes')
   autoit.ControlClick("Security Alert",'', '&Yes')
   sleep(5)
  end
       
rescue Exception => e
  puts e
end


If you are using this as part of a script, you can include it using this structure.

require 'win32/process'

  @pid = Process.create(
          :app_name       => 'ruby clicker.rb', #assuming you make the above script into a file called clicker.rb
          :creation_flags  => Process::DETACHED_PROCESS
      ).process_id
     
at_exit{ Process.kill(9,@pid) }

Find All Elements By Class

// Javascript function that will return an array of elements based on DOM element, tag, and class name.
// For instance, getElementsByClassName(document, 'tr', 'INFO') will get all "tr" tags under the document node with the "INFO" class and return an array of them.

function getElementsByClassName(oElm, strTagName, strClassName){
var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
            var arrReturnElements = new Array();
            strClassName = strClassName.replace(/\-/g, "\\-");
            var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
            var oElement;
            for(var i=0; i<arrElements.length; i++){
                oElement = arrElements[i];
                if(oRegExp.test(oElement.className)){
                    arrReturnElements.push(oElement);
                }
            }
            return (arrReturnElements)
        }

Defeat Apple's Anti-DVD-Screenshot DRM

Apple disables the OS X screenshot capability while a DVD is playing, but there is a workaround.

Using terminal, type in this command.
screencapture -i ~/Desktop/filename.jpg


Your mouse should turn into crosshairs. Now hit the space bar. Your mouse should now be a camera. Click the window the DVD is playing in. A file called "filename.jpg" will appear on your desktop.

Found here with many more options:
http://highschoolblows.blogspot.com/2005/11/take-screenshot-of-dvd-player-in-os-x.html
« Newer Snippets
Older Snippets »
5 total  XML / RSS feed