Archive of articles classified as' "Downloads and Copy-Pasteables"

Back home

Quickly whitelist sites in Kill-Flash

7/06/2010

Is it hypocritical of me to write about a Flash blocker when I’ve spent a good portion of my time the last four years doing Flash? Maybe, but some of the sites out there have ridiculous amounts of intrusive and annoying banner ads, and I just can’t stand having my the fans on my Mac blowing a fuse every time I want to check out the news.

My favorite implementation of Flash-blocking has always been ClickToFlash which is a Safari-only plugin that works exactly as advertised. You click the element to load Flash. Sadly, as mentioned, it’s Safari-only and my browser of choice these days is Google Chrome.

Jason 128Fortunately I found a port, or perhaps a backwards engineered version for Chrome named, somewhat more aggressively, Kill-Flash. It works on exactly the same principle. All Flash elements are replaced with an inconspicuous grey-scale gradient with the label “Flash”, and you “Click To Flash”… Duh.

Stupidly however, I have found no simple way to add sites to the plugins whitelist. A few sites (YouTube and GMail) are whitelisted by default, but no option that I’ve found to add new sites. There are several sites I visit on a regular basis and where I want to see the Flash. Hell, my own blog uses several (subtle, I hope) Flash elements and I don’t need to see those grey boxes every time I come here. In fact, personally I think perhaps a “blacklist mode” would be my preferred way to operate.

So, anyway. I started digging around in the Library to figure out how to add sites to the whitelist. The first issue of course is to find out where the whitelist is located. A couple of headscratches later I found that this is the file you need to deal with:

/Users/USERNAME/Library/Application\ Support/Google/Chrome/Default/Extensions/kfncbcioneejfnnelcdmocdjncbmceea /1.1/kill_flash.js

I’m not sure whether or not that crazy string is the same for everyone or generated randomly for each installation. If you see the kill_flash.js you’re there.

Opening this file reveals, at the very top the following variable.

1
var whitelist = ["www.youtube.com","mail.google.com","gmail.com"];

What you need to do is simply append the domains you want to whitelist to this array, in quotes and separated by commas. Like so:

1
var whitelist = ["www.youtube.com","mail.google.com","gmail.com", "ctrloptcmd.com"];

When you’ve done this you might want to create an alias for easy access to the file. Personally I just dragged it to my Dock for the sake of convenience.

I might at some point write an AppleScript or something to make this easier. If that ever happens I’ll be sure to post it here.

No Comments

The Parallax WordPress theme open sourced

4/06/2010

I’ve been meaning to release the theme of this blog for ages, yet I never really got around to finishing it.
After a bit of consideration I’ve decided to go for the easy option and just release it “as is”. It’s based on Sandbox and is therefore GPL-licensed. Otherwise I’d release it under my personal “I don’t give a hoot, but please credit me”-license.

If you want to use this theme for your blog without making any changes, here’s what you might be interested to know:

  • The text in the top banner is entirely configurable in the theme options. You can even choose between using Flash, a static image file (there’s a template included in the theme folder) or even plain HTML text
  • The Twitter widget in the sidebar is likewise configurable. Enter your Twitter ID, choose whether or not to ignore @replies and Bob’s your uncle.
  • This theme is not widget ready. If you try to add widgets they simply won’t show up. The default Twitter, Feeds, Recently and Pages is what you get. I’m sorry about this. This was one of the things I was working on when I ran out of time.
  • I’ve tried to clean out most of the plugin-specific styling for the plugins I use. Simply delete the following files if you don’t want my plugin-styles to override the defaults:
    • styleextras.css
    • sociable_see_extras.css
  • Like I said; Work in progress. Here be dragons. :)

If, however, you want to help out finishing this theme and / or add your ideas to it here is a list for you.

  • The reason widgets don’t currently work is because I wanted to make it so that widgets would always be styled in a specific manner according to their position, rather than the type of widget. For example I wanted the next box on the right to be grey regardless of whether it was an archives widget or a recent posts widget. Anal much? Yes. Anyway; I made a JavaScript that assigns an extra class to each widget based on it’s position, or “number” if you please. It’s pretty much done except for making the graphics (getting the design to be height-agnostic is a real bitch). There’s some first attempts in the images folder if you want to give it a go
  • The theme does not currently validate properly. It used to, and then I messed something up. Sorry.
  • The comment styling is really messy. I’d consider working it over if I were you. (I’ll get around to it some day…)
  • There’s probably more I should warn you about, but it’s late and I’m sleepy. I created this theme strictly for personal use, and although I’ve gotten rid of all absolute URLs and site-specific stuff I haven’t gotten around to cleaning up the code. I’m quite the salesman, huh?

So there it is. For the geeks, here’s a github link.
For the non-geeks, here’s a direct download to the theme zip-file.

Enjoy.

No Comments

A few random AppleScript snippets

14/01/2010

I was just writing an AppleScript to look up words on the excellent NinjaWords and decided to post it in case someone else needs something similar. Since one snippet of AppleScript is not a very meaty post, I’ll throw in a couple extra.

Look up word on NinjaWords

Select a word and copy it to the clipboard. Then invoke this script via Quicksilver or LaunchBar or whatever is your favorite tool for invocations.

1
2
3
4
set clip_url to (the clipboard as string)
set lc_url to do shell script "echo " & clip_url & " | tr '[:upper:]' '[:lower:]'"
set ninjaURL to "http://ninjawords.com/" & lc_url
do shell script "open " & ninjaURL

Wrap link in ‘a href…’

Note: This one will look slightly different depending on whether you are using Quicksilver, LaunchBar, whatever. The key is that you pass a string value into the script and it returns one back to you. This example is for LaunchBar.
Copy a link to the clipboard, invoke the script, paste your now a-tagged link.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
on handle_string(vanillaStr)
  set quote to ASCII character 34
 
 
  set openTag to "<a href=" & quote
  set closeTag to quote & ">"
  set finishTag to "</a>"
 
  set TempTID to AppleScript's text item delimiters
  set AppleScript's text item delimiters to space & ":" & space
  if (count of text items of vanillaStr) is greater than 1 then
    set urlStr to text item 1 of vanillaStr
    set linkStr to text item 2 of vanillaStr
    set returnStr to openTag & urlStr & closeTag & linkStr & finishTag
  else if (count of text items of vanillaStr) is 1 then
    set urlStr to text item 1 of vanillaStr
    set linkStr to "linkage"
    set returnStr to openTag & urlStr & closeTag & linkStr & finishTag
  else
    beep
    return
  end if
  set AppleScript's text item delimiters to ""
  tell application "LaunchBar"
    perform action "Copy and Paste" with string returnStr
  end tell
end handle_string

New File

Sometimes you just want a dang text file to magically appear.

1
2
3
4
5
6
7
8
9
10
11
12
try
  tell application "Finder" to set the this_folder ¬
    to (folder of the front window) as alias
on error -- no open folder windows
  set the this_folder to path to desktop folder as alias
end try
tell me to activate
set thefilename to text returned of (display dialog ¬
  "Create file named:" default answer "filename.txt")
set thefullpath to POSIX path of this_folder & thefilename
do shell script "touch \"" & thefullpath & "\""
do shell script "mate \"" & thefullpath & "\""

That’s it for now. I have some gems saved for a later post, but they wouldn’t make sense out of context so you’ll just have to wait.

2 Comments

Things Migrator 2

14/12/2009

I noticed that my little app for migrating your data from Things to The Hit List still gets some hits. I haven’t really looked at it for ages, but I wasn’t terribly surprised to see that it’s broken under Snow Leopard.

I decided to fix it, expecting AppleScript projects in Xcode to work pretty much the same that they did before, and brother was I mistaken.

It seems that Apple decided AppleScript as a simple to grasp scripting language really has no place in Xcode anymore, and Cocoafied the bejeezus out of it. On the surface using the new Cocoa / AppleScript bridge feels like playing a nazi in most hollywood war movies. You’re still speaking English (Cocoa), just with a horrible German (AppleScript) accent.

The Migrator is just a little quick and dirty utility app, which AppleScript is perfect for, but rewriting this for 10.6 I felt I might as well have ported it to Cocoa (since I’m in the process of learning Objective C anyway). I didn’t though. I hacked my way through it using the Bridge, and I felt like Xcode was berating me the whole time.

I’m excited about Cocoa and Objective-C, but I loved AppleScript for what it was. I’m still going to be using AppleScript a lot, but unless I “See the light” of the Cocoa Bridge, I don’t think I’ll be making any GUI apps with it anymore. I also find it telling that there seems to be no documentation for the Cocoa / AppleScript Bridge except for the release notes that I can find.

Rant over.

Disclaimer:

  • This works fine for me. I make no guarantees that it’ll work for you. I think it will, and I’ll try to help you out if it doesn’t, but I’m not liable if your Mac explodes.
  • Caution: If you check the “Delete items from Things” option your items will be deleted from Things.
  • In order for this to work the app will empty your Things trash can regardless. If you really need the stuff in the Things trash can, perhaps it shouldn’t be in the trash.
  • I don’t have a Leopard machine handy, so I haven’t tested the Leopard version since I first posted it in May. It worked then, so it should work now.

Github
App – Leopard
Source Code – Leopard
App – Snow Leopard
Source Code – Snow Leopard

3 Comments

Capture key sequences in ActionScript 3. AKA The Konami Comeback.

6/06/2009

Contra Konami
Lately the internet has had a wave of sites using the cherished Konami Cheatcode to reveal easter eggs or similar functionality in the site or app.

I wrote a (crappy but working) class to implement such functionality in ActionScript about a year ago here.

I decided to polish it up a bit for the benefit of myself and anyone else and in the process ended up creating a small utility class to work with keystrokes in the process.

You can download the (fairly self-expaining) classes and a sample project right here, or read on for a bit of explanations.

(Text) Keys.as.
(Text) Konami.as.
(Archive) Neatly zipped + example.

Read the rest of this article »

3 Comments