The RoLLing cOde

Rumor, crap and –un–original

Archive for the ‘Crap’ Category

Convert adblock rule list to regular expressions

without comments

Here’s the script convert EasyList and ChinaList to regex lines, which may be used in some web browsers or proxy programs.

#!/bin/sh

ADLIST=”http://adblock-chinalist.googlecode.com/svn/trunk/adblock.txt http://easylist.adblockplus.org/easylist.txt”

echo -n > /tmp/adblock.txt

for URL in $ADLIST

do

    echo Fetching $URL …

    curl $URL | grep -v ^$ | grep -v # | grep -v ^[!|@] | grep -v \$ | sed ’s/./\./g’ | sed s/*/.*/g | sed ’s/|/\|/g’ | grep -v ‘Adblock Plus 1′ >> /tmp/adblock.txt

done

Note this will generate >1000 regexp lines, which might impact performance of your web browser.

Written by freewizard

July 4th, 2009 at 5:27 pm

Posted in Crap

Tagged with

Idle reminder script for The Hit List

without comments

This handy script will remind(disturb?) you every N minutes about what you are doing (if you begin a task in
The Hit List
) or you are idling right now as
Growl
notification.

Paste the following code to Script Editor, Save.

try
	tell application "GrowlHelperApp" to register as application "THL Notifier" all notifications {"Doing", "Idle"} default notifications {"Doing", "Idle"} icon of application "The Hit List"
	tell application "System Events"
		tell process "The Hit List" to set myDoing to get value of text field 1 of window "Timer"
		tell application "GrowlHelperApp" to notify with name "Doing" title (myDoing) description ("now doing...") application name "THL Notifier" priority 0 sticky no icon of application "The Hit List"
	end tell
on error
	tell application "GrowlHelperApp" to notify with name "Idle" title ("Something to do?") description ("idle...") application name "THL Notifier" priority 0 sticky no icon of application "The Hit List"
end try

Open Terminal, type

crontab -e

Add this line and save ( you can change 15 to what ever minutes between each reminder)

*/15  *    *    *    *    osascript /path/to/Whatsup.scpt

Note: due to the limitation of the time tracking window display in THL, this script does not support Spaces very well.

Written by freewizard

June 1st, 2009 at 9:34 am

Posted in Crap

Tagged with

Install multiple versions of Flash plugin for Firefox

without comments

As developing ActionScript projects, one have to frequently switch between different Flash versions and test. Here is a tip for Mac OSX ( also works on Windows I think ) to install multiple versions of Flash Player plugins for Firefox.

When Firefox starts, it scans for plugins in 3 sets of directories:

  1. General plugin directory for current system and user, e.g.
    /Library/Internet Plug-Ins/
  2. Plugin directory for current application executable file, e.g.
    /Applications/Firefox.app/Contents/MacOS/plugins/
  3. Plugin directory for current profile, e.g. 
    ~/Library/Application Support/Firefox/Profiles/fw9q5h64.default/plugins

Then it will
sort by modification time
, dedupe and load all the plugins.

Now you get the trick:

  1. Extract the desired firefox plugin files (
    e.g. Flash Player.plugin
    and
    flashplayer.xpt
    on Mac ) from Flash plugin installer or copy from installed directory ( e.g.
    /Library/Internet Plug-Ins/
    on Mac )
  2. Copy these files to your favorite firefox app or profile directory
  3. use the command


       touch -t 201603150101.01

    Flash Player.plugin

    flashplayer.xpt

    to make the mtime larger than the one in the general directory.

  4. repeat above steps for all flash versions you want.

Update: you should check “Open using Rosetta” when playing Flash 8 or earlier with Firefox on Mac.

Written by freewizard

April 18th, 2009 at 4:21 pm

Posted in Crap

Tagged with ,

TextMate bundle for the haXe Language

without comments

It’s modified from some post in the
haXe mailing list
.

Check it out from
GitHub
.

Written by freewizard

April 4th, 2009 at 7:18 am

Posted in Crap

Tagged with ,

URL Handler and Bookmarklet for The Hit List

without comments

This app will handle x-thl:// links and add task to your inbox of
The Hit List

The bookmarklet will use title of web page as title of the task and pick page url and selected text as notes.

THL URL Handler.app.zip
- unpack to Applications folder of your Mac

Send to THL
- Drag to bookmark bar of your favourite browser 

If you’d like to write your own bookmarklet, here’s the template:




position
=optional



only inbox is supported at this stage,
i’ll consider if add support for start/due and specify a project in THL some time later.


Mar 25, 2009 - App updated!

Newly supports:

  • optional position parameter ( beginning or end )
  • inbox can be any project or even folder1/folder2/project

Enjoy!

Written by freewizard

March 22nd, 2009 at 9:59 pm

Posted in Crap

Tagged with

Script Entourage messages to The Hit List

without comments

The Hit List
is a good task management software for Mac OSX, and I think it’s better than
OmniFocus
and
Things
.

 120 then
			set theNotes to get text 1 through 120 of theNotes
			set theNotes to theNotes & "..."
		end if
		tell application "GrowlHelperApp" to notify with name "New Email" title (theTitle) description (theNotes) application name "Entourage Growl Notifier" priority 0 sticky no icon of application "The Hit List"
	end repeat
end tell
]]>

To use this as a mail rule, in Entourage, open menuToolsRules, add a new rule with “Run AppleScript” as its action.

To use this as a menu item or hotkey script, copy the script to

/Documents/Microsoft User Data/Entourage Script Menu Items/

, it’ll appear in the Script menu of Entourage.You can even add a
cT
after it’s name so that it will be triggered when you press Ctrl-T. 

Written by freewizard

March 18th, 2009 at 9:30 am

Posted in Crap

Tagged with ,

Bulk edit in redmine-0.7.x

with one comment

for those who stick to redmine-0.7, apply this to make its bulk-edit rework in Firefox/Safari.


backported from trunk.

Written by freewizard

January 4th, 2009 at 6:28 am

Posted in Crap

Tagged with

Detect ActionScript 2/3 in TextMate

without comments

I made
a very rough tmplugin
(TM 1.x OSX 10.4+ UB) to search the word “package” in the beginning of first 20 lines of .as file to determine whether it’s AS3 or AS2, then select a proper bundle. It’s modified from
TabMate
.

You should have
ActionScript
and
ActionScript 3
tmbundle before install this tmplugin. 

Written by freewizard

December 12th, 2008 at 7:07 am

Posted in Crap

Tagged with ,

Growl notification for 1G1G.com

without comments

It’s a
Fluid
SSB user script.

// ==UserScript==
// @name        1G1G
// @namespace   http://fluidapp.com
// @description Show Growl notification when song changes
// @include     *
// @author      freewizard gmail.com
// ==/UserScript==

(function () {
    if (window.fluid) {
        window.lastTitle = "亦歌-自由自在听音乐";
        setInterval(function() {
            if (document.title == window.lastTitle) return;
            window.lastTitle = document.title;
            window.fluid.showGrowlNotification({
                title: "亦歌",
                description: window.lastTitle,
                identifier: "www.1G1G.com"
            });
        }, 1000);
    }
})();

Written by freewizard

December 8th, 2008 at 3:38 pm

Posted in Crap

Tagged with

Quick filter by mail topic in Microsoft Entourage

without comments

This script will filter mails by topic ( actually subject without “Re:” and “Fw:” ) of the selected message.

Save the following AppleScript code as ~/Documents/Microsoft User Data/Entourage Script Menu Items/Quick FiltercF

on ltrim(someText)
	repeat until first character of someText is not in {" ", tab, ASCII character 10, return, ASCII character 0}
		set someText to text 2 thru -1 of someText
	end repeat
	return someText
end ltrim

on run
	tell application "Microsoft Entourage"
		--activate
		set msgs to the current messages
		if msgs is {} then return
		repeat with msg in msgs
			set subj to get the subject of msg
		end repeat
		set AppleScript's text item delimiters to {":"}
		set tpc to last text item of subj
	end tell
	set tpc to my ltrim(tpc)
	set the clipboard to tpc
	tell application "System Events" to tell process "Entourage"
		delay 0.1
		keystroke tab
		delay 0.1
		keystroke "v" using command down
		keystroke tab
	end tell
end run

Make sure quick filter is turned on (Cmd-Shift-L);

Click one item in the messages list;

Click script menu and select our script.

Written by freewizard

October 23rd, 2008 at 9:43 am

Posted in Crap

Tagged with