How to get the total size of a directory in Linux
du -sh
-h means print it human readable (with MB, kB)
-s mean summarize, i.e. don't print the size of sub directories
du -sh
-h means print it human readable (with MB, kB)
-s mean summarize, i.e. don't print the size of sub directories
Sammanfattning: En mycket viktig film, och tillräckligt bra gjord, men når i form och disposition inte upp till bästa BBC/Channel Four-klass.
En del, däribland jag, tror att en värre ekonomisk kris lurar runt hörnet. Många verkar tro att ett liberalt frihandelssystem med kapital och marknader är ett system bland andra, ett val man fritt kan göra bland andra system. Så är inte riktigt fallet. Istället är systemet en kodifiering av hur saker och till verkligen går till: Marknader finns alltid, och människor kommer att använda sin frihet att inrätta saker på bästa sätt. En liberal ekonomi hjälper bara till att få detta att hända. Om man avviker från systemet, genom att ignorera finansiella risker, lurar fattigdomen om hörnet.
Dokumentärfilmen "Överdos" (på engelska "Overdose") försöker kommunicera denna insikt, och lyckas bra, om den kan hålla kvar tittaren till andra halvan. Materialet i sin helhet är bra: Det består av
I den svenska versionen finns också en svensk textremsa.
Intervjuerna fungerar och varje person presenteras på ett sätt som ger trovärdighet och tyngd. Animationerna fungerar mycket bra och är i världsklass. Tyvärr så är de suggestiva bilderna i början av filmen inte så suggestiva, det är lite svenskt tungfotat över dem. Den svenska textningen är inte heller av så bra kvalitet, jämfört med den uttrycksförmåga intervjusubjekten visar. Jag föredrog att lyssna på engelskan istället.
TV-mediet är subjektivitetens högborg, och det gör att det tyvärr ibland är själva hantverket som avgör om man ska tycka att en film som "Överdos" eller en Marxistisk-Leninistisk film om hur bra det är med revolutioner ska framstå som mest trovärdig.
Det är därför viktigt att kommunicera fakta i dokumentärfilmer. Det som fungerar bäst i TV-mediet är jämförelser. I barnprogrammet Fem Myror så pratar man om att Asta går före Beda, och Cecilia bakom Beda. I filmen överdos görs jämförelser som illustrerar hur mycket pengar som har pumpats in, men detta görs först i andra halva av filmen. Filmen skulle behöva klippas om så att dessa delar kommer först och hookar tittaren. Då har man etablerat en faktabas. Sedan kan man ta in nån dansk (Andreas Mol Daalsgaard?), britt, italienare eller fransos som är proffs på det där med känslor för att få upp suggestiviteten i bilderna för den rent emotionella delen.
Jag hoppas att denna film kommer att få en stor spridning, och om saker blir värre så kommer den att få det. Men det bästa är om den får en spridning snabbt, och då skulle ett varv till i redigeringen behövas tycker jag. Men jag håller inte för osannolikt att den blir en succé även i nuvarande form.
Johan Norberg (Författare, manus), Henrik Devell (producent) och Martin Borgs (Regissör, manus) tog emot på rad och skakade hand med alla som kom på galapremiären på Skandia i Stockholm igår.
Så här ser de ut framifrån, i samma ordning
En kraftig vindby som höll i sig i pass 40 sekunder svepte över Skeppsbron i Gamla Stan i Stockholm idag. Jag hann tyvärr inte få upp kameran, men dammet yrde och en och annan flagga slets loss. Jag uppskattar vindhastigheten till uppemot 40 m/s som mest, men jag är ingen expert på området.
Jag antar att det var någon typ av rotation och att det alltså var en tromb, ett lokalt yrväder.
Det vore trevligt att ha något som håller tekoppen eller tekannan varm. Innan inköp och testning kan det vara bra att sondera och fundera.
Det finns USB-drivna plattor man kopplar in i datorn som ska hålla en kopp te eller kaffe varm. En sådan jag tittade på på webben hade en effekt på 2,5W. Det är inte mycket. Bestämde mig för att gå till Amazon.com för att se recensioner för olika koppvärmare. Nästan alla USB-värmare får bottenbetyg där.
Det visar sig att de koppvärmare som får bra recensioner tycks ligga runt 20W i effekt, och är då inte USB-drivna, utan stoppas direkt i vägguttaget.
Each of the three are rated at 20W, 17W and 24W respectively.
Läs mer: Amazon.com: Customer Reviews: Electric Beverage Warmer
USB har om jag minns rätt 5 volt i sig, och ska man ha 20 Watt ur det så blir det 4 Ampere, vilket skulle ge en rätt tjock sladd, och förutom att bryta USB-specifikationen vad gäller strömmängd så skulle man bara kunna använda USB-uttag som har mycket stor strömleveransförmåga (direkt från nätagget). I andra fall så har man nog bara sönder sin dator.
Nja, det får nog blir en koppvärmare som går på det vanliga elnätet. En komplikation är att ju mindre te man har kvar i koppen, desto varmare blir det, för dessa varmhållare brassar på med samma effekt.
Fast det jag helst skulle vilja ha är en manick som håller min tekopp i en konstant temperatur. Detta skulle kunna göras med en värmesensor inbyggd i koppen, som kommunicerar med värmelementet. Fast det blir komplicerat, då sensorn måste sitta långt ner för att funka även vid halvtom kopp, medan vid hel kopp så kanske den visar en annan temperatur än den vid ytan...
Nä, så här gör man, allt tevärmaren behöver veta är följande:
Sedan så får man helt enkelt kalibrera den för den mugg man använder.
Sätt tekoppen på plattan när teet har den temperatur du vill ha (t ex 55 grader)
Värmeplattan kan nu räkna ut vilket wattantal den kommer att behöva. Om teet efter 20 minuter är 10 grader kallare, så kan plattan räkna ut hur mycket mer watt den kommer att behöva avge för att hålla temperaturen konstant.
Ja, och dessutom måste man ju ha vägt koppen utan te först så taran kan noteras, så att plattan vet hur mycket av vikten senare som är te.
Lyxigare modeller kan ha minne för flera koppar. Om man kopplar ihop värmeplattan med en webbkamera så kan den identifiera koppen ur minnet.
Jo, detta blev väl lite overkill, men mycket av det vi kanske idag tycker är overkill kommer att vara standard i framtidens hem och kontor, trots allt.
En annan variant är att ha en infraröd strålnings-sensor som bevakar temperaturen på ytan på teet i koppen. Det är nog den bästa vägen att gå. Mot Elfakatalogen... Eller vänta lite research:
Single waveband radiation thermometers are usually designed to measure the true temperature when they receive all the radiation from an object that has an emissivity effectively of 1.0, or under blackbody conditions. This occurs most often when the devices are being calibrated, since they are calibrated under simulated blackbody conditions. The accuracy of the simulation bears much on the uncertainty of the calibration of the device. When these devices are used under effectively blackbody conditions, and their emissivity correction is set at 1.0, they can measure very accurately, indeed.
Är ytan på teet en black body? Nära nog kanske. Så nu behövs en arm som går ut upp och över koppen, för att läsa temperaturen på ytan, och så en tyristor i någon krets som kommunicerar med sensorn och reglerar effekten. En termometer som mäter på avstånd kallas pyrometer. Ok, kan nån bygga det här? :-)
I needed to downgrade a couple of repositories from format version 3 to 2 in order to work with RHEL, and it took me a while to realise that svnadmin load loads into an existing repository, it does not create a new one. So first create the repository with svnadmin create, then load into it.
"These parallels suggest that unidentified differences in exposure to microbial communities in the industrialized world may have fundamentally changed human immune responses, thereby enhancing susceptibility to autoimmune and allergic diseases," say the researchers.
Läs mer: Bacteria in household dust may help or hinder childhood asthma
Asymmetrisk översättning - samma deklaration har lite olika innehåll på olika språk, för att passa bättre med respektive lands föväntningar. Låter inte helt legalt.
The Irish and Dutch objected, saying that the term would alarm their voters. So in a typical compromise it was subjected to what the president of the European Council, Herman Van Rompuy, calls “asymmetric translation”. A French-language declaration talks of gouvernement économique. But the English version calls for enhanced “economic governance”.
Läs mer: Bailing out Greece: Smoke and mirrors | The Economist
Here are some thoughts on how a open, distributed social networking system might work:
Each participant in the social network has her own server. This server does not need to be physically where that user is, and it does not even need to be its own server process. However it needs to be a piece of the Internet that he user has sole control over and where:
An example
Alice is friends with Bob. She has signed a relationship declaration, which is just a piece of text containing her OpenID url and Bob's OpenID url and the text "friend with" and stored it on her server. She has also signed it with her cryptographic key.
Now a guy named Charlie comes surfing to Alice's server, and is automatically logged in with his OpenID. Alice has give Charlie the right to see what relationships she has, so Charlie can see Alice is friends with Bob. Charlie thinks he knows Bob. He realises this from the information about Bob (A photo, and a short text describing him). Alice's site has that information on Bob because her server fetched that from Bob's server, or because she had a picture of Bob. If it was taken from Bob's server, Bob had granted Alice's server the right to fetch the information first.
Charlie wants to declare friendship with Bob, and via Bob's OpenID url looks up Bob's server. Charlie cannot view much on Bob's site so he simply posts a request for friendship with Bob, at the same time granting Bob the right so see some basic info on Charlie on Charlie's server. Charlie also signs a friendship declaration with Bob and stores it on his own server, signed with his own key, just as Alice did with Bob on her server.
Bob is notified by his server that a guy named Charlie wants to be friends. Bob views Charlie's personal info, and maybe Charlie also has sent a proof that he already is friends with Alice. Bob now sings his friendship declaration and now Bob and Charlie are registered as friends, since both have signed a friendship declaration (Although each only stores their signed version of it).
Software needed for this to work
Not much, there needs to ne OpenID servers and they already exist. The OpenID url needs to have metadata in the form of a url to the personal server of that user.
There needs to be a way to sign information that can be verified to have been signed by e.g. you, and that also exists.
There needs to be a server that different people can be given different rights on the owner on what to view, based on their Open ID url
As an example, Plone with the plonesocial.auth.rpx plugin could be used to control who gets to see what on a server, GPG to sign stuff and MyOpenID.com to store metadata on where a server is. I am sure there are many other combinations.
Are there any products like this underway?
De har glömt ett "på" nu ser jag. Från förstasidan, själva artikeln här:
Hans roll som trappern Davy Crockett i en Disneyproducerad tv-serie gjorde honom till storstjärna över en natt i mitten av 1950-talet och
ssh-copy-id remote-machine
This one-liner copies your public-key, that you generated with ssh-keygen (either SSHv1 file identity.pub or SSHv2 file id_rsa.pub) to the remote-machine and places it in ~/.ssh/authorized_keys file. This ensures that the next time you try to log into that machine, public-key authentication (commonly referred to as “passwordless authentication.”) will be used instead of the regular password authentication.
Read more: Top Ten One-Liners from CommandLineFu Explained - good coders code, great reuse
Searching for "**" on Google does not give much.
The two stars prefix in python converts between dictionaries and named arguments.
>>> def twoargs(one=None,two=None): ... return (two,one)
The above function takes two named arguments, "one" and "two".
However it can still be called as if the arguments were just positional:
>>> twoargs(32,3) (3, 32)
And it can be called with named arguments:
>>> twoargs(two=32,one=3) (32, 3)
But, what if we call it with a dictionary as a parameter?
>>> adict = {'one':3232,'two':886} >>> twoargs(adict) (None, {'two': 886, 'one': 3232})
The dictionary will be assigned positionally to the first argument ("one"). Since the function happens to return its arguments in reverse order, we first get None for the the last argument in, and then the dictionary.
However if we put two stars in front of the dictionary when calling the function, the dictionary is transformed into named arguments
>>> twoargs(**adict) (886, 3232)
This showed a function with two named arguments, called with the two stars prefix. One can also do it the other way around, that is put the stars in the arguments in the function definition:
>>> >>> def someargs(**args): ... return args
The above function will take any number of named arguments, and put them into a dictionary called "args".
>>> someargs(one=323) {'one': 323}
It doesn't like positional arguments:
>>> someargs(323) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: someargs() takes exactly 0 arguments (1 given)
For positional arguments one can use the single star prefix.
So, when the two stars are used calling a function:
When the two stars are used in the function definition:
So if you want to access a field's value you have to do it through the content item's schema:
obj.Schema()['fieldname'].get(obj)
In templates (or more actually, views), this means doing it from the python file in a Zope view.
Nein, ich habe gesagt, dass man mit der """ "get" Methode des fields """ an die Daten kommt -> obj.Schema()['fieldname'].get(obj)
Läs mer: [dzug-zope] Probleme mit archetypes.schemaextender und ReferenceField
We've been doing Plone Training in London since 2005, but last autumn we were so swamped with consulting work back home that we could not make it. However we now have scheduled a course for May in London. There is going to be more about buildout, subversion and a preview of Plone 4, otherwise steady as she goes.
We've been doing a lot of development and consulting lately, but I want to go back to more teaching, in Plone and in other subjects. We did a Plone course in Stockholm in April this year and now we will be back with Plone Training in the UK with with a course in July in London.
With ESI it is possible to cache the more or less static parts of Plone's pages in Varnish, and "fold in" the dynamic stuff per request. This can in some use cases increase performance massively.
Putting Varnish in front of Plone is a common way to speed up things, and can lead to insane speed increases. However, Plone and Zope are dynamic and tighly coupled frameworks, and it is a bit of a shame to have it serve out essentially static pages. Even if you use something intelligent like CacheSetup (Cache fu), if you make a change that affects a portlet, e.g. "recent comments", you will need to invalidate all pages where that portlet is shown.
Varnish however has support for caching only parts of pages and then fetch the dynamic parts and combine with the static stuff, before serving it out to the visitor. Can Plone be used with it? Yes it can, with some hoop jumping.
The technology of combining pages on the fly is called Edge Side Includes (ESI) and Varnish supports part of the standard. Here is how it works in Varnish:
If you put in a special xml fragment (stanza) like this in your html output:
<esi:include src="/site/@@left_column"/>
...Varnish will fetch the contents of that url (http://yoursite/site/@@left_column), and include it, and replace the stanza with what it finds at that url.
My current hobby project is a salsa dancing web site called 123-567.net. It allows visitors to put together their own salsa dancing routine from short fragments ("Moves"). Moves are connected through positions. It is currently running on our hobby server on the office ADSL connection.
In the right hand column there is a portlet that keeps track of each visitor's routine as it is being built up. No login is required but a captcha tries to keep the salsa dancing away from robots (who suck at dancing anyway, currently, although this may change).
There is one big honking page that lists all moves, and traverses a lot of archetypes references to compute and display all possible moves from each move (and how many moves in its turn can follow each such move). This page basically manages to wake up and excercise every single content object on the site, sometimes multiple times, and the page takes 3-5 seconds to render on a small server. The page cannot be made static, since the contents of the routine portlet will be different for each visitor that uses it.
There are multiple ways of optimizing this page while keeping the portlet dynamic, from RAM-caching with memoize (which brings down the render time of the page to 0.2 s), to using KSS, to using the catalog exclusively for calculating moves.
Memoize seemed like a good solution, but since there are also videos on the site, and I did not want to tie up a Plone process serving each one, I still needed some extra oomph. Varnish should be able to cache the videos and offload Zope's precious processes.
It should be enough to instead of showing the portlet on the page, just show a placeholder for it:
<esi:include src="/site/@@left_column"/>
..and then construct a view by the name "@@left_column" and show the portlet in that view.
Varnish's behavior is controlled by a configuration file, normally called varnish.vcl. The configuration file basically deals with:
The part of the vcl file that deals with responses is a subroutine called vcl_fetch. Here is a simplified part of that code for 123-567.net, with esi enabled:
sub vcl_fetch {
if (req.url == "/site/@@left_column") {
pass;
}
if (obj.http.Content-Type ~ "html") {
esi; /* Do ESI processing */
unset obj.http.set-cookie;
set obj.ttl = 24 h;
}
The esi directive as framed above enables esi parsing and caching of all html pages, but first the preceding if clause sees to that the @@left_column is passed through without caching ("pass").
The @@left_column view needs to be constructed, and since the portlet is a proper portlet, I could register its page template file also as a viewlet, but a quicker and dirtier way (the "customer" of this project, i.e. me, is very tolerant of whims and shortcuts :-) is to just put in a the entire portlet renderer into the view.
<metal:block use-macro="here/global_defines/macros/defines"/>
<tal:block replace="structure provider:plone.leftcolumn" />
Come to think of it, that may not be quicker... Anyway, now the site renders the page statically but puts in the portlet in varnish. We are down to 50 ms rendering time from 5s rendering time, according to Apache's ab tool (with an empty portlet).
The portlet is context free, it renders the same on all pages. It uses the Zope (not Plone) session machinery and is essentialy independent of Plone, and should render very quickly, if put directly in the view instead of with the above provider stanza. For portlets that need context, one could just put in a cgi parameter in the esi stanza, with the path from the calling page, and then use that to recreate the context on the receiving end.
However if we view the site without Varnish the portlet will never materialize on the pages. There will just be stupid esi directive sitting there. I believe it is important that the site can be used without Varnish.
The obvious solution would be this:
<esi:include src="/site/@@left_column">
<--portlet goes here-->
</esi>
One would hope that Varnish would replace the entire esi element. However Varnish is not zpt, and if you put in the above code, Varnish will replace the start tag of the esi element with the portlet, and happily let the rest of the code stay on the page. Viewed through Varnish you would now have two portlets on the page (of which one portlet is stale).
So we need a way for the portlet to "know":
It seems you can find this out from the Plone side! Analyzing the contents of the request variable shows that there is an HTTP_X_VARNISH environment variable which will only be present if varnish is in front. That takes care of displaying the portlet when you are directly accessing Zope. But when behind Varnish, how do we now if we are on the page (ouput ESI tag) or on the specially crafted view (output portlet)? One way is to check for path. The specially crafted view has in its id the string "left_column". Quickly and dirtily we can do it in the page template:
<tal:varnish define= "behind_varnish
python:context.REQUEST.get('HTTP_X_VARNISH',False);
not_cached_in_varnish python: 'left_column' in context.REQUEST['URL0']">
<esi:include src="/site/@@left_column"
tal:condition=
"python:behind_varnish and not not_cached_in_varnish"/>
<tal:portlet condition=
"python: not behind_varnish or not_cached_in_varnish">
[...]
You can do it with a buildout recipe.
You can use varnishtop and varnishhist, which probably comes if you install Varnish centrally on your machine. However for monitoring the buildout based Varnish we need to specify its name. The buildout recipe does not allow this and I do not think it would work even if it were possible. Instead of the name we supply the path to the name parameter ("-n"), giving the path to to where the buildout's Varnish .vsh directory is.
varnishttop -n absolutepath/to/buildout/parts/varnish-build/var/varnish/
..and then tab complete to the lonely dir in there.
The world economy is shifting away a bit from the "first world", towards countries like China and Brazil, but poorer places in Africa south of Sahara are also starting to get more attention and are deemed to have more potential for growth.
At the same time there is a rather painful insight among many idealists in the developed world that development aid hasn't worked and that in may cases foreign aid has possibly destroyed more than it has helped. For liberals (freedom of the individual, free market) the obvious solution is free trade and strong institutions, and a number of liberals have taken it on themselves to pressure EU and other trading blocks to work in that direction. The results of this work proceeds at a glacial pace.
For socialists these trend towards deregulation and free trade smacks of oppression. I have lost count of the number of debates with socialists I have had about this.
However, if you subscribe to the more liberal (and more correct dare I say) world view of freedom to work and freedom to trade, what can you do as an individual?
The blogger behind Hotel Ivory has taken upon himself (according the blog the blogger wishes to remain anonymous) to in a small way reach the goals of:
These goals are hardly unique to the blogger, but it is interesting to follow the analysis and decisions that are taken from a business sense but also liberal perspective. So far the blog has dealt with:
I believe that if thousands (if not millions) of people started doing stuff like this, we should see some pretty strong devlopment all over the world. Problem being of course that these enterprises are fraught with risk. In the nineties, the currency used in the Ivory Coast was devalued by 50%. However as soon as a middle class starts to entrench itself, the virtues of good governance tend to make it into the seats of power. There is just a need to reach that tipping point.
1) Skapa en branch, t ex genom att skapa ett bibliotek någonstans på hårddisken och sedan importera det:
jorgen@computer:~$ mkdir jm20091111
jorgen@computer:~$ svn import jm20091111 https://svn.someserver/some.project/branches/jm20091111
Committed revision 2683.
2) Gå till det bibliotek någonstans din utcheckade trunk, där filen som man vill jobba på i en branch ligger, Och kopiera över filen till branchen:
svn cp trickyModule.py https://svn.someserver/some.project/branches/jm20091111/
3) Filen på disken på din dator är nu fortfarande i trunk, men man kan switcha över till kopian. Normalt jobbar switch på ett helt bibliotek, men man kan lägga på ett optional andra argument om man bara vill switcha en fil:
svn switch https://svn.someserver/some.project/branches/jm20091111/trickyModule.py trickyModule.py
4) Kolla status:
svn st
S trickyModule.py
S betyder väl "switched" får man gissa. Alla ändringar i denna fil blir nu på commit skickade till den nya branchen (har kollat)
Beväpnad endast med ett Spotify-konto och med skraltig kunskap om salsamusikvärldens artister, var det dags att sätta ihop en kollektion med dansant salsamusik. Efter mer eller mindre kreativa sökningar och ett antal genomlyssningar hade dammet lagt sig och av de 40 eller så låtar jag hade valt ut var hälften av Ricardo Lemvo och hans band Makina Loca.
Lemvo gör salsamusik som det är omöjligt att inte bli glad av. Musiken är välproducerad och hela bandet har ett sinne för rytm som gör att en gedigen, närmast muskulös, rytm flödar genom låtarna. Lemvos röst har en tröghet som om hela kroppen måste röra sig i position för att frambringa fraseringen; det är så uppenbart musik att dansa till. När blåssektion kommer in är den snyggt mutad, vilket förutom att det är väldigt vackert gör att man slipper få så hårda ljudstötar från högtalarna på dansgolvet, när blåset kommer in.
Den första låt jag hörde var Africa Havana Paris, som fortfarande efter några dagar är en favorit. Lemvos musik är afrikainfluerad (Lemvo är från DR Kongo med Angolansk bakgrund och bor i Los Angeles i USA), men hans passion är uppenbart kubansk musik.
En ännu mer uptempo-låt är Kasongo Boogaloo, och en lugnare är Serenata Angolano. Lemvo sjunger på en måängd språk. Spanska naturligtvis, men även portugisiska, kikongo och på senaste skivan tydligen även på turkiska.
A long-time fan of Cuban music and traditional salsa as embodied by Johnny Pacheco, Lemvo moved to the USA at age 15 to pursue his studies[1]. His mixture of languages (Spanish, Lingala, Kikongo, French, Portuguese and English) and his keen sense of rhythm made him a favorite of dancers throughout North America, Europe, Latin America, and Africa.
En sida där man kan examinera och slå av och på clave, conga osv, och lyssna på rersultatet
Salsa music has a complex rhythm. Understanding the rhythm can help you to find the 1 beat or find the 2 beat so that you know when to start dancing. On this page I introduce the most important salsa percussion instruments and explain their common rhythms. You can listen to each instrument as you read about it or combine them in the interactive rhythm player at the end. Each rhythm is "counted in" by six beats to give you the speed.
Läs mer: Salsa Rhythm