>> python singleton (75 views)

A version of python singleton pattern, it is not very pretty and breaks a bunch of pep 20, but in some cases is useful.

Singleton Pattern

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Singleton(object):
    __instance = {}
 
    def __new__(cls, *args, **kwargs):
        if cls.__name__ not in cls.__instance:
            cls.__instance[cls.__name__] = super(cls.__class__, cls).__new__(cls, *args, **kwargs)
            setattr(cls.__instance[cls.__name__], '__init', True)
        else:
            setattr(cls.__instance[cls.__name__], '__init', False)
        return cls.__instance[cls.__name__]
 
    def __init__(self, *args, **kwargs):
        if getattr(self, '__init', False):
            # do initialization here
            pass

Alternatively consider the Borg Pattern below.

Borg Pattern

1
2
3
4
5
6
7
8
class Borg(object):
    __state = {}
 
    def __init__(self):
        self.__dict__ = self.__state
        if 'my_data' not in self.__dict__:
            # do initialization here, i.e.:
            self.my_data = 'initialize your data'

 

Our flat in Tokyo, was built in mid 2009, with the sole purpose of maximising profits for the owner.
The structure is really solid, and of course earthquake proof, clearly the “landlord” does not want to risk having to rebuild and lose money.
The flat is in Musashi Koyama, a convenient location two stops from Meguro.

The walls have no insulation whatsoever, we have to heavily rely on two air conditioners.
During summer and winter is impossible to keep the air conditioners switched off, as without any insulation temperatures drop really fast during winter, and the opposite happens during summer.

The interior of the flat is extremely low quality, the floor is made out of thin sheets of very soft wood, the walls are covered with a plasticky paper, and both the floor and the walls chip and bruise simply by staring at them too hard.
The owner is obviously counting on our deposit money to replace any inevitable damage to the interior, so that it will be able to minimise or even completely remove any necessary expenditure to make the flat ready for the next tenants when we move out.

The bathroom floor is of course glued plastic, very cheap as is the plastic Panasonic sink. The shower however, is great, of course the materials are the cheapest and probably overall below standard, but I can’t complain as I lived fifteen years in England, where the average bathroom sink has two separates taps, one for the very hot water (when you’re lucky) and the other for the very cold water, that’s right, no mixing, you would think that a country arrogant enough to call it self “great” would have some how mastered mix water.
Probably most British “landlords” believe that their tenants don’t appreciate the warmth of mixed water on their face in the morning but rather burn or freeze their face instead.

Going back to the flat in Tokyo, it was built to make money and not to provide the tenants with a nice home to live.
And that is the problem, how different would be our society if somehow we could remove money out of the equation, if our flat was somehow built with passion and with the desire to give a comfortable home to people.

Our flat, like many others, is so inefficient in terms of energy that is an insult to our planet, it should be illegal to build without using the most advanced insulations technologies, each building should strive to be energetically as self sufficient as possible.

Money did play an important part in the evolution of our society, however now money, as well as fossil fuels are dragging us down, and obviously slowing down our evolution, its time to let them go.

The surprising truth about what motivates us

 

>> Letter of Protest (71 views)

 

I visited Hiroshima last 25th of December 2011, and the hypocrisy of U.S. policies on nuclear weapons was obvious.
While they are oppose to any one else developing nuclear weapons, they make sure their own weapons of mass destruction are up to date.
Below is quoted the original letter, and a photo of the plaque from the “Hiroshima Peace Memorial Museum”.
Hiroshima Mayors have written hundreds of such a letters to leaders world wide since the nuclear attack the 6 of August 1945.


May 23, 2011
His Excellency Mr. Barack Obama
President
The United States of America

Letter of Protest

The City of Hiroshima has worked long and hard to help people around the world fully
understand the pain and sorrow of our hibakusha* experience. We believed that this
information would help them develop the strong will required to abolish nuclear weapons.
Despite our efforts, you announced this month that the U.S. conducted a new type of
nuclear test last November and again this past March at Sandia National Laboratories in
New Mexico.

Though these tests did not involve nuclear explosions, they can be understood as evidence
that the U.S. intends to maintain its nuclear stockpile. Coupled with the fact that you
revealed the testing only several months later, these tests have betrayed the hopes of the
hibakusha* and the millions of others who seek a nuclear-weapon-free world, while arousing
suspicion regarding your intentions. Such actions are completely unacceptable, and on
behalf of the A-bombed city of Hiroshima, I vehemently protest.

I urge you to thoroughly comprehend the experience of the survivors who witnessed the
bombing, understand their sincere wish for peace, and strive for the earliest possible
realization of a world free from nuclear weapons.

MATSUI Kazumi
Mayor
The City of Hiroshima

*In Japanese means: the people that were expose to radiations

Click to enlarge.
Hiroshima Letter of Protest

A quick self reminder.

#include <stdio.h>
#include <string.h>
#include <signal.h>
 
void handler(int signal)
{
    printf("Signal: %s\n", strsignal(signal));
    if (signal == SIGABRT)
    {
	raise(SIGKILL); // can't be caught or ignored
    }
}
 
int main(int argc, char *argv[])
{
    signal(SIGABRT, handler); // Abort
    signal(SIGFPE, handler);  // Floating-Point Exception
    signal(SIGILL, handler);  // Illegal Instruction
    signal(SIGINT, handler);  // Interrupt
    signal(SIGSEGV, handler); // Segmentation Violation
    signal(SIGTERM, handler); // Terminate
    signal(SIGQUIT, handler); // Terminal quit
 
    printf("Hello Crazy World!\n");
 
    raise(SIGABRT); // raise Abort
 
    printf("I am never going to be printed...\n");
 
    return 0;
}

 

>> vote Ron Paul (19 views)

Source: http://youtu.be/4fHfdSi-GDo


Speech before the US House of Representatives, 02/12/09

Madame Speaker,

I have a few questions for my colleagues.

What if we wake up one day and realize that the terrorist threat is a predictable consequence of our meddling in the affairs of others?

What if propping up repressive regimes in the Middle East endangers both the United States and Israel?

What if occupying countries like Iraq and Afghanistan – and bombing Pakistan – is directly related to the hatred directed toward us and has nothing to do with being free and prosperous?

What if someday it dawns on us that losing over 5,000 American military personnel in the Middle East since 9/11 is not a fair trade-off for the loss of nearly 3,000 American citizens, no matter how many Iraqi, Pakistani, and Afghan people are killed or displaced?

What if we finally decide that torture, even if called enhanced interrogation techniques, is self-destructive and produces no useful information – and that contracting it out to a third world nation is just as evil?

What if it is finally realized that war and military spending is always destructive to the economy?

What if all wartime spending is paid for through the deceitful and evil process of inflating and borrowing?

What if we finally see that wartime conditions always undermine personal liberty?

What if conservatives, who preach small government, wake up and realize that our interventionist foreign policy provides the greatest incentive to expand the government?

What if conservatives understood once again that their only logical position is to reject military intervention and managing an empire throughout the world?

What if the American people woke up and understood that the official reasons for going to war are almost always based on lies and promoted by war propaganda in order to serve special interests?

What if we as a nation came to realize that the quest for empire eventually destroys all great nations?

What if Obama has no intention of leaving Iraq?

What if a military draft is being planned for the wars that will spread if our foreign policy is not changed?

What if the American people learn the truth: that our foreign policy has nothing to do with national security and that it never changes from one administration to the next?

What if war and preparation for war is a racket serving the special interests?

What if President Obama is completely wrong about Afghanistan and it turns out worse than Iraq and Vietnam put together?

What if Christianity actually teaches peace and not preventive wars of aggression?

What if diplomacy is found to be superior to bombs and bribes in protecting America?

What happens if my concerns are completely unfounded – nothing!

What happens if my concerns are justified and ignored – nothing good!


www.ronpaul.com

 

>> stop the machine (17 views)

Stop The Machine, Create A New World! october2011.org
occupywallst.org
thezeitgeistmovement.com

Join the revolution, save the world

Earth natural resources should be used to meet humanity needs and should not however be exploited for the benefit of few.

 

>> ciambella bertolini (212 views)

Ingredients:

  • 500 grams of flour
  • 300 grams of sugar
  • 175 grams of butter
  • 4 eggs
  • 1 cup of milk
  • a pinch of salt
  • 1 sachet of Bertolini’s yeast

In a bowl, pour the melted but not hot butter and add stirring sugar, eggs, salt, milk and flour.
Work the mixture well and lastly add the Bertolini yeast.
Pour the mixture into a buttered and dusted with flour mold and place it in a hot oven.
Cook for about 50 minutes at a moderate temperature (180°) leave the cake in the switched off oven for extra 5 minutes once cooked.

Bertolini Yeast

Lievito Bertolini

 


 

Full screen version.

 

Few weeks ago I transfered £750 from a bank account in London (England) to a bank account in Italy.
The charge for the transfer was £13.

Unfortunately the Italian bank changed their IBAN number therefore about 10 days later the money came back to the account in England, but only £711.73 came back.

So banks legally stole £750 – £711.73 = £38.27 + the original £13 charge makes it £51.27.
Obviously I still need to send the money to Italy so I will have to pay another £13 making the total taken (so far) £64.27.

We all work very hard to earn our living, why do we have to let banks regularly rip us off, we all know is not “real money” that they are transferring is all virtual and computerized, yet it still takes days to transfer money from one bank to another.

Then to add insult to injury, we have to read the huge bonuses bankers cash in every year, i know is probably not related with the money banks steal us every day, but it is still annoying.

 

The Zeitgeist Movement – New Mission Statement (as of 24th Apr, 2011)

Founded in 2008, The Zeitgeist Movement is a Sustainability Advocacy
Organization which conducts community based activism and awareness actions
through a network of Global/Regional Chapters, Project Teams, Annual
Events, Media and Charity Work.

The Movement’s principle focus includes the recognition that the majority
of the social problems which plague the human species at this time are not
the sole result of some institutional corruption, scarcity, a political
policy, a flaw of “human nature” or other commonly held assumptions of
causality in the activist community. Rather, The Movement recognizes that
issues such as poverty, corruption, collapse, homelessness, war, starvation
and the like appear to be “Symptoms” born out of an outdated social
structure.
While intermediate Reform steps and temporal Community Support are of
interest to The Movement, the defining goal here is the installation of a
new socioeconomic model based upon technically responsible Resource
Management, Allocation and Distribution through what would be considered
The Scientific Method of reasoning problems and finding optimized
solutions.

This “Resource-Based Economic Model” is about taking a direct technical
approach to social management as opposed to a Monetary or even Political
one. It is about updating the workings of society to the most advanced and
proven methods Science has to offer, leaving behind the damaging
consequences and limiting inhibitions which are generated by our current
system of monetary exchange, profits, corporations and other structural and
motivational components.

The Movement is loyal to a train of thought, not figures or institutions.
In other words, the view held is that through the use of socially targeted
research and tested understandings in Science and Technology, we are now
able to logically arrive at societal applications which could be profoundly
more effective in meeting the needs of the human population. In fact, so
much so, that there is little reason to assume war, poverty, 95% of most
crime and many other money-based scarcity effects common in our current
model cannot be resolved over time

The range of The Movement’s Activism & Awareness Campaigns extend from
short to long term. The long term view, which is the transition into a
Resource-Based Economic Model, is a constant pursuit and expression, as
stated before. However, in the path to get there, The Movement also
recognizes the need for transitional Reform techniques, along with direct
Community Support.

For instance, while “Monetary Reform” itself is not an end solution
proposed by The Movement, the merit of such legislative approaches are
still considered valid in the context of transition and temporal integrity.
Likewise, while food and clothes drives and other supportive projects to
help those in need today is also not considered a long term solution, it is
still also considered valid in the context of helping others in a time of
need, while also drawing awareness to the principle goal.

The Zeitgeist Movement also has no allegiance to a country or traditional
political platforms. It views the world as a single system and the human
species as a single family and recognizes that all countries must disarm
and learn to share resources and ideas if we expect to survive in the long
run. Hence, the solutions arrived at and promoted are in the interest to
help everyone on the planet Earth, not a select group.

http://www.thezeitgeistmovement.com/joomla/