Archives 2005 - 2019

Get Audacity to work on Ubuntu 14.04

published May 06, 2015 11:12   by admin ( last modified May 06, 2015 11:12 )

Tried and it does work:

 

env PULSE_LATENCY_MSEC=30 audacity


Read more: Link - Linux Issues - Audacity Wiki


Why computer networks have problems staying reliable

published May 06, 2015 02:55   by admin ( last modified May 06, 2015 03:04 )

A good discussion why computer networks have problems staying reliable

The network is reliable

Some choice quotes:

The 90-second network partition caused fileservers using Pacemaker and DRBD for HA failover to declare each other dead, and to issue STONITH (Shoot The Other Node In The Head) messages to one another. The network partition delayed delivery of those messages, causing some fileserver pairs to believe they were both active. When the network recovered, both nodes shot each other at the same time. With both nodes dead, files belonging to the pair were unavailable.

--

From what we can gather informally, all the major managed hosting providers experience regular network failures. One company running 100-200 nodes on a major hosting provider reported that in a 90-day period the provider’s network went through five distinct periods of partitions.

--

Large-scale virtualized environments are notorious for transient latency, dropped packets, and full-blown network partitions, often affecting a particular software version or availability zone. Sometimes the failures occur between specific subsections of the provider’s datacenter, revealing planes of cleavage in the underlying hardware topology

--

Marc Donges and Michael Chan bring us a thrilling report of the popular Broadcom BCM5709 chipset abruptly dropping inbound but not outbound packets to a machine. Because the NIC dropped inbound packets, the node was unable to service requests. However, because it could still send heartbeats to its hot spare via keepalived, the spare considered the primary alive and refused to take over. The service was unavailable for five hours and did not recover without a reboot.


Pystone benchmark comparison, Raspberry pi B+ WD My Cloud & my computers

published Apr 26, 2015 08:25   by admin ( last modified Aug 28, 2015 02:26 )

Old HP server featuring last Dual Pentium (architecture wise actually the first Core 2 duo):

This machine benchmarks at 57471.3 pystones/second

 

Laptop with i5-4200u 1.6GHz with turbo to 2.6GHz (no idea if it it turbo'd):

This machine benchmarks at 185771 pystones/second

WD My Cloud 4GB, running Debian 7:

This machine benchmarks at 10869.6 pystones/second

Raspberry pi B+:

This machine benchmarks at 3831.42 pystones/second

So in this particular benchmark, my laptop is about 3 times as fast as my old server. And the Pi is about 15 times slower than my server and 48 times slower than my laptop.

The WD My Cloud is 2-3 times faster than the Raspberry Pi B+, 6 times slower than the server and 18 times slower than my laptop.

Update: I just upgraded my laptop from Ubuntu 14.04 to 15.05, and now it does around 207'000 pystones/second:

This machine benchmarks at 207550 pystones/second

That is about a 10% improvement.  Either it is turboing, or something is more efficient in Ubuntu 15.04. Oh, I just remembered that it is now switched to 64-bit from 32-bit Ubuntu. Might be that, then.

 

 

 

 


Android app interfaces easily with Arduino, and other Android apps

published Apr 26, 2015 03:04   by admin ( last modified Apr 26, 2015 03:04 )

This is untested by me but it has a number of nice traits:

  • It is open source, so you can tinker with the code
  • It has intents that your own Android app can use, so you do not need to tinker with the source code
  • If I understand correctly it should work with a standard USB cable between the phone and an Arduino Uno R3. I have not checked this.

 

jeppsson/Arduino-Communicator - Let your own Android application receive data from Arduino by listening to the "primavera.arduino.intent.action.DATA_RECEIVED" intent.


Python library that chains functions with dots

published Apr 25, 2015 01:50   by admin ( last modified Apr 25, 2015 01:49 )

A python library that lets you chain together functions with dots into pipelines. Looks like jquery to me, is actually taken from Scala:

from functional import seq

seq([[1, 1], [2, 3], [5, -1]]).flat_map(lambda x: x).sum()

 

To use ScalaFunctional, you need only include: from functional import seq. seq is a function which takes as argument a list and returns a wrapper on that list that provides the extensions for functional programming using Scala style.

 

I wonder how it handles errors in the chain...

 

List of supported functions

 

List to List

  • init: get everything except last element
  • tail: get everything except first element
  • inits: get subsequent inits
  • tails: get subsequent tails
  • drop: drop first n elements
  • drop_while: drop first elements using f
  • take: take first n elements
  • take_while: take first elements using f
  • map: map f onto sequence
  • filter: filter sequence by f
  • filter_not: filter sequence by not f
  • reverse: reverse sequence
  • distinct: return set of unique/distinct elements
  • flatten
  • flat_map
  • group_by
  • enumerate, zip_with_index
  • partition
  • slice
  • zip
  • sorted

List of (Key, Value) to List

  • reduce_by_key
  • group_by_key

List to Value

  • head, first: get first element
  • head_option: get first element or None
  • last: get last element
  • last_option: get last element or None
  • reduce: reduce sequence using f
  • fold_left
  • fold_right
  • count, len, size: get count of sequence
  • any
  • all, for_all
  • max, max_by
  • min, min_by
  • find
  • empty
  • non_empty
  • string: similar to mkString
  • sum

Conversion to other types

  • set
  • list
  • to_dict

When you can't reach your Arduino on Linux, getting Permission Denied

published Apr 17, 2015 08:21   by admin ( last modified Apr 17, 2015 08:21 )

This from the below linked page worked for me. Adjust /dev/ device to where your Arduino is. Mine is a Uno R3 clone.

 

To fix it, enter the command:
$ sudo usermod -a -G dialout
$ sudo chmod a+rw /dev/ttyACM0


Read more: Link - Arduino-er: Arduino IDE error - avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied


No exceptions, classes or frameworks: Creating a web application in python

published Apr 06, 2015 04:05   by admin ( last modified Apr 06, 2015 04:21 )

My current rules for creating a web application in python

Summary: No exceptions, no classes, no frameworks.

No frameworks

Framework fatigue A framework is a mode, a global pragma on how to express the code in your application. In order to be efficient you need to understand how that framework works and it is unlikley that its modus operandi covers all the things that you want to do in a way that is flexible enough to match standard python. Instead use libraries, that gets hooked into your code, and only have a local impact on syntax and configuration.

Coming from the Zope/Plone world, it is very nice to throw all frameworky stuff to the wind and just express things in pure python. Now, frameworks do have their place, when you are solving something that many people have already solved for you, such as a content management system. But the moment your customer starts suggesting/dreaming up unique features you start fighting the framework. I chose to go with the bottle micro framework (which technically is a framework), that mostly stays out of the way and the module in my code that uses bottle is as thin as possible, and isolates the rest of the code from it.

No exceptions

Exceptions break the flow of the code, and it is harder to follow the execution of it. Furthermore in a web application you sometimes want to communicate several errors to the user, and not just the first one. Currently I use an extra return value in the form of an error object, that contains info if there is an error, some text that describes the error in a human readable way, and sometimes a recommendation of what url to redirect to.

class Status:

    def __init__(self):
        self.error = False
        self.redirect_address = None
        self.messages = []

    def add_message(self, message):
        self.messages.append(message)

..and used in a function:

    status = Status()

    user_info = session.get_user_info_from_session(session_id)
    if not user_info:
        status.error = True
        status.add_message("Please log in.")
        status.redirect_address = '/login'
        return (None, status)

In this way I can add error messages, and then return from a function when enough error messages have been added. That is, I can add errors that are not caused by each other, before returning. This works well with server side validation, where you can list all the things that need to be corrected back to the user, and not just the first one you test for (although obviously you do client side validation too, for usability reasons. But you still need to untaint the input).

Using an explicit return value for error or success is used in the Go language instead of exceptions. Idiomatic scala uses the entire result you get back with a return value. The latter would be highly magical in Python, so a separate status value is used.

No classes

Objects are in practice highly unpredictable in when it comes to how you're supposed to interact with them, and get data in and out of them. In practice, objects forces you to learn a mini configuration language for each class, expressed as methods, parameters and whatever state changes happens as a result of those method calls. With pure functions that complexity is confined to the parameters going in and the return values coming out. I have heard from Java programmers that the complexity of how to interact with objects is less of a problem if you have declared interfaces and an IDE that can tell you what's going on with inputs and outputs. However there is still way to much freedom to express yourself as a class author when it comes to how you go about performing a task.

Objects all the way down can make for something akin to a Rube Goldberg machine:

But it is also a question of how to do simple things such as setting a configuration value. Is that done by just setting an attribute, or calling a setter, or using a configuration object that somehow interacts with something?

Objects are often used to store state, which if it is mutable also messes up scaling up the application, and makes testing more difficult. In a web app pure functions also automatically makes your application scalable, since http is sessionless and each request needs to retrieve its state anyway from cookies, urls and server side stored data.

I actually did end up using some objects, as can be seen from the Status object in one of the code listings above.


Tunnelbanetecknet

published Apr 02, 2015 02:35   by admin ( last modified Jun 25, 2015 01:53 )

24C9

 

CIRCLED LATIN CAPITAL LETTER T
# <circle> 0054


Det finns ett tecken för tunnelbanan i Stockholm, som är bra att använda när man ska beskriva i text att man ska åka tunnelbana, som också kallas t-bana, metro, metron eller tricken. Nu ska jag väl kunna hitta den här bloggposten igen när jag behöver teckent. Tecken som är en cirkel med ett inskrivet T. Sådeså.
 

Ⓣ 24C9 CIRCLED LATIN CAPITAL LETTER T # 0054


Read more: Link - UNICODE -- 2460:Enclosed Alphanumerics


SIM cards that give you cheap data roaming across the EU

published Mar 31, 2015 03:35   by admin ( last modified Mar 31, 2015 03:39 )

European Union - Prepaid Data SIM Card Wiki

EU integration means you should be able to move and work anyway you want within the European Union. One obstacle to this is that it can get quite expensive to use your mobile phone once you get out of your own country. EU is trying to change this but there is some resistance.

The site above lists a couple of providers that can get you €10 - €20 per gigabyte EU-wide today. That is a pretty good deal.

Found via the the Europe subreddit at reddit.com: eugay comments on So the EU in the form of its various institutions is dragging its feet with regulation of roaming. But since we live in the single market, which providers offer cheapest roaming in the EU/EEA?


De som vill ha relationer istället för fakta

published Mar 23, 2015 10:45   by admin ( last modified Mar 28, 2015 12:54 )

Sammansvärjningsteoretiker, putinister, kommunister och annat löst folk tror jag har en sak gemensamt: Man anser att världen fungerar, eller borde fungera, med relationer istället för med regler och fakta.

I mindre sociala sammanhang är relationer viktiga: Man litar på att en annan person ser ens problem och rättar till dem, man gör något för någon annan eller behöver uppenbart hjälp och blir sedd och får det man behöver i gengäld.

På större skala fungerar inte relationer så bra. Istället har vi parlament, en kakafoni av yttrandefrihet och marknader. Alla dessa är regelstyrda i sin funktion mer eller mindre och de lämnar inte utrymme för så mycket individuell empati och uppmärksamhet. Man skulle kunna kalla dem pluralistiska system.

En del personer upplever detta som problematiskt och vill att den stora världen ska fungera med relationer istället. Man är obekväm med de  pluralistiska systemen och kanske till och med hatar och föraktar dem. Och det tror jag ligger bakom mycket av vurmandet för kommunism, eller för en stark ledare. Vad gäller konspirationsteoretiker är man dessutom övertygad om att allt redan är relationer på hög nivå över hela världen. Dvs marknader och parlament är bara kulisser för vad de stora grabbarna snackar sig samman om, i sina relationer med varandra.

Jag undrar om detta kan vara en grundläggande sak i människans psyke och om vi i så fall får dras med dessa åsikter och föreställningar, eller om en kulturell innötning av pluralistiska system kommer att balansera bort dem.

Uppdatering 2015-03-28

Insåg just att tätt kopplade globala finansiella system med stor hävstång (high leverage) är ytterligare ett exempel där man använder relationer på alldeles för stor nivå.


Whodunit problems

published Mar 23, 2015 09:35   by admin ( last modified Apr 14, 2015 09:50 )

Sometimes you feel the need to pass judgement on a problem: You look at the facts, and reach a conclusion. But later another piece of fact turns up, or a previously asserted fact turns out to be false and everything gets turned upside down and you realise you were completely wrong. In short you are faced with a problem where what the apparent solution is changes, sometimes several times, as more information is known.

I call such problems whodunit problems, after crime stories where it is not clear until the very last page who actually did the crime.

The reasons why can be varied: It may be a war situation where a lot of disinformation is bandied about or it can be a problem where you need a heck of a lot more information than you previously thought in order to pass a correct judgement, or it might be a problem whose outcome seems pretty much random. It may be as simple as a leading question or a propaganda piece that sets you off in the wrong direction.


Forget intent when analyzing Russia

published Mar 16, 2015 04:55   by admin ( last modified Mar 16, 2015 05:03 )

Ability, opportunity and intent is a triad used for assessing if someone is a threat to you. With Russia, strike out watching for intent.

It is impossible to know the intent due to the Russian regime playing games, but also because the Russian regime is truly unstable. Pretty much any behavior or intent can manifest itself - including cruel or bizarre ones - depending on the outcome of power struggles and of outright mistakes.

Furthermore many of the things Russia says it wants to achieve would be of no material importance to it and would likely not make it happier.

Instead, focus on opportunity. With a firm policy response, consisting both of military, diplomatic and economic means, opportunities for destabilizing Europe or for that matter Russia, will be scarce.


The International Monastery Fund...

published Mar 12, 2015 12:55   by admin ( last modified Mar 12, 2015 12:56 )

Independent.ie has a funny typo in an article about Greece:


I tweeted about the typo to them but it is still there. Maybe there is no International Monestary Fund, in which case one ought to promptly create one, and invite oneself to a bit of hob nobbing with the hoi polloi in the Swiss alps every now and then.

Read more: Link - Greek threat to flood EU with 'migrants, jihadis' - Independent.ie


Flytande kärnkraftverk?

published Mar 01, 2015 06:02   by admin ( last modified Mar 01, 2015 06:02 )

Inte så långt ut till havs, men tillräckligt långt för att inte störa. Jag kom på idén idag och en snabb sökning visade att detta är lite hett just nu. Flytande kärnkraftverk kan byggas på ett ställe och sedan bogseras till där de skall vara, kylning blir automatisk och de är okänsliga för Tsunamis. Skulle något gå fel så kan man bogsera bort dem. Låter faktiskt som en bra idé!

Nuclear power: All at sea | The Economist
 

There is plenty of water to keep them cool and the electricity they produce can easily be carried onshore by undersea cables.


New concept for offshore nuclear plant

A new design concept for offshore nuclear power plants with enhanced safety features


Därför är massmedia (vänster)populistisk

published Feb 20, 2015 02:05   by admin ( last modified Feb 20, 2015 02:05 )

Tidningen Neo har gjort ett reportage om att P3 är vänstervridet. Det är faktiskt inte så konstigt att massmedier som P3 har en populistisk ådra, och det har att göra med hur massmedia fungerar.

Populism är enkla lösningar på svåra problem. Ofta jobbar man med den dåliga idén att hela världen/landet är ens klan (högerpopulism, nationalism) eller ens familj (vänsterpopulism, åt var och en efter behov - från var och en efter förmåga). Sedan blir man förbannad när det inte funkar så bra i verkligheten, i stor skala.

Vad gäller P3 så är det ju radio, och det innebär att en röst magiskt dyker upp i hörlurar och i tjäll och stuga. Man låtsas att man är i samma rum som lyssnaren. Ja, jag vet att detta är självklart, men faktum är att detta får konsekvenser, nämligen den att journalisten talar direkt till individer som om de vore i samma rum.

Man fejkar en närhet och familjäritet. Känns likheten igen från populismen här ovan? Och detta kan lätt få journalisten att tro att hela världen är en radio, om han eller hon tappar kollen på samhället utanför massmedia.

Massmedia har alltså en naturlig dragning till enkla lösningar, därför att masskommunikation som form bygger på en illusion av närhet.


Information wants to be free. What does that make us?

published Feb 17, 2015 11:40   by admin ( last modified Feb 17, 2015 11:41 )

This video by Jack Vale is about what you can find out about random people. A bigger problem is what non-random people can find out about you.

Information wants to be free. What does that make us? A question to ponder.

Stuff you can find out from someone's tweets, instagrams, facebook posts.

 


Let Greece and other countries default

published Feb 13, 2015 06:30   by admin ( last modified Feb 18, 2015 04:20 )

Greece and other countries in dire straits in Euroland are not supposed to default. It is seen as a bad thing. But maybe a default would still be the best solution.

Countries in Euroland could be treated as separate risk areas. One country or the whole zone for that matter should not bail out a country. I'm thinking that it would be better to let the creditor banks take the hit.

The creditors will then know to never lend money to that country again (unless under very favourable terms for the creditors).

In this way the problem should fix itself. If one is worried about "to-big-to-fail" creditor banks not being able to take the hit of a Greek default, then treat the problem at the bank level and leave Greece and other countries out of the picture.

Greece then has no debts, and no credit. Or at least more expensive credit and is able to fix itself, given the new conditions it has to function under. It is not possible to blame any other country, cabal, entity or group and the Euro zone has then settled on a model of handling overborrowing that lets the markets set the terms, and does not require more political scaffolding and supervision.

The alternatives to default, all involve moving money around or diluting the money supply. None of that actually increases the value of products or services. All talk about stimulance, rescue packages and the like is just a game of semantics.

One could argue it is a game of smoke and mirrors deciding who actually loses money in the end, see Greece Vs Germany and the disappearing money A default is clearer.

Also check:



How terrorism works

published Feb 05, 2015 10:30   by admin ( last modified Feb 05, 2015 10:30 )

Insightful article on the rules for it. It is only a threat if you treat it as such. In a way it is similar to how some diseases kill through the reaction of the immune system (e.g. a cytokine storm). However a warning that the rules may change in the future if bigger threats will get into the  terrorists' hands.

 

Following an act of terrorism, the enemy continues to have the same number of soldiers, tanks and ships as before. The enemy’s communication network, roads and railways are largely intact. Its factories, ports and bases are hardly touched. However, the terrorists hope that even though they can barely dent the enemy’s material, power, fear and confusion will cause the enemy to misuse its strength. Terrorists fight like tai-chi masters: they aim to beat the rival with the rival’s own power.


Read more: Link - Yuval Noah Harari: the theatre of terror | Books | The Guardian


Why we shouldn't print money & mess with interest rates

published Feb 02, 2015 12:01   by admin ( last modified Feb 02, 2015 12:01 )

Imagine two hospitals that declare war on fever. After having tried different things, one decides to simply paint all thermometers to indicate 37°C (100°F). The other decides to give all patients massive doses of fever-reducing medication.

Both of these would of course be terrible ideas: Without thermometers it is impossible to know exactly how much fever a patient might be running, and giving fever-reducing medication to everyone would be even worse since that means depressing the immune systems. Instead of treating the root causes of the patients' ailments they are making everything worse by denying or depressing the symptoms.

Still, this is how we are treating the economy: Banks don't want to lend money, so we then give banks an easy supply to newly printed money. That does not solve the problem.

The real problem is that many people are busy doing work they should not do. Their businesses should fail and new businesses should come and take their place and employ the recently jobless.

That is how free economies work, through creative destruction. With the artificial printing of money (fever reducing medication) and centrally set unrealistic interest rates (painted thermometers), we are just leading people further into a dead end. This will make the eventual re-adjustment so much bigger and more painful.