Archive for February, 2008

How to Add Bookmarklets to your iPhone

Monday, February 25th, 2008

Build yourself a hyperlink out of some webpage with this URL http://soft-use.com/inst.html? followed by the code for the bookmarklet.

Here’s an example of how the begining of the new URL would look:
http://soft-use.com/inst.html?javascript:location.href=...

Click the link on from you iPhone, bookmark the resulting page, and then edit the URL in the new bookmark to erase everything before the “javascript:”.

This page has some handy, ready-to-bookmark bookmarklets for your iPhone.

Two Dimensional Discrete Cosine Transform (DCT-II) in Python

Friday, February 22nd, 2008

Here’s my first shot at implementing the 2D discrete cosine transform in Python. It seems to work, but let me know in the comments if it’s wrong, or if you know of any easy ways to speed it up.

import numpy
#shortcuts
from numpy import pi
from math import cos,sqrt

def two_dim_DCT(X):
    """2D Discrete Cosine Transform
    X should be square 2 dimensional array
    Trying to follow:

http://en.wikipedia.org/wiki/Discrete_cosine_transform#Multidimensional_DCTs

    http://en.wikipedia.org/wiki/JPEG#Discrete_cosine_transform"""
    result=numpy.zeros(X.shape)
    N1,N2=X.shape
    def alpha(n):
        """Normalizing function, not sure if necessary"""
        if n==0:return 0.353553390593 #sqrt(1/8.)
        else:return .5 #sqrt(2/8.)
    for (k1,k2),_ in numpy.ndenumerate(X):
        sub_result=0.
        for n1 in range(N1):
            for n2 in range(N2):
                sub_result+=X[n1,n2] * cos((pi/N1)*(n1+.5)*k1)*cos((pi/N2)*(n2+.5)*k2)
        result[k1,k2]=alpha(k1)*alpha(k2)*sub_result
    return result

What is the Name for those Wavy Arm Dolls They have at Sales

Wednesday, February 20th, 2008

What is the official term for these guys?

The kind people at Reddit suggest either Wacky waving inflatable arm flailing tubeman or Air Dancers

How do I Find What Version of PIL I have?

Tuesday, February 19th, 2008

In your Python session:

from PIL import Image
print Image.VERSION

Mini Searches with Answers

Monday, February 18th, 2008

These are links associated with recent searches I’ve done. They’re not difficult enough to warrant to their own posts but still super useful.

O’Reilly Network — Avoid Common Pitfalls in Greasemonkey
I have to INSIST you read ALL of this before making any GreaseMonkey scripts! I hit about all of these pitfalls in my first GM script, at a cost of maybe 30 minutes each! Do yourself a favor and read this first.

Simple command line file encryption in Linux
# brett@parasite:~$ echo "hello" > secret
# brett@parasite:~$ openssl enc -aes256 -base64 -in secret -out encryptedsecret
# (password)
# brett@parasite:~$ cat encryptedsecret
# U2FsdGVkX1/M0fRNElD9nXtNXv5qCqB5GY7dgV421Ws=

Maps/Speed Traps Mashup – Best One So Far
Combines Microsoft Live Maps and the ability to pinpoint and review speed traps anywhere. Membership is totally free. Speeding tickets are not. Future revisions of the site will allow for uploading to mobile GPS devices and GPS Enabled Phones.

Table2Clipboard :: Firefox Add-ons
Copy tables on webpages and paste into things something that actually makes sense and looks like a table.

Tags: , , , , , , , , , , , , , , , , , , , , , , , ,