2718.us blog » firefox http://2718.us/blog Miscellaneous Technological Geekery Tue, 18 May 2010 02:42:55 +0000 en hourly 1 http://wordpress.org/?v=3.0.4 Mac: Chrome versus Firefox http://2718.us/blog/2009/09/17/mac-chrome-versus-firefox/ http://2718.us/blog/2009/09/17/mac-chrome-versus-firefox/#comments Thu, 17 Sep 2009 05:04:26 +0000 2718.us http://2718.us/blog/?p=178 Seeing the announcement of Chrome 3 on Ars Technica reminded me of my desire for Chrome on the Mac. I’m not unhappy with Firefox, especially with the processor-specific-optimization builds, but it’s still slow and it just gets slower the longer I keep it open, constantly churning the CPU doing something and occasionally pausing for no apparent reason. (I dislike the interface and the feel of Safari, though less so with 4 than earlier versions.) So, I Googled Mac Chrome and found that they’ve got a developer preview up for Mac and I just had to download and install it. Both on my Macbook Air and on my Mac Pro, the SunSpider benchmark performance of “Shiretoko” intel-optimized Firefox 3.5.2 was 3-4x slower than the Chrome developer preview 4.0.207.0 (in which I am writing this post). This is huge. When I switched to “Shiretoko” from stock Firefox, I ran the SunSpider benchmarks and found a slight and significant improvement, but not even close to 2x, let alone 3-4x. I can’t wait for a final Chrome (or at least a Chrome that supports SOCKS proxy settings so I can securely browse over WiFi).

]]>
http://2718.us/blog/2009/09/17/mac-chrome-versus-firefox/feed/ 0
SSH Tunneling on a Mac http://2718.us/blog/2008/06/13/ssh-tunneling-on-a-mac/ http://2718.us/blog/2008/06/13/ssh-tunneling-on-a-mac/#comments Fri, 13 Jun 2008 22:55:27 +0000 2718.us http://2718.us/blog/?p=45 Since my employer’s wireless network is unencrypted and since I use other open WiFi networks with some frequency, I’ve gotten in the habbit of tunneling everything through SSH, using the SOCKS5 proxy mechanism built in to SSH.  In WinXP, there’s a nice little program called Tunnelier that makes the setup of the tunnel simple and it reconnects automatically, so the tunneling part is virtually automatic (even though proxy setup is still tricky and/or annoying).

On the Mac, however, I have tried several programs and never really been happy.  So I wrote a little AppleScript that not only sets up the SSH tunnel, but also deals with switching my location to set the system’s network settings to use the proxy (the code is after the cut).  Combine this with System Proxy for Firefox and all my application traffic goes through the SSH tunnel.  Note also that if you’re using a SOCKS5 proxy with Firefox, you probably want to set it to do DNS lookups through the proxy.

This script also stores the info for creating the tunnel (server, login, pw) in the keychain.

Here’s the “library” script where I put the functions to do the underlying work (since I have various different tunnels I use):

  1. on startTunnel(targetServer) –returns PID of ssh for killing later
  2.  tell application "Keychain Scripting"
  3.  
  4.   set sshTunnelKeys to every Internet key of current keychain whose (name is "autoSSHTunnel") and (server is targetServer)
  5.  
  6.   if sshTunnelKeys is {} then
  7.    set sshKey to my makeSSHKeyWithServer(targetServer)
  8.   else
  9.    set sshKey to item 1 of sshTunnelKeys
  10.   end if
  11.   set user to account of sshKey
  12.   set passwd to password of sshKey as string
  13.   set sshHost to server of sshKey as string
  14.  end tell
  15.  
  16.  set sshCommand to "ssh -fND 9999 " & user & "@" & sshHost
  17.  
  18.  set expectScript to "spawn " & sshCommand & "
  19. expect assword
  20. send \"" & passwd & "\\n\"
  21. sleep 1"
  22.  
  23.  do shell script "/usr/bin/expect -c '" & expectScript & "' &>/dev/null &"
  24.  
  25.  set tries to 0
  26.  repeat
  27.   set tries to tries + 1
  28.   try
  29.    set sshPIDstring to (do shell script "sleep 1;bash -c 'ps ax -o pid,tt,command | grep \"??\" | grep \"" & sshCommand & "\" | grep -v grep | grep -v expect'")
  30.    set sshPID to first word of sshPIDstring
  31.    set gotPID to true
  32.   on error
  33.    set gotPID to false
  34.   end try
  35.   if gotPID then
  36.    exit repeat
  37.   end if
  38.   if tries > 10 then
  39.    exit repeat
  40.   end if
  41.  end repeat
  42.  if gotPID then
  43.   return sshPID
  44.  else
  45.   return false
  46.  end if
  47. end startTunnel
  48.  
  49. on setUseTunnel()
  50.  do shell script "scselect 'Use SOCKS5 Proxy on localhost:9999'"
  51. end setUseTunnel
  52.  
  53. on clearUseTunnel()
  54.  do shell script "scselect 'Automatic'"
  55. end clearUseTunnel
  56.  
  57. on stopTunnel(pid)
  58.  do shell script "kill " & pid
  59. end stopTunnel
  60.  
  61. on makeSSHKeyWithServer(targetServer)
  62.  tell application "Keychain Scripting"
  63.   repeat
  64.    set acctBox to display dialog "Enter your SSH login for host " & targetServer & ":" default answer "" buttons {"Cancel", "OK"} default button 2
  65.    set myAcct to the text returned of acctBox
  66.    set myButton to the button returned of acctBox
  67.    if myButton is "Cancel" then
  68.     –quit
  69.    else
  70.     if myAcct is not "" then
  71.      exit repeat
  72.     else
  73.      display dialog "bad login"
  74.     end if
  75.    end if
  76.   end repeat
  77.   repeat
  78.    set passBox to display dialog "Enter your password:" default answer "" buttons {"Cancel", "OK"} default button 2 with hidden answer
  79.    set myPass to the text returned of passBox
  80.    set myButton to the button returned of passBox
  81.    if myButton is "Cancel" then
  82.     –quit
  83.    else
  84.     if myPass is not "" then
  85.      exit repeat
  86.     else
  87.      display dialog "can't use blank passwd"
  88.     end if
  89.    end if
  90.   end repeat
  91.   set newSSHKey to make new Internet key with properties {name:"autoSSHTunnel", account:myAcct, password:myPass, server:targetServer, authentication:default, protocol:SSH}
  92.  end tell
  93.  return newSSHKey
  94. end makeSSHKeyWithServer

And here’s the actual script I run.

  1. property Lib : (path to scripts folder from user domain as text) & "Script Library:"
  2. property sshTunnelLib : load script Lib & "ssh_tunnel.scpt" as alias
  3.  
  4. sshTunnelLib's setUseTunnel()
  5.  
  6. set sshPID to sshTunnelLib's startTunnel("fqdn.of.your.server")
  7. if sshPID is not false then
  8.  set noPIDtxt to ""
  9.  set buttonTxt to "Kill SSH and Exit"
  10. else
  11.  set noPIDtxt to " (but couldn't get PID)"
  12.  set buttonTxt to "Exit"
  13. end if
  14.  
  15. display dialog "SSH-tunneled SOCKS5 proxy running on localhost:9999" & noPIDtxt buttons {buttonTxt}
  16.  
  17. if sshPID is not false then
  18.  sshTunnelLib's stopTunnel(sshPID)
  19. end if
  20.  
  21. sshTunnelLib's clearUseTunnel()
]]>
http://2718.us/blog/2008/06/13/ssh-tunneling-on-a-mac/feed/ 0
shrinking gcal http://2718.us/blog/2008/04/07/shrinking-gcal/ http://2718.us/blog/2008/04/07/shrinking-gcal/#comments Mon, 07 Apr 2008 22:45:45 +0000 2718.us http://2718.us/blog/?p=7 I’ve started to get really into using Google Calendar and it works all fine and dandy on my desktop (multiple large monitors), but when I get to my smaller laptop screen it’s hrd to see more than an event or two per day in the 4-week view (especially since I keep my browser window small-ish).  This led me (through various googling) to the Stylish plugin for Firefox (I think it’s available for other browsers, too), and a few styles: Shrink Sidebar, colorize Saturday & Sunday, and Compact Header.  These were a good start, but just not enough for me, so I hacked up my own version of Compact Header and added another style to do some more shrinking.

Here’s my version of Compact Header:

@namespace url(http://www.w3.org/1999/xhtml);
  1.  
  2. @-moz-document url-prefix("http://www.google.com/calendar/"),
  3.                url-prefix("https://www.google.com/calendar/") {
  4.   #topBar > table > tbody > tr:first-child > td:first-child,
  5.   #ft {
  6.     display: none !important;
  7.   }
  8.   #cornerBookmarks {
  9.     width: 1em !important;
  10.     overflow: hidden !important;
  11.   }
  12.   #cornerBookmarks:hover {
  13.     overflow: visible !important;
  14.   }
  15.   #cornerBookmarks > .bookmarks {
  16.     padding: 4px !important;
  17.   }
  18.   #cornerBookmarks > .bookmarks > tbody > tr > td::before {
  19.     content: "\bb\a0\a0";
  20.     font-weight: bold;
  21.   }
  22.   #tc_top > table {
  23.     background-color: transparent !important;
  24.   }
  25.   #topBar {
  26.     margin-left: 1em !important;
  27.   }
  28.   #s {
  29.     padding-bottom: 0 !important;
  30.    /* margin-top: -5px !important; **ILG */
  31.     margin-top: 4px !important;
  32.   }
  33.   #s > input, #s > button {
  34.     font-size: 80% !important;
  35.     vertical-align: middle !important;
  36.   }
  37.   #nt1 {
  38.     margin-bottom: -2ex !important;
  39.   }
  40.   #nt1 > div {
  41.     padding-top: 4px !important;
  42.   }
  43.   #mt1 > .s > div {
  44.     margin-top: 1em !important;
  45.   }
  46. }

Here’s my more-shrinking thing:

@namespace url(http://www.w3.org/1999/xhtml);
  1.  
  2. @-moz-document url-prefix(http://www.google.com/calendar) {
  3. body {
  4. font-size: 8pt !important;
  5. }
  6. div#gbar {
  7. display: none !important;
  8. }
  9. div#guser {
  10. font-size: 8pt !important;
  11. }
  12. span#todrawfav table {
  13. margin-top: 1px !important;
  14. }
  15. span#todrawfav font {
  16. font-size: 8pt !important;
  17. }
  18. td.chip div label {
  19. font-size: 6pt !important;
  20. }
  21. div#nt_0 div {
  22. height: 13px !important;
  23. }
  24. div#nt_0 {
  25. height: 15px !important;
  26. font-size: 7pt !important;
  27. }
  28. div#addPT {
  29. border-bottom: 1pt solid #999 !important;
  30. height: 14px !important;
  31. }
  32. div#nt_0 div#addPT,div#nt_0 div#addPT div {
  33. height: 14px !important;
  34. }
  35. }
]]>
http://2718.us/blog/2008/04/07/shrinking-gcal/feed/ 0