Scrupuli

blunt essays with sharp points

Make Firefox Take Geolocation From Google Latitude

by Scrvpvlvs
Nov 29, 2010 5:16 AM–Firefox takes its geolocation from Google Latitude, with the help of a small PHP program.

Websites can now ask for your location, and a few do. For example, Gowalla wants your location so that it can show you nearby places of interest.

When you give your permission, your browser does its best to find out where it is and let the website know. But sometimes this procedure goes wrong. For example, my home computer is in Tarrant County, Texas, but my browser tells Gowalla that it is miles away in Dallas County.

Now, if you know your actual latitude and longitude, there are a couple of ingenious ways that you can supply this to the Firefox browser so that it can offer the correct location to websites. But these methods, which have been blogged about elsewhere, have two drawbacks: First, there are several manual steps. You must find out your latitude and longitude, and then you must carefully update your browser with the information. Second, you must do this each time your location changes.

But Google Latitude lets me simply click on a map to set my exact location. So I came up with a refinement of the manual method. I arranged for Firefox to ask Google Latitude for my location.

First, I built a small web page which finds out my Google Latitude location and supplies it to Firefox when asked. For the time being, I have made this web page public so anyone can use it. If it becomes so popular that my web server cannot handle the demand, I will restrict its use. I hope other people will also make this web page public on their servers, so I am reproducing the page source code at the end of this article.

Second, I made my location public in Google Latitude using the Google Public Location Badge option. From the code snippet for the Badge, I copied my user code, which in my case was a large negative number.

Third, I opened about:config in Firefox, and changed the value of geo.wifi.uri from the default value to http://archweaver.com/geol?user= and pasted my user code after the equal sign.

And that was it. Now, when I click to set my Google Latitude location, Firefox passes that location on to websites such as Gowalla.

Incidentally, when I want to restore the default behavior, I simply reopen about:config, right-click on geo.wifi.uri, and choose Reset.

Here is the PHP code mentioned above:

 1 <?php
 2 // geol.php - pass Google Latitude location to Firefox.
 3 // Author: MetaEd. Update: 2011-12-21.
 4 
 5 // Identify this program's output as JSON.
 6 header('Content-type: application/json');
 7 
 8 // Get Google Latitude Badge as JSON, using the key provided. The
 9 // cast to integer protects the URI from attack.
10 $badgeKey = (int) $_GET['user'] ;
11 $badgeUri = 'http://www.google.com/latitude/apps/badge/api?user='
12   . $badgeKey
13   . '&type=json' ;
14 $badgeJson = file_get_contents( $badgeUri ) ;
15 $badgeObject = json_decode( $badgeJson ) ;
16 
17 // Read the latitude and longitude from the badge.
18 $longitude = $badgeObject->{'features'}[0]->{'geometry'}
19   ->{'coordinates'}[0] ;
20 $latitude = $badgeObject->{'features'}[0]->{'geometry'}
21   ->{'coordinates'}[1] ;
22 $accuracy = $badgeObject->{'features'}[0]->{'properties'}
23   ->{'accuracyInMeters'} ;
24 
25 // Encode the geolocation in JSON and write it to Firefox.
26 // There are two encodings. Firefox 8 and older request the old 
27 // encoding using the POST method; Firefox 9 and newer request the 
28 // new encoding using the GET method.
29 switch($_SERVER['REQUEST_METHOD'])
30 {
31   case 'POST' : // Firefox 8 and older
32   $geoArray = array(
33     'location'=>array(
34       'latitude'=>$latitude
35         ,
36       'longitude'=>$longitude
37         ,
38       'accuracy'=>$accuracy
39     )
40   ) ;
41   $geoJson = json_encode( $geoArray ) ;
42   break ;
43 
44   case 'GET' : // Firefox 9 and newer
45   $geoArray = array(
46     'status'=>'OK'
47       ,
48     'accuracy'=>$accuracy
49       ,
50     'location'=>array( 'lat'=>$latitude , 'lng'=>$longitude )
51   ) ;
52   break ;
53 }
54 
55 $geoJson = json_encode( $geoArray ) ;
56 echo $geoJson ;
57 ?>

I want to be very plain that this work is preliminary. I could do a much better job of explaining the step by step instructions for setting this up. I could also do a much better job of input validation and exception handling. But I wanted to get the word out that this is really very easy to do, and get some real world feedback that would direct my efforts.

So if you give it a try, please comment here. Mention any trouble you run into, and also let me know what you are using it for.

Cheers!

Labels: , , , , , , ,

(go to complete article)

Share:

15 comments

Pumpkin Pie Mea

by Scrvpvlvs
Nov 25, 2010 1:53 AM–Scrvpvlvs likes to make pumpkin pie every holiday season. His pies are a little different every year. Here is this year’s pie recipe.

Notes on measurement

Measurements: by volume, using customary United States cooking units of measure

Abbreviations: C = cup, T = tablespoon, t = teaspoon, °F = degrees Fahrenheit

Gather materials

1 small (6–8” diameter) pumpkin, heavy for its size
flour
eggs
cream
olive oil
sugar
salt
ground cinnamon
ground nutmeg
ground ginger
ground cloves
ground coriander
ground paprika (smoked okay)

oven heated to 375 °F
two baking pans having a lip
two or three pie pans
large kitchen knife
measuring cups and spoons
large spoon
fork or toothpick
dough cutter or two knives
small bowl
medium bowl
large bowl
rolling pin
rolling surface

Roast pumpkin

Cut the pumpkin in half at its middle with the knife. Pull out the seeds with pursed fingers and thumb and save the seeds in the small bowl. Scrape out and discard the slimy, fibrous strands which held the seeds. Place halves cut side down on a baking pan. Put in the oven to roast.

The pumpkin is ready to remove when fragrant pumpkin juice is bubbling in the baking pan and a fork or toothpick goes in easily and comes out clean. Remove the pan from the oven and set aside to cool enough to handle. Scoop the meat of the pumpkin out of the rind and into the large bowl. Discard the rind.

Roast seeds

This can be started as soon as the pumpkin is in the oven.

Combine 1 T olive oil, 1 T sugar, 1 t cinnamon, ½ t paprika, and ½ t coriander with the seeds in the small bowl. Spread on the second baking pan. Put the pan in the oven to roast with the pumpkin.

The seeds are ready to remove when they have begun to darken. Remove the pan from the oven. Rinse the bowl and the spoon; scoop the roasted seeds into the bowl.

Pie crust

For each pie, thoroughly mix 1 C flour and ½ t salt in the medium bowl. Cut in ⅓ C shortening. Sprinkle and cut in 3 T water. Form a ball on a floured surface. Flour the ball and the rolling pin. Roll out to fit the pie pan. Fold in quarters. Unfold in the pie pan and cut off the excess.

Pie filling and baking

Mash and mix thoroughly together with the pumpkin meat in the large bowl:

1 ½ C cream
6 eggs
¾ C sugar
1 ½ t ground cinnamon
1 ½ t ground ginger
¾ t salt
¾ t ground cloves
½ t ground nutmeg (note half of that used this year for lack of enough)

Pour the filling into the crusts, leaving at least ¼ inch for expansion. Put in the oven to bake for 45–60 minutes depending on the size of pie. The pie is ready to remove when the crust and filling have browned, the filling has swelled up, and a fork or toothpick comes out of the filling clean. Remove the pie and let it cool.

Extra crust dough can be scattered with sugar and cinnamon and baked in the oven to a light brown.

Labels: , ,

(go to complete article)

Share:

0 comments

Eddys Found In the Space-Time Continuum

by Scrvpvlvs
Nov 20, 2010 4:27 PM–Ripples in the background glow of the Universe may be caused by huge explosions that occurred before the Big Bang, say well respected physicists.

Doctors V. G. Gurzadyan and Roger Penrose have circulated a new paper on the history of the Universe.

They are looking at the idea that the Big Bang is a recurring event. If their particular idea is right, then there were clusters of galaxies before the Big Bang. In them, super-massive black holes collided numerous times, resulting in violent explosions on an intergalactic scale.

Their idea predicts that these energy bursts were so huge that we should still be able to see evidence of them today in the background glow of the Universe---as concentric ring patterns, like ripples in a pond.[1]

The background glow of the Universe was predicted in 1948, and first detected in the 1960's. Since then, radio astronomers have been observing and mapping its features. (Click for a full size map.)[2]

The new paper concludes that concentric ring patterns are, in fact, faintly visible in the best maps of the background glow, just as the idea predicts!

This is a very interesting development in astrophysics, and I look forward to reading the reactions of other physicists around the world.

1. Photograph by Roger McLassus.

2. Map of the background glow of the Universe courtesy of NASA.

Labels: , , , , , , , , ,

(go to complete article)

Share:

0 comments

rad50.pl - interpret quadragesimal numbers

by Scrvpvlvs
Nov 19, 2010 6:43 AM–
  1 #! /usr/bin/perl
  2
  3 # Title:
  4 #   rad50.pl
  5 #
  6 # Author:
  7 #   MetaEd
  8 #
  9 # Version:
 10 #   November 22, 3732
 11 #
 12 # This document is a Perl 5 program which will:
 13 #
 14 #   1. take a line of text as input
 15 #
 16 #   2. interpret it as a string of three-digit quadragesimal numbers
 17 #
 18 #        NOTE: Quadragesimal notation is analogous to octal,
 19 #        decimal, and hexadecimal notation. Octal uses eight symbols
 20 #        (numerals), decimal uses ten, hexadecimal uses sixteen, and
 21 #        quadragesimal notation uses forty numerals.
 22 #
 23 #   3. convert each such number to six-digit octal numbers
 24 #
 25 #   4. type the octal numbers as a line of text
 26 #
 27 #   5. stop
 28 #
 29 # Sample input:
 30 #   "Nothing sucks like a VAX."
 31 #
 32 # Interpretation as quadragesimal numbers:
 33 #   "NOT/HIN/G S/UCK/S L/IKE/ A /VAX/.  "
 34 #
 35 #     NOTE: The interpretation is not case sensitive. If the last
 36 #     number is incomplete, it is padded on the right with space.
 37 #
 38 # Sample output:
 39 #   054754 031566 025723 101703 073314 034775 000050 104700 127400\n
 40
 41 # First, we declare the forty symbols we recognize as quadragesimal
 42 # numerals.
 43
 44 $_ =
 45 $numerals =
 46 $digital020 = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ$.%0123456789' ;
 47   # ' ' (space) = zero, 'A' = one, ..., 'V' = twenty-two, ...
 48
 49 $digital044 = ' 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ.$%' ;
 50   # ' ' (space) = zero, 'A' = eleven, ..., 'V' = thirty-two, ...
 51
 52 #   NOTE: Two different notation schemes are commonly used. These
 53 #   originate from Digital Equipment Corporation (DEC) sixteen bit
 54 #   systems and DEC thirty-six bit systems, respectively. The same
 55 #   symbols are used by both schemes, but the ordering is different.
 56 #   For our purpose, we adapt the sixteen bit ordering.
 57
 58 # We create a hash table which maps each numeral to its number.
 59
 60 %rad050 = map( ($_ => $i++), split // ) ;
 61
 62 #   NOTE: These schemes (both of them) are better known to systems
 63 #   programmers as Radix 50. Why Radix 50, not Radix 40? Because 50
 64 #   (octal) = 40 (decimal). Ask a silly question, get a silly
 65 #   answer.
 66
 67 # We read input from a literal string, and transform it to valid
 68 # input.
 69
 70 $_ = "Nothing sucks like a VAX." ;
 71 tr/[a-z]/[A-Z]/ ;                 # convert lower case to UPPER CASE
 72 eval "tr/$numerals//cd" ;         # delete any illegal character
 73 $_ .= '  ' ;                      # pad the last number with space
 74
 75 # We create an accumulator to hold intermediate values during
 76 # interpretation, a place counter to keep track of what place of the
 77 # quadragesimal number we're on, and a string to hold the result.
 78
 79 $accum = 0 ;
 80 $place = 0 ;
 81 $output = '' ;
 82
 83 # We consider each numeral in turn from left to right.
 84
 85 foreach( split // ) {
 86
 87   # As a failsafe, we assert that the current numeral can be
 88   # interpreted quadragesimally. If not, we construct an identifying
 89   # error message and stop.
 90
 91   index( $numerals, $_ ) >= 0
 92     or
 93   die "$0: current numeral: "
 94   . ( /^[[:graph:]]$/ ? $_ : sprintf("<%#o>",ord($_)))
 95   . "\nILLEGAL FILE NAME\n" ;
 96
 97   # We shift the accumulated value left one quadragesimal place to
 98   # make room for the value corresponding to the current numeral,
 99   # taken from the hash table.
100
101   $accum = $accum * 050 + $rad050{$_} ;
102
103   # If the place counter tells us the number is complete, we write
104   # it in octal with a space separator, and reset the accumulator
105   # and the place counter.
106
107   if ( $place++ == 2 ) {
108     $output .= sprintf "%06o ", $accum ;
109     $accum = 0 ;
110     $place = 0 ;
111   }
112
113 }
114
115 # At the end, we type the line of output.
116
117 print $output, "\n" ;
118
119 # HISTORICAL NOTE: Systems programmers used quadragesimal (Radix 50)
120 # numbers to economize on memory needed to store text: for example,
121 # file names in the disk index. Consider the file name "NONAME".
122 # Storing it as a string of six ASCII codes would cost forty-eight
123 # bits:
124 #
125 #   N        O        N        A        M        E
126 #   01001110 01001111 01001110 01000001 01001101 00100101
127 #
128 # But storing it as a string of two three-digit quadragecimal
129 # numbers would cost sixteen fewer bits:
130 #
131 #   NON               AME
132 #   01011001 11100110 00001000 01001101
133 #
134 # Economy was traded for convenience. File names were limited to the
135 # repertoire of forty quadragesimal numerals. And conversions to and
136 # from quadragesimal were arcane, despite the availability of tools
137 # in the system library. For example, here's how the PDP-11 RSTS/E
138 # systems programmer could store a file name as a quadragesimal
139 # number with this technique, saving sixteen bits of memory:
140 #
141 # 1000    T$ = "NONAME"                                     ! ASCII
142 # 1010    T$ = MID(SYS(CHR$(6%) + CHR$(-10%) + T$), 7%, 4%) ! RAD50
143 #
144 # And here's how the programmer could recover the file name as text:
145 #
146 # 2000    CHANGE T$ TO T%
147 # 2010    T$ = RAD$(      T%(0%)
148 #                 + SWAP%(T%(1%))
149 #            + RAD$(      T%(2%)
150 #                 + SWAP%(T%(3%))
151 #
152 # Or:
153 #
154 # 2000    T$ = RAD$(      ASCII(MID(T$,0%,1%))
155 #                 + SWAP%(ASCII(MID(T$,1%,1%))))
156 #            + RAD$(      ASCII(MID(T$,2%,1%))
157 #                 + SWAP%(ASCII(MID(T$,3%,1%))))
158
159 # vim:set sw=2 sts=2 tw=68 : Instructions for Vim, the text editor.

Labels: , , , , , , , , , , , , , , , , ,

(go to complete article)

Share:

0 comments

Out Of Kindness, Play Dumb

by Scrvpvlvs
Nov 11, 2010 6:43 AM–Sometimes the nicest thing you can do for others is refuse to cooperate.

When patrons and employees of a restaurant franchise in my area want the corporate office, they ask at a restaurant for the number. Sometimes the restaurant manager mistakenly gives them my company's number. (It's an easy mistake; theirs ends 0888 and ours ends 0088.)

The trouble comes when my kind receptionist gives the caller—who has a real and urgent problem such as a missing paycheck or a case of food poisoning—the right number. This positively reinforces the mistake. Any restaurant manager that makes the mistake gets to know the wrong number from memory, and continues to supply it. Over time, we get more and more phone calls for the franchise. This represents frustration and a waste of time on the part of the callers and my receptionist.

The kindest thing to do is never, ever, cooperate with the caller by giving the right number. Instead, we play dumb. Callers push the problem back on the restaurant manager. The restaurant manager soon gets to know and give out the right number. The result is less frustration and less waste of time, both ours and future callers.

This principle has many applications. Before you offer help and advice in a situation, consider whether the kindest thing to do might be to play dumb.

Labels: , , ,

(go to complete article)

Share:

0 comments

Oklahoma law banning Islamic law could also ban Biblical law

by Scrvpvlvs
Nov 5, 2010 5:51 PM–Oops! The Oklahoma law that Oklahoma voters just approved, banning Islamic law from their courts, could ban Biblical law also. #UnintendedConsequences

The people of Oklahoma amended their Constitution by adopting State Question No. 755, Legis. Ref. No. 355, by a vote of 70%‒30% at the November 2, 2010 election.

They have forbidden their courts to look to the legal precepts of other nations or cultures when deciding cases. Specifically, the courts shall not consider international law or Sharia Law.

There is an irony here.

The amendment, legally known as the “Save Our State Amendment”, strongly appealed to the Christian majority of the people of Oklahoma because of its rejection of Sharia Law. The Attorney General of Oklahoma described Sharia Law on the State Question as Islamic law […] based on two principal sources, the Koran and the teaching of Mohammed.

But Dr. Joseph Thai, a University of Oklahoma law professor, pointed out that the new law could also forbid their courts to consider Biblical law: The Ten Commandments, of course, is international law. It did not originate in Oklahoma or the United States. (Quoted in this AP article.)

So Oklahomans who would like to see Biblical law established in their state may have created a new obstacle for themselves. And, by doing so, arguably they have violated Biblical law:

You will not curse the dumb or put an obstacle in the way of the blind, but will fear your God. I am Yahweh.
(Leviticus 19:14, quoted from the New Jerusalem Bible.)

I guess it’s fortunate for them that they cannot be prosecuted for it in their state courts.

Here is the old and new text of Okla. Const. Art. 7 § 1 from the State Question:

Section 1. A. The judicial power of this State shall be vested in Senate, sitting as a Court of Impeachment, a Supreme Court, the Court of Criminal Appeals, the Court on the Judiciary, the State Industrial Workers’ Compensation Court, the Court of Bank Review, the Court of Tax Review, and such intermediate appellate courts as may be provided by statute, District Courts, and such Boards, Agencies and Commissions created by the Constitution or established by statute as exercise adjudicative authority or render decisions in individual proceedings. Provided that the Court of Criminal Appeals, the State Industrial Court, the Court of Bank Review and the Court of Tax Review and such Boards, Agencies and Commissions as have been established by statute shall continue in effect, subject to the power of the Legislature to change or abolish said Courts, Boards, Agencies, or Commissions. Municipal Courts in cities or incorporated towns shall continue in effect and shall be subject to creation, abolition or alteration by the Legislature by general laws, but shall be limited in jurisdiction to criminal and traffic proceedings arising out of infractions of the provisions of ordinances of cities and towns or of duly adopted regulations authorized by such ordinances.

B. Subsection C of this section shall be known as the “Save Our State Amendment”.

C. The Courts provided for in subsection A of this section, when exercising their judicial authority, shall uphold and adhere to the law as provided in the United States Constitution, the Oklahoma Constitution, the United States Code, federal regulations promulgated pursuant thereto, established common law, the Oklahoma Statutes and rules promulgated pursuant thereto, and if necessary the law of another state of the United States provided the law of the other state does not include Sharia Law, in making judicial decisions. The courts shall not look to the legal precepts of other nations or cultures. Specifically, the courts shall not consider international law or Sharia Law. The provisions of this subsection shall apply to all cases before the respective courts including, but not limited to, cases of first impression.


Update Nov 8, 2010

A friend wrote to ask: “This passed by a wide margin—who’s to say that the ban on biblical law, ten commandments, etc. was unintentional?”

Oklahoma’s Department of Libraries says there is very little record of legislative intent. The legislature does not publish floor debate, committee reports, minutes, or hearings. (source)

But the two primary authors have said that they meant to ban Sharia law. And based on their voting records and other activities, I cannot believe that they meant to ban Biblical law. In fact I am sure they want just the opposite.

Rep. Rex Duncan (R) said that foreign influence has undermined the legal systems of other democratic states, specifically Great Britain and Michigan. He said the amendment will constitute a pre-emptive strike against Sharia law coming to Oklahoma. (source) Rep. Duncan has reportedly voted yes on bills requiring the Ten Commandments be posted at the entrance to the state Capitol. (source)

Sen. Anthony Sykes (R) stated that Sharia law coming to the U.S. is a scary concept. Hopefully the passage of this constitutional amendment will prevent it in Oklahoma. (source) Not long ago, Sen. Sykes was a featured participant at a “Reclaiming Oklahoma for Christ” event. The mission statement of this organization is to educate our pastors, legislators, educators, students and all citizens as to the truth about America’s Christian Heritage and the role of fundamental, Biblical Christianity in the establishment and function of our legal, legislative and educational systems; and to work towards the successful reestablishment of these values in our society today. (source)

Labels: , , , , , , , , , , , , , ,

(go to complete article)

Share:

1 comments

About Roundup: Part 1, Preface and Introduction

by Scrvpvlvs
Nov 2, 2010 7:04 AM–Permit me to introduce you to Roundup, a chemical product invented by Monsanto Corporation. Roundup needs no introduction to you; Roundup has come in contact with you before, whether you knew it or not.

Preface

You are reading the first of a series of columns about Roundup, in which I introduce you to the product and why I think it is worth writing about. In later columns, I present the benefits and hazards of using it. The last column will pull together my conclusions and advice. I begin this project not knowing what my conclusions and advice will be, so I am quite curious myself! But I will take my time and try to get everything right, so we will just have to be patient and wait and see together.

A bottle of Roundup turned up during housecleaning not long ago, and our question was, what should we do with it? Answering this question is what these articles are really about. At the end, I hope I know whether it is best to turn it in to the local Environmental Collection Center, give it to a friend, or use it on my lawn and driveway. Even if by then we have already turned it in, at least I will know what I should have done! Anyway, that question is the scrupulus behind this project. So now let’s get started.

Introduction

Roundup was invented by Monsanto Corporation to control the growth of plants. Inside the bottle or the barrel, the product is a liquid mixture of two substances. One is glycine phosphonate, known as glyphosate, a chemical that blocks plant growth. The other is a liquid detergent which helps the glyphosate spread out and soak quickly into the leaves.

In my country, the United States, we apply about 100 million pounds of glyphosate to the land every year, more than any other herbicide (plant killing chemical). We apply it on crop lands, lawns, and gardens to kill or slow the growth of plants.

100 million pounds is more than any other chemical we use in the United States to control plant growth. It is three-fourths of a cup for each person. It is 1 rounded tablespoon for every city block (that is, if we divided all of the land into city blocks and applied an equal amount to every block).

This is why I say Roundup needs no introduction to you. It has come into contact with you before, whether you knew it or not.

Please let me know your thoughts about the project, so that I can approach it from more points of view. And watch for the next column in the series!

Labels: , , , , , , ,

(go to complete article)

Share:

0 comments

about.me

Follow

feed

E-mail: enter address

Project Euler competitor metaed

vs.

Project Euler competitor db8

profile for MetaEd on Stack Exchange, a network of free, community-driven Q&A sites

Recent Articles

Cataclysm

Open letter re: Grinnell College alumni “lifetime”...

Spybot – Search & Destroy interferes with Lync 201...

A moment of silence

Rondeau

Howard Schultz of Starbucks: firm on support for m...

In each of us, two natures are at war

Clorox does not understand how to measure bleach

This season’s pie recipe

Adamah

Archives

November 1999
June 2000
July 2000
September 2001
October 2001
February 2002
March 2002
June 2003
February 2004
June 2004
July 2004
August 2004
September 2004
February 2005
March 2005
November 2005
July 2007
March 2008
April 2008
May 2008
October 2008
November 2008
December 2008
January 2009
April 2009
September 2009
December 2009
February 2010
March 2010
May 2010
June 2010
September 2010
October 2010
November 2010
December 2010
January 2011
April 2011
June 2011
July 2011
August 2011
September 2011
December 2011
February 2012
April 2012
May 2012
June 2012
July 2012
August 2012
September 2012
November 2012
January 2013
February 2013
April 2013
February 2014
May 2014
October 2014
June 2017
February 2019