Ben - Last comments http://nonplatonic.com/ben.php?disp=comments en-US hourly 1 2000-01-01T12:00+00:00 In response to: python: xml to dict, bow to my recursive genius http://nonplatonic.com/ben.php?title=python_xml_to_dict_bow_to_my_recursive_g&more=1&c=1&tb=1&pb=1#c1746980 2011-07-17T00:18:14Z Francisco [Visitor] I added some changes to the child loop (in elementtodict(parent)) in order to avoid the list excess in the result: while child is not None: if child.nodeType == Node.ELEMENT_NODE: try: d[child.tagName] except KeyError: d[child.tagName] = elementtodict(child) else: #first time that I use the try's else if type(d[child.tagName]) != list: d[child.tagName] = [d[child.tagName]] d[child.tagName].append(elementtodict(child)) child = child.nextSibling while child is not None:
if child.nodeType == Node.ELEMENT_NODE:
try:
d[child.tagName]
except KeyError:
d[child.tagName] = elementtodict(child)
else: #first time that I use the try's else
if type(d[child.tagName]) != list:
d[child.tagName] = [d[child.tagName]]
d[child.tagName].append(elementtodict(child))
child = child.nextSibling
]]>
In response to: The Ben in the High Castle http://nonplatonic.com/ben.php?title=the_high_floor&more=1&c=1&tb=1&pb=1#c1746978 2011-07-16T22:40:21Z ben [Member] http://openbuildings.com/buildings/crane-rooms-profile-1671 http://openbuildings.com/buildings/crane-rooms-profile-1671]]> In response to: George Carlin and Stuff http://nonplatonic.com/ben.php?title=george_carlin_and_stuff&more=1&c=1&tb=1&pb=1#c1746108 2011-07-05T16:16:48Z Pat Burns [Visitor] I think of my books as carbon storage. In response to: Gargoyle Cowboy http://nonplatonic.com/ben.php?title=gargoyle_cowboy&more=1&c=1&tb=1&pb=1#c1745904 2011-07-03T20:32:45Z ben [Member] It looks like putting together what I'm imagining would cost something like $10,000. I suppose I'll wait another 5 years and look again. I'm thinking about buying a Lenovo X220T to replace my work computer. It seems like it would be a good ubiquitous thing to cart around the country.
I'm thinking about buying a Lenovo X220T to replace my work computer. It seems like it would be a good ubiquitous thing to cart around the country.]]>
In response to: Heat Death http://nonplatonic.com/ben.php?title=heat_death&more=1&c=1&tb=1&pb=1#c1725388 2010-11-30T22:27:05Z ben [Member] My little heat death argument goes something like this: imagine the universe trillions of years from now. The stars have all died. Matter has dispersed to a state of maximum entropy. Everything is gone -- all that man or anything else might have created has disappeared. From the perspective of a historically naive hypothetical observer at this point it is impossible to determine whether anything of interest (humanity, art, whatever the meaning of life is) ever existed because the universe now sits at the same state it would have if nothing had ever existed. Given this inevitable outcome, and the insistence of thermodynamics that it will come to pass, then life can have no meaning. Some might argue that only reinforces the transitory precious nature of life, but such an argument willfully ignores the final, dreadful outcome. From a purely rational standpoint, given what I understand about how the universe works, it makes no difference if I live a long, useful life or die pointlessly this instant. Of course, there are ways out: (1) Maybe the universe isn't closed (then, in the words of MCJB3, we wouldn't all be hosed). (2) Maybe there are lots of universes and they interact and we can pass information between them, thereby giving some longer, hopefully perpetual, meaning to our lives (3) Some other option neglected due to my poor understanding of physics (4) Maybe there is something supernatural, some sort of afterlife, metaphysical force or something that can be used to give meaning to an otherwise bleak existence. I still remember having this conversation while staring at a starry sky, imagining the lights going out. That led to another issue I am also nervous that some piece of enormously dense matter will come wandering through the solar system, causing the earth to go careening off its typical orbit into interstellar space. That would make a much more frightening movie than all those asteroid apocalypse ones.
From the perspective of a historically naive hypothetical observer at this point it is impossible to determine whether anything of interest (humanity, art, whatever the meaning of life is) ever existed because the universe now sits at the same state it would have if nothing had ever existed.

Given this inevitable outcome, and the insistence of thermodynamics that it will come to pass, then life can have no meaning.

Some might argue that only reinforces the transitory precious nature of life, but such an argument willfully ignores the final, dreadful outcome.

From a purely rational standpoint, given what I understand about how the universe works, it makes no difference if I live a long, useful life or die pointlessly this instant.

Of course, there are ways out:
(1) Maybe the universe isn't closed (then, in the words of MCJB3, we wouldn't all be hosed).
(2) Maybe there are lots of universes and they interact and we can pass information between them, thereby giving some longer, hopefully perpetual, meaning to our lives
(3) Some other option neglected due to my poor understanding of physics
(4) Maybe there is something supernatural, some sort of afterlife, metaphysical force or something that can be used to give meaning to an otherwise bleak existence.

I still remember having this conversation while staring at a starry sky, imagining the lights going out. That led to another issue

I am also nervous that some piece of enormously dense matter will come wandering through the solar system, causing the earth to go careening off its typical orbit into interstellar space. That would make a much more frightening movie than all those asteroid apocalypse ones.
]]>
In response to: Merlin http://nonplatonic.com/ben.php?title=merlin&more=1&c=1&tb=1&pb=1#c1719301 2010-11-04T17:24:17Z Devin [Visitor] We learned about Arthur-Merlin protocols in my complexity theory class today. In response to: Heat Death http://nonplatonic.com/ben.php?title=heat_death&more=1&c=1&tb=1&pb=1#c1718184 2010-11-02T03:55:55Z Leonid Korogodski [Visitor] I'm happy that you have enjoyed the book. I wonder about the old concerns of yours that you mentioned in your post. In response to: Heat Death http://nonplatonic.com/ben.php?title=heat_death&more=1&c=1&tb=1&pb=1#c1718059 2010-11-01T14:20:58Z ben [Member] Thanks for note! I actually already ordered the Beinhocker book. After finishing Pink Noise I went through and probably picked up 3/4 of the books in the bibliography. Looking forward to reading them... Pink Noise I went through and probably picked up 3/4 of the books in the bibliography. Looking forward to reading them...]]> In response to: Heat Death http://nonplatonic.com/ben.php?title=heat_death&more=1&c=1&tb=1&pb=1#c1717965 2010-11-01T06:34:28Z Leonid Korogodski [Visitor] Thanks. On the evolutionary approach to economics, I highly recommend Origin of Wealth: Evolution, Complexity, and the Radical Remaking of Economics by Eric D. Beinhocker. Origin of Wealth: Evolution, Complexity, and the Radical Remaking of Economics by Eric D. Beinhocker.]]> In response to: python: xml to dict, bow to my recursive genius http://nonplatonic.com/ben.php?title=python_xml_to_dict_bow_to_my_recursive_g&more=1&c=1&tb=1&pb=1#c1699061 2010-08-12T22:54:36Z Nan [Visitor] I adapted elementtodict to use numeric values instead of strings for actual numeric values, as well as base types instead of lists when there is only one element with a given name: def elementtodict(parent): child = parent.firstChild if (not child): return None elif (child.nodeType == xml.dom.minidom.Node.TEXT_NODE): val = child.nodeValue try: if '.' in val: val = float(val) else: val = int(val) except ValueError: pass return val d={} while child is not None: if (child.nodeType == xml.dom.minidom.Node.ELEMENT_NODE): try: d[child.tagName] except KeyError: d[child.tagName]=[] d[child.tagName].append(elementtodict(child)) child = child.nextSibling for key, val in d.items(): if type(val) is list and len(val) == 1: d[key] = val[0] return d
def elementtodict(parent):
child = parent.firstChild
if (not child):
return None
elif (child.nodeType == xml.dom.minidom.Node.TEXT_NODE):
val = child.nodeValue
try:
if '.' in val:
val = float(val)
else:
val = int(val)
except ValueError:
pass
return val

d={}
while child is not None:
if (child.nodeType == xml.dom.minidom.Node.ELEMENT_NODE):
try:
d[child.tagName]
except KeyError:
d[child.tagName]=[]
d[child.tagName].append(elementtodict(child))
child = child.nextSibling
for key, val in d.items():
if type(val) is list and len(val) == 1:
d[key] = val[0]
return d
]]>
In response to: python: xml to dict, bow to my recursive genius http://nonplatonic.com/ben.php?title=python_xml_to_dict_bow_to_my_recursive_g&more=1&c=1&tb=1&pb=1#c1668359 2010-01-11T19:59:49Z qkiss [Visitor] Sorry for the code... I hope this one will be better. from xml.dom.minidom import parse, Node def xmltodict(filename): doc = parse(filename) return elementtodict(doc.documentElement) def elementtodict(parent): child = parent.firstChild if not child: return None while child.nodeType == Node.TEXT_NODE and not child.data.strip(): child = child.nextSibling if child.nodeType == Node.TEXT_NODE: return child.nodeValue d={} while child is not None: if (child.nodeType == Node.ELEMENT_NODE): try: d[child.tagName] except KeyError: d[child.tagName]=[] d[child.tagName].append(elementtodict(child)) if len(d[child.tagName]) == 1: d[child.tagName] = d[child.tagName][0] child = child.nextSibling return d

from xml.dom.minidom import parse, Node

def xmltodict(filename):
doc = parse(filename)
return elementtodict(doc.documentElement)

def elementtodict(parent):
child = parent.firstChild
if not child:
return None
while child.nodeType == Node.TEXT_NODE and not child.data.strip():
child = child.nextSibling
if child.nodeType == Node.TEXT_NODE:
return child.nodeValue

d={}
while child is not None:
if (child.nodeType == Node.ELEMENT_NODE):
try:
d[child.tagName]
except KeyError:
d[child.tagName]=[]
d[child.tagName].append(elementtodict(child))
if len(d[child.tagName]) == 1:
d[child.tagName] = d[child.tagName][0]
child = child.nextSibling
return d
]]>
In response to: python: xml to dict, bow to my recursive genius http://nonplatonic.com/ben.php?title=python_xml_to_dict_bow_to_my_recursive_g&more=1&c=1&tb=1&pb=1#c1668358 2010-01-11T19:58:29Z qkiss [Visitor] Hi, Thanks for the simple solution, just what I was looking for. I changed it a bit and removed the remove_whilespace_nodes function. Hope it will also help someone. from xml.dom.minidom import parse, Node def xmltodict(filename): doc = parse(filename) return elementtodict(doc.documentElement) def elementtodict(parent): child = parent.firstChild if not child: return None while child.nodeType == Node.TEXT_NODE and not child.data.strip(): child = child.nextSibling if child.nodeType == Node.TEXT_NODE: return child.nodeValue d={} while child is not None: if (child.nodeType == Node.ELEMENT_NODE): try: d[child.tagName] except KeyError: d[child.tagName]=[] d[child.tagName].append(elementtodict(child)) if len(d[child.tagName]) == 1: d[child.tagName] = d[child.tagName][0] child = child.nextSibling return d qkiss
Thanks for the simple solution, just what I was looking for.

I changed it a bit and removed the remove_whilespace_nodes function. Hope it will also help someone.

from xml.dom.minidom import parse, Node

def xmltodict(filename):
doc = parse(filename)
return elementtodict(doc.documentElement)

def elementtodict(parent):
child = parent.firstChild
if not child:
return None
while child.nodeType == Node.TEXT_NODE and not child.data.strip():
child = child.nextSibling
if child.nodeType == Node.TEXT_NODE:
return child.nodeValue

d={}
while child is not None:
if (child.nodeType == Node.ELEMENT_NODE):
try:
d[child.tagName]
except KeyError:
d[child.tagName]=[]
d[child.tagName].append(elementtodict(child))
if len(d[child.tagName]) == 1:
d[child.tagName] = d[child.tagName][0]
child = child.nextSibling
return d

qkiss]]>
In response to: I should join the Porsche club. http://nonplatonic.com/ben.php?title=i_should_join_the_porsche_club&more=1&c=1&tb=1&pb=1#c1665163 2009-08-03T09:19:48Z yang [Visitor] buy ed hardy cheap ed hardy cheap ed hardy]]> In response to: Program Trading http://nonplatonic.com/ben.php?title=program_trading&more=1&c=1&tb=1&pb=1#c1665113 2009-06-12T11:28:30Z JOHNNY JOHNNY [Visitor] used to use IB.. they are not bad In response to: I finally built a closet. http://nonplatonic.com/ben.php?title=i_finally_built_a_closet&more=1&c=1&tb=1&pb=1#c1664947 2009-04-20T22:25:54Z ben [Member] I build everything. I'm awesome. Yay shit drills and 2x4s! In response to: I finally built a closet. http://nonplatonic.com/ben.php?title=i_finally_built_a_closet&more=1&c=1&tb=1&pb=1#c1664946 2009-04-20T18:15:39Z graham [Member] So how did you end up building it? I'm a little disappointed that it's not 15 feet long. In response to: my place http://nonplatonic.com/ben.php?title=my_place&more=1&c=1&tb=1&pb=1#c1664906 2009-01-16T17:13:35Z graham [Member] Hey... that looks a lot better than what you've described to me. In response to: Ben wants a closet. http://nonplatonic.com/ben.php?title=title_222&more=1&c=1&tb=1&pb=1#c1664904 2009-01-13T00:27:59Z collin [Member] You're drawings are very crappy. Those telescoping supports are called house jacks (I think). And you don't need them since they're made for 5-20 tons. I would just use steel pipe and fittings, but those can get expensive surprisingly quickly. Do you remember the thing I have for my skis? -2 3/4"x2' pipe -2 end caps -2 flanges -2 pieces 1/4" cable -2 turnbuckles -2 eye bolts -some u-bolts and drywall screws I think it was about $50. I've got ~6 pairs of skis and 2 paddles on it right now. If I were you I'd put the flanges on the brick not the tile, drilling into the brick not the mortar and use expansion bolts. You could just have a vertical cable like I did, with an eybolt in a joist. Or have a vertical pipe with a flange resting on the floor. I don't think you'd need to attach it to the floor, maybe stick a piece of rubber on the bottom. Then the only thing you'd need to patch are some holes in the brick.
Those telescoping supports are called house jacks (I think). And you don't need them since they're made for 5-20 tons. I would just use steel pipe and fittings, but those can get expensive surprisingly quickly.

Do you remember the thing I have for my skis?
-2 3/4"x2' pipe
-2 end caps
-2 flanges
-2 pieces 1/4" cable
-2 turnbuckles
-2 eye bolts
-some u-bolts and drywall screws

I think it was about $50. I've got ~6 pairs of skis and 2 paddles on it right now.

If I were you I'd put the flanges on the brick not the tile, drilling into the brick not the mortar and use expansion bolts. You could just have a vertical cable like I did, with an eybolt in a joist. Or have a vertical pipe with a flange resting on the floor. I don't think you'd need to attach it to the floor, maybe stick a piece of rubber on the bottom.

Then the only thing you'd need to patch are some holes in the brick.]]>
In response to: Just wrote my congressman... http://nonplatonic.com/ben.php?title=just_wrote_my_congressman&more=1&c=1&tb=1&pb=1#c1664800 2008-10-18T15:22:43Z ben [Member] Oblivious, idiotic form Letter response from Senator Murray (also the reply-to murray@murray.senate.gov bounces) It's democracy in action: Dear Mr. Lackey: Thank you for contacting me about H.R. 1424, the Emergency Economic Stabilization Act of 2008. I appreciate hearing from you about this important issue. The U.S. Senate voted to pass this bill by a margin of 74-25 on Wednesday, October 1, 2008. H.R. 1424 is now being considered by the U.S. House of Representatives. As you know, in communities across America today, people are finding it increasingly difficult to fill up their tanks, pay for health care, and afford college tuition. Now, all Americans, even those who have paid their bills on time and have excellent credit, are at risk of being severely affected by the current credit freeze on Wall Street. People want to know if this crisis is real. I have asked the same question of Treasury Secretary Paulson and Federal Reserve Chairman Bernanke. I have spoken with economic experts and Washington state business leaders. Companies like Weyerhaeuser and Microsoft have made it clear that something must be done. Power utilities such as Avista and the farm groups such as the Farm Bureau have told me that the government's proposal to stabilize our financial markets is critically needed. Throughout various sectors of our economy, there is deep and genuine concern about market collapse and the potential impact on jobs, credit and pensions. We have already experienced a slowdown in home sales and construction. Our home state bank, Washington Mutual, was unable to withstand the crisis and was acquired by another institution. Millions of Americans have tried to obtain a loan or refinance their mortgage, but have found it increasingly difficult to find a willing line of credit and in many cases have been unable to do so at all. If this crisis worsens, credit could freeze completely for consumers and companies who use credit to pay their employees or run their business operations. The bottom line is that without a steady stream of credit, American businesses will not be able to pay their workers and Americans will lose their jobs. Because of the impact the financial crisis could have on all Americans, from layoffs to access to credit, I supported the Emergency Economic Stabilization Act of 2008. I understand the frustration of people who want those on Wall Street to be held accountable for their actions and shoulder the consequences of their own misdeeds. Americans are being confronted with two undesirable options. Either do nothing and let the crisis worsen, or take action and use taxpayer dollars to solve a problem they did not create. Americans are rightfully angry. However, those who created the problem will not be those who are hurt most if the government does not act. My top priority is to do what is best for the people of Washington State and the nation, and that is why I believe government action is urgently needed in this situation. The original plan presented to Congress by President Bush and Secretary Paulson was a non-starter. Congress rightly refused to give Secretary Paulson a blank check to spend hundreds of billions of dollars without oversight. Congress refused to allow executives of failing companies to walk away with millions of dollars in severance packages while taxpayers paid for their mistakes. This legislation is a more prudent agreement to anchor taxpayer dollars to strict Congressional oversight and scrutiny by independent economic experts. We added assistance for responsible borrowers hit by the foreclosure crisis and plans to recoup money from any institutions which use government money and then see a profit. In the future, it is possible that most, if not all, of the taxpayer money invested will be returned once this crisis comes to a close. Congress has to be vigilant in our oversight of how this law is implemented. I fought to ensure that every transaction that takes place regarding this funding will be on the Internet for all Americans to see. In addition, I strongly support the Federal Bureau of Investigation's (FBI) and other state and federal agencies' investigation into the wrongdoing related to the current crisis on Wall Street. If fraud and criminal activity are uncovered, the individuals responsible must be prosecuted to the fullest extent of the law. Congress must take a hard look at the factors that brought us to this point and seriously address them. Congress will be holding ongoing hearings into the causes of this crisis and the regulation reform that is desperately needed and has been missing throughout the duration of the Bush Administration. The next administration has to work with Congress to pass and implement new regulatory measures so that taxpayers are never put in this position again. It will take both investment and honesty to get our economy back on track. The next administration will inherit this economic crisis along with many other serious challenges. I hope our new President is honest with the American people about where we stand and what it will take to move America forward. I believe that to move America forward, we need to invest in the infrastructure and education that create economic growth and jobs. We have to invest in our workforce and find a way to make health care affordable and accessible. We have to increase funding for research and development and reward innovation. We have to implement a smart, forward-looking energy policy that ends our addiction to foreign oil. It is time to put America's families first and restore their faith that government works for, not against them. I grew up with a country at my back - one that when my own father got sick and could no longer work was there with Pell Grants and student loans and even food stamps when my family needed them. I will always remember that. I supported this legislation because the American dream of owning a home or going to college is simply too important to take a back seat to politics or to be put at risk by the misdeeds of Wall Street. As Congress continues to work to restore our economy, I will continue to stand up for our state and listen to your concerns. Thank you for contacting me, and please do not hesitate to contact me in the future. I hope all is well in Seattle.
Dear Mr. Lackey:

Thank you for contacting me about H.R. 1424, the Emergency Economic Stabilization Act of 2008. I appreciate hearing from you about this important issue. The U.S. Senate voted to pass this bill by a margin of 74-25 on Wednesday, October 1, 2008. H.R. 1424 is now being considered by the U.S. House of Representatives.

As you know, in communities across America today, people are finding it increasingly difficult to fill up their tanks, pay for health care, and afford college tuition. Now, all Americans, even those who have paid their bills on time and have excellent credit, are at risk of being severely affected by the current credit freeze on Wall Street.

People want to know if this crisis is real. I have asked the same question of Treasury Secretary Paulson and Federal Reserve Chairman Bernanke. I have spoken with economic experts and Washington state business leaders. Companies like Weyerhaeuser and Microsoft have made it clear that something must be done. Power utilities such as Avista and the farm groups such as the Farm Bureau have told me that the government's proposal to stabilize our financial markets is critically needed. Throughout various sectors of our economy, there is deep and genuine concern about market collapse and the potential impact on jobs, credit and pensions.

We have already experienced a slowdown in home sales and construction. Our home state bank, Washington Mutual, was unable to withstand the crisis and was acquired by another institution. Millions of Americans have tried to obtain a loan or refinance their mortgage, but have found it increasingly difficult to find a willing line of credit and in many cases have been unable to do so at all. If this crisis worsens, credit could freeze completely for consumers and companies who use credit to pay their employees or run their business operations. The bottom line is that without a steady stream of credit, American businesses will not be able to pay their workers and Americans will lose their jobs. Because of the impact the financial crisis could have on all Americans, from layoffs to access to credit, I supported the Emergency Economic Stabilization Act of 2008.

I understand the frustration of people who want those on Wall Street to be held accountable for their actions and shoulder the consequences of their own misdeeds. Americans are being confronted with two undesirable options. Either do nothing and let the crisis worsen, or take action and use taxpayer dollars to solve a problem they did not create. Americans are rightfully angry. However, those who created the problem will not be those who are hurt most if the government does not act. My top priority is to do what is best for the people of Washington State and the nation, and that is why I believe government action is urgently needed in this situation.

The original plan presented to Congress by President Bush and Secretary Paulson was a non-starter. Congress rightly refused to give Secretary Paulson a blank check to spend hundreds of billions of dollars without oversight. Congress refused to allow executives of failing companies to walk away with millions of dollars in severance packages while taxpayers paid for their mistakes. This legislation is a more prudent agreement to anchor taxpayer dollars to strict Congressional oversight and scrutiny by independent economic experts. We added assistance for responsible borrowers hit by the foreclosure crisis and plans to recoup money from any institutions which use government money and then see a profit. In the future, it is possible that most, if not all, of the taxpayer money invested will be returned once this crisis comes to a close.

Congress has to be vigilant in our oversight of how this law is implemented. I fought to ensure that every transaction that takes place regarding this funding will be on the Internet for all Americans to see. In addition, I strongly support the Federal Bureau of Investigation's (FBI) and other state and federal agencies' investigation into the wrongdoing related to the current crisis on Wall Street. If fraud and criminal activity are uncovered, the individuals responsible must be prosecuted to the fullest extent of the law.

Congress must take a hard look at the factors that brought us to this point and seriously address them. Congress will be holding ongoing hearings into the causes of this crisis and the regulation reform that is desperately needed and has been missing throughout the duration of the Bush Administration. The next administration has to work with Congress to pass and implement new regulatory measures so that taxpayers are never put in this position again.

It will take both investment and honesty to get our economy back on track. The next administration will inherit this economic crisis along with many other serious challenges. I hope our new President is honest with the American people about where we stand and what it will take to move America forward.

I believe that to move America forward, we need to invest in the infrastructure and education that create economic growth and jobs. We have to invest in our workforce and find a way to make health care affordable and accessible. We have to increase funding for research and development and reward innovation. We have to implement a smart, forward-looking energy policy that ends our addiction to foreign oil. It is time to put America's families first and restore their faith that government works for, not against them.

I grew up with a country at my back - one that when my own father got sick and could no longer work was there with Pell Grants and student loans and even food stamps when my family needed them. I will always remember that. I supported this legislation because the American dream of owning a home or going to college is simply too important to take a back seat to politics or to be put at risk by the misdeeds of Wall Street.

As Congress continues to work to restore our economy, I will continue to stand up for our state and listen to your concerns. Thank you for contacting me, and please do not hesitate to contact me in the future.

I hope all is well in Seattle.

]]>
In response to: model kung foo (bar) http://nonplatonic.com/ben.php?title=title_218&more=1&c=1&tb=1&pb=1#c1664525 2008-09-17T19:28:42Z ben [Member] ...turns out a lot of that growth is rounding error. Compounding exponents is not good.