Henrik Carlsson's Blog

All things me.

Using and AirPort Express as a wired extension to an AirPort Extreme

posted this article on and tagged it with Wireless networking

Part of moving into the new house off course involves setting up the wired and wireless network for the home. Since I have both an Apple AirPort Extreme and an Airport Express, and since the house is too big for the wireless network from one to cover all of it, I wanted to use the latter to extend the formers wifi. I’ve struggled with this previously and failed.

This time I decided not to quit until it worked. There’s just no way this can’t be done, right?

After some googling I found a webpage that helped me on the way, Airport Express as an extender. (Apple.com).

The way to do it is to connect a Cat5e/Cat6 wire between one of the ports of the Extreme and the port1 of the Express. So far, so good.

Then, and here’s the catch, you setup the Extreme as a wifi access point. Once it’s up and running you setup the Express and the important thing is to not set it up as an extension of an existing network. Instead you should set it up as a new network, give it a unique device name and then use the same network name and password as you did on the Extreme. Finally you set the Express to work in bridge mode.2

Is you do these steps it should work. Yay!


  1. I have the older Express that only has one Ethernet port. 
  2. Apple calls this ”roaming” and you can read more about it in the manual

Replies and comments

DC exhausting all possibilities

posted this on

This is an old Los Angeles Times article about Batman Begins and with hindsight, this is an amazing quote from David S. Goyer, who wrote the screenplay:

”Batman Vs. Superman” is where you go when you admit to yourself that you’ve exhausted all possibilities,” says Goyer

Guess who wrote the screenplay for Batman v Superman: Dawn of Justice.

Ett svar till Emils svar till mitt svar

posted this on and tagged it with php Programming

Min ursprungliga post – En kommentar till ”Refactoring Loops and Conditionals”

Emil svarade genom ett par tweets, som jag här satt samman till ett sammanhängande citat för tydlighetens skull.

Jag tycker han gör det rätt fram tills han blandar in collection. Även om collection är helt guld så blir det i det där fallet inte lättare att förstå. Men bort med switchen och in med en array istället. Helt klart.

och tredjepartslibraries är ju väldigt vanligt sedan Composer slog igenom. Om man inte utnyttjar det är man korkad. :)

Jag håller med om att det i det här fallet inte är något fel att byta ut ett Switch-statement mot en Array, så jag tror att vi är mer eller mindre överens.

Sen kan jag absolut se värdet av tredjepartsramverk. Dock medför de en högre tröskel för förståelse för den som läser koden i efterhand eftersom den förutsätter en förtrogenhet med det aktuella ramverket. Och visst, idag använder ”alla” Laravel men om två år är det något annat som ”alla” använder. Huvudproblemet här skulle jag säga är att PHP har så dåliga interna typer att man som utvecklare så lätt frestas att förlita sig på en tredjepart för något så grundläggande som en ”Collection”-klass.

Replies and comments

En kommentar till ”Refactoring Loops and Conditionals”

posted this on and tagged it with php Programming

Min vän Emil twittrade nyss följande:

Dagens lunchfilm för dig som programmerar PHP.
https://vimeo.com/115719437
Diskutera i grupp.

Emil Österlund, 2016-04-27

Jag fick en stor lust att, precis som Emil uppmanar till, diskutera det som visades i videon, och eftersom 140 tecken inte är en särskilt bra grogrund för nyanserad diskussion så tänkte jag blogga om det istället. (Just nu skriver jag på svenska för att i första hand diskutera med Emil. Eventuellt översätter jag det hela till engelska vid ett senare tillfälle om det visar sig vara intressant.)

Låt mig börja med att säga att jag är helt övertygad om att Adam Wathan som har gjort videon är en mycket mera kunnig PHP-utvecklare, och säkert programmerare i största allmänhet, än vad jag är. Jag är bara en glad amatör. Så jag vill inte påstå att han är okunnig, att hans lösning är idiotisk. Det är säkert jag som missförstått nåt men tills jag förstår mer så har jag några invändningar. Dessa kan sammanfattas under rubriken:

Varför?

Varför denna refaktorisering1? Vad vinner vi på den? Blir koden mycket snabbare att exekvera? Blir den lättare att uppdatera?

Jag skulle påstå att den definitivt blir svårare att förstå. Kanske inte för den som redan programmerar på avancerad nivå, och visst ”det är lätt om en kan”, men omstruktureringen fick koden att gå från något som var fullt läsbart för den som är en nybörjare inom programmering till totalt obegripligt för den inte redan invigde.

”Switch”-statements och loopar kanske inte är så snygga att titta på men det är glasklart vad de gör. Jag skulle kunna visa den ursprungliga koden för de 12-åringar som vi (Emil, jag och andra) på fritiden undervisar i grundläggande programmering och annat och barnen skulle ha förstått allt redan under första lektionen. De refaktoriserade resultatet skulle kräva många lektioner för att förstå, inklusive en lektion i ett tredjepartsramverk eftersom den vanliga array-datatypen i PHP inte anses vara bra nog.2

Vi har bytt bort lättförståelig kod, så vad fick vi istället?3 Adam Wathan påstår att han gör koden mera ”simple” och ”clean” men jag förstår inte på vilket sätt det är sant. Det blev mindre kod men är det verkligen samma sak som ”simple” och ”clean”. Det är säkert Objective C-programmeraren i mig som talar men jag är ett fan av kod som är tydlig och lättförståelig, även om det innebär att den är längre och mera mångordig än vad som vore nödvändigt för samma funktion.

(Also linked from Twitter.)


  1. ”Internet” påstår att det här är rätt översättning. 
  2. Jag kan i och för sig hålla med om att ”Array” inom PHP är ett stort jävla mörker, vilket jag insåg när jag började med Objective C och såg hur vackert NSArray och NSDictionary fungerade där. Men PHP-kverulansen sparar jag till en annan dag. 
  3. Det är alltså en ärlig fråga, inte ett sarkastiskt uttalande. Jag vet inte vad vi vinner på den nya koden. 

Replies and comments

Första kvällen i huset

posted this article on and tagged it with Husbygge Huset The House

Nu är vi på plats i huset. ”Vi” är jag, Linn, Iris och min bror som är här och hjälper oss med flytten. Vi har kört ett rejält lass hit till huset idag så vi har allt vi behöver men just nu är det lite svårt att veta var någonting är. Fyrtio kartonger betyder att det finns gott om ställen att leta på. :)

Vi har även byggt ihop ett gäng möbler och har massor kvar och i morgon ska vi hämta ännu mer prylar och förhoppningsvis ska jag även få fart på det trådlösa nätverket i huset.

Det kan även vara så att vi så småningom får roa oss med att klättra på taket och sätta upp en tv-antenn. En av de många tjusningarna med ett helt nytt hus är ju att det inte finns några antenner eller nåt på det. Fiber finns draget in i huset och det är den vägen vi kommer konsumera merparten av den tv vi tittar på. Jag vill inte skaffa någon box och/eller något abonnemang från någon kabeltv-leverantör men jag vill att vi om möjligt ska kunna titta på sändningar från SVT och TV4, även om internetuppkopplingen av någon anledning slutar fungera. Så därav en vanlig tv-antenn för marksänd digital-tv. Stay tuned för mer av det äventyret. (I’ll see myself out.)

Hursomhelst så känns det väldigt, väldigt bra att sitta vid köksbordet, visserligen ett väldigt rörigt köksbord men ändå, i sitt eget hus och njuta av en öl och av tystnaden. Ingen vältrafikerad bilväg som stör, inga grannar som låter genom väggarna som vi delar. Ingen vändplan där raggarbilarna står och brötar ut bas. Bara värmepannan som surrar i bakgrunden. (Det kan vara så att jag behöver köpa en tjockare dörr till tvättstugan där pannan sitter, annars kanske jag så småningom blir sinnessjuk.)

Det är mycket kvar att göra innan allt är klart inne i huset och trädgården är en enda ler- och stenhög just nu men det känns att det kommer bli väldigt bra och jag trivs redan.

Scrolling a UIView to keep the keyboard from obstructing the view of the current UITextField

posted this on and tagged it with iOS Narrating my work Objective-C UIKit

Wow, that’s an unwieldy title!

Anyway, during some spare time today I’ve struggled with something in Objective C and Cocoa Touch that I’ve been struggling with before. When a UITextField in an iOS app becomes ”active”, allowing the user to enter text, almost half of the screen gets covered by the software keyboard. That’s all well and good, but that keyboard is likely to obstruct the view of something, maybe even of the UITextField in question and that’s not good.

To avoid this problem, I the developer am supposed to move or resize (or something) the view. There are multiple questions about this on StackOverflow and multiple answers. After some digging and a lot of trial and error I came up with a solution that differed at least somewhat from all other solutions that I could find. As far as I can tell my solution works and it’s pretty short in terms of code, which I like.

I don’t know, maybe it’s a bad solution. If so, please let me know.

The solution

First, embed all the views that need to move inside a UIScrollView.

In my case I have multiple UITextFields that needs to move so I placed them all inside a UIScrollView. I then added the following property to my ViewController:

This property is updated on textFieldShouldBeginEditing like so:

Then , in my viewDidLoad I added the following two observers:

These will trigger the methods keyboardDidShow and keyboardDidHide when the keyboard appears and disappears respectively. It is in those methods that ”the magic” happens:

Coda

As I said, this works but it’s very possible that it’s a bad solution. If you like the solution, feel free to use it. If you think it’s bad, please tell me so and why so that I can learn and become a better programmer.

Det gör mig så ledsen

posted this on

Jag mår så dåligt varje gång jag ser ett reportage om flyktingarna som förtvivlat försöker ta sig till Europa och jag hatar våra politiker som fokuserar på att göra det svårare för dem, istället för att fokusera på asylrätten och på att rädda liv.
Förhoppningsvis så kommer åtminstone historiens dom över dagens europeiska ledare bli stenhård.

Replies and comments

Apple vs The US Government, or I stand with Tim

posted this on and tagged it with Apple Apple vs FBI Dystopian present Government surveillance Liberty

As most of you probably know by now the FBI has demanded that Apple build a new version of iOS with a backdoor in place. This iOS version is ostensibly only meant to be used on an iPhone 5C owned by one of the San Bernardino terrorists.

Tim Cook, Apples CEO, has publicly refused this.

First off, let me say that I agree with and fully support Cook in this. Good work Tim!

Second, if it wasn’t so serious it would be quite funny that suddenly private corporations go all in on defending civil liberties from the government. Should the government be the ones doing the defending of liberties?

This is a really important line in the sand than Cook is drawing. I’m not sure that Apple can uphold their stance in the long-run, but I hope I’m wrong and that they can.

As other people have said, the FBI has chosen this case wise to get the legal precedent they want. Nobody sympathizes with the San Bernardino terrorists so it’s easy to make a straw man argument about Apple being evil for being more interested in protecting terrorists than ”the American people”. But we need to realize that this is not about the San Bernardino case. This is about US federal agencies wanting the technical help and legal precedent to do whatever they want with the private data of whoever they want.

Where are the other tech giants? Why aren’t Microsoft, Facebook and Google lining up next to Apple? So far the only CEO that I’ve seen taking a firm stance on this is Jan Koum, CEO of WhatsApp

I have always admired Tim Cook for his stance on privacy and Apple’s efforts to protect user data and couldn’t agree more with everything said in their Customer Letter today. We must not allow this dangerous precedent to be set. Today our freedom and our liberty is at stake.

Some links

Here are some good articles on the topic:

Or just look at ”the front page” of Daring Fireball. John has collected a lot of good links and quotes.

Replies and comments

Please Anchor, be a good citizen of the open web

posted this on and tagged it with Anchor Podcasts The open web

I’ve tried Anchor today. It’s a service that let’s its users post short audio posts, like Twitter but for audio. Or put more accurately, it allows its users to make short-form podcasts. I thought it was really fun to use, and discussing a topic on it with a friend seemed much more fruitful that doing the same thing on Twitter.

The setup procedure in the app was simple and as far as I know there are no easier way of recording a piece of audio and broadcasting it ”to the people”. (Note the quotes.)

However, there are quite enough silos around already and I really don’t like to lock myself into yet another one. I want to own the data – or content if you prefer – that I create. Therefore I’d like the following:

I also want to mix and match sources. I want to be able to consume similar content in one app, not having to constantly switch from one app to the other just because people lock their content in various silos.

As I said in the beginning, what Anchor does is provide a way to easily record short-form podcasts and publishing them to the people following you. There is nothing about this that is new from a podcasting perspective. What is new, is how easy they’ve made it. I love that! But since they are podcasts I want to treat them as such. I want people to be able to listen to the things I publish even if they don’t have, never have had, nor ever will get, an account on Anchor.

So I would like Anchor to provide a way for its users to use the content they – the users that is – create outside of the Anchor. The simplest way to do this, that almost certainly would require very little effort on Anchor’s part, is to have some sort of feed for each user of the service. Making those feeds RSS feeds with <enclosure> elements would make them compatible with pretty much all podcatchers that are currently in use.

That would make the service so much less of a silo. It would mean that other people could listen to my stuff outside of Anchor and I could interleave the ”Waves”1 of people on Anchor with other short- or long-form podcasts that I listen to. It would also mean that I could set up automation to cross-post my waves to my own site.

And it wouldn’t even have to be RSS/XML. Any kind of easily parseable feed available without authentication would do for me. Once upon a time even Twitter provided this function for its users tweets and it was great.

Sure, it would be nice to have a posting API for Anchor and it would be equally nice to have a way of using their app to post directly to another service, or to my own blog, but the simple act of adding feeds would take them so far along the way of becoming good citizens of the open web. And I want them to be that since I thought the app and service was great, but I don’t want to lock up my content.

One good thing about it is that there are more or less easily accessible URLs for each Wave. Unfortunately, those URLs are not easily crawlable for the media they are meant to display.

I’ve asked Anchor, both on Anchor and on Twitter, whether they are going to add feeds or not. So far I’ve not gotten a respons. If you who read this also finds this important, please ask them about it you too. (They are @anchor on Twitter.)

So please Anchor, please, be a part of the open web. In your Medium posts you claim to be ”the world’s first true public radio”. Make this real by actually making the content created by your users public. Embrace feeds, embrace the open web.


  1. A post on Anchor is called a wave

Replies and comments

So I have a question for Anchor…

posted this on and tagged it with Anchor Silos The open web

Does the service have an API? Or a way to listen to peoples waves inside a regular pod catcher? Do the people behind Anchor intend to play nice with the open web or is this just another silo that want to usurp the web?

I’ve searched their help and found nothing regarding APIs or XML/RSS.