Skip to main content

Posts

Showing posts from 2010

An HTML select that allows user created options

I was thinking the other day that it would be useful to have a select option that people could also put their own options into on the fly.  Obviously you wouldn't do this if you wanted completely normalization, but many times I have made selects with an "other" option, and then below put a text field "If you have selected "other" please tell us what your preference is. This is meant to address that. <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" > <!-- A simple way to have a dropdown that also allows user input. If the user choses "other" from the dropdown, he/she will be shown a text field into which he/she can put a new option. When the user clicks save, the option will be added to the select and made as the selected item. There is a place in the code where you can call the onchange after a new value is added, or comment out that if desir...

A modification of Lifehacker's Invisibility Cloak

Need to curtail your surfing during certain time periods?  I've tweaked Gina Trapiani 's original code to make it a little more tolerant.  Put a few numbers into the "surfHours" array and you'll be able to access your "blocked" sites for one hour after each hour listed.  As an example, if surfHours = [9,13,17] you can access facebook (or any other site) from 9-10am, 1-2pm and 5-6pm. You can install the script directly from userScript and the source code is below.  If you don't know how to install a grease monkey script, check out the instructions at http://userscripts.org/scripts/show/92640 // Invisibility Cloak // version 0.1 // Gina Trapani // 2006-01-03 // Released to the public domain. // // ==UserScript== // @name Modified Invisibility Cloak // @description Turns time-wasting web pages invisible until a specified time of day. // @include http://flickr.com/* // @include http://*.flickr.com/* // @include ...

Making your facebook group safe for the enter key

I've been very frustrated recently with the fact that in facebook groups, if you press enter while typing a post, it submits the post.  If you just want to make a line break you have to hit shift-enter. Fortunately we don't have to live that way any more.  I've made a greasemonkey script for people who use firefox .  You can either install it directly or install it from the UserScripts.org site To be perfectly clear: You must be running firefox http://www.getfirefox.com  AND You must have GreaseMonkey installed:  https://addons.mozilla.org/en-US/firefox/addon/748/ BEFORE you can install my script. After you have installed my script when you are on a group page, press the alt-z to turn on safe typing. Now you will be able to press the enter key all you want to make line breaks. Then when you are ready to save, you can press the alt-q to turn OFF safe typing and THEN press enter (sequentially, not simultaneously), and your post will save....

Time for a smaller government

I just read this intriguing piece in the Times:   http://www.nytimes.com/2010/11/28/opinion/28rich.html?_r=3&hp What's great about this article is that I think the means that it describes and ends we would all find desirable: a government that votes it's conscience. We differ greatly as to the means. I've been thinking recently that the problem is lack of accountability. First a little history: Under the Articles of Confederation, Congress was a unicameral body in which each state held one vote. The ineffectiveness of the federal government under the Articles led Congress to summon a Constitutional Convention in 1787. The issue of how Congress was to be structured was one of the most divisive among the founders during the Convention. James Madison's Virginia Plan called for a bicameral Congress: the lower house would be "of the people," elected directly by the people of the United States and representing public opinion, and a more deliberative upper ho...

We're through Adobe

I've been an anti-flash guy for a pretty long time now but I've been "ok" with running flash on machines when I had flashblock installed.  Today however I ceded to Adobe's nag and installed the latest upgrade to Flash -- bringing me to Flash Player 10.1  It ran mostly in the background, and I had to agree to what read like a EULA.  My oh my what bullshit they pulled. Turns out they installed McAfee anti-virus/antispyware, which I've always thought was terrible.  Don't just take my word for it though.  You need no further proof as to how seriously McAfee takes spyware than to see that they don't mind that their program IS INSTALLED AS SPYWARE.  If you have McAfee I would be worried that for $$$ McAfee will decide some other programs aren't spyware, and allow them to be installed on your PC.  Nothing is more dangerous than a false sense of security, and it's clear McAfee has little interest in your PC's security. As for Adobe.  I'...

Encyclopedia Brown and the Case of the Mysterious Sweater

I wrote this in summer of 2008.  My gang of friends had all come down to Woods Hole, and Mark Z. had brought a sweater he had found in his apartment.  All the girls we knew were assembled, yet no  one claimed the sweater.  After the weekend, emails flew among the group trying to decide who owned the "mysterious sweater."  The phrase reminded me of my childhood, and I sat down and wrote the following:     Encyclopedia Brown and the Case of the Mysterious Sweater It was a warm Memorial Day on Cape Cod.  Encyclopedia Brown was driving down to visiting his friend Dan in Woods Hole from Idaville.  He had picked up his old friend Sally Kimball from Smith, where she was doing a double major in physical education and flannel shirts.   They were looking forward to a pleasant day of vacation.  But when they got to Woods Hole they found a mystery awaiting them. Encyclopedia Brown pulled into the hidden driveway, and saw Dan standi...

Javascript , YUI, Dates and Datatable

I've had some issues with pushing strings in JSON to a browser and having the browser parse them correctly.  Some browsers will take strings as argument, some want numbers -- it's a bit confusing.  To avoid all confusion, I recommend making a new date and then setting the values, rather than using the ambiguous constructors, which are implemented differently on different browsers. As an example new Date("2010, 12, 25"); and new Date("12 25,2010"); both yield a date in Firefox, but not in IE. Better is to do this: Date d = new Date(); d.setFullYear(int year,int month,int day);   Note that month is 0 based, so 0 is January, 11 is December.

A simple versioning implementation of Voldemort

I've been playing around with Voldemort recently for a robust enormous datastore at Esped.com .  One of the frustrating things I found in getting into it was the lack of complete existing code samples, so I thought I'd contribute one to the community. This is a bit more than simple put/get because I need versioning associated with my objects.  This code assumes you've got a Voldemort server up and running.  Make the object you want to save implement Storeable, and then you can call VoldemortValet.process(yourObject) and it will save it. It would be easy enough to take the versioning OUT of this code if you needed to. import org.jdom.Element; public interface Storeable { public String getIidString(); public Element rawXML(); public String getUserId(); public String getDataType(); } /** * A simple versioning datastore. In this example we want to keep track of every iteration of every object * as well as every change made by every use...