Category: technical

Raspberry Pi WiFi via USB

I’ve been playing with my Raspberry Pi again. Actually, I ordered a Pi Zero and a Pi 3 as well.

I really didn’t need the Pi Zero. It was a bit of a Black Friday impulse purchase. Ordered it from Pimoroni in the UK and took just about a month to arrive. On a related note, Amazon Canada had better Pi 3 deals during Black Friday than they did for Boxing Day (I’m looking at you, Canakit).

I’m still waiting on the Zero4U (USB board) I ordered for the Pi Zero and I don’t have any microUSB adapters so the Zero is sitting unused in its antistatic bag. By coincidence, both the Pi Zero I ordered from the UK and the USB WiFi dongles I ordered from China arrived on the same day.

All that aside, both my 1st gen Pi Model B and the Pi Zero need WiFi capabilities. I barely use my Model B because it’s a nuisance to plug it in where my router is.

Here’s how I got wifi working on my Pi. Credit goes to the two articles I found here and here, because the first article mostly worked, and the second article had the command to actually connect to my access point.

From the pi command line:

wpa_cli
add_network

It’ll give you a number. 0 in my case.

scan
scan_results

Locate the access point you want to connect to.

set_network 0 ssid "your-access-point"
set_network 0 psk "the-passphrase-goes-here"

The first article tells me the Pi should connect to the network now. Mine didn’t. So the second article says to

select_network 0

Provided your settings are correct it should connect. Now to figure out how to connect every time the Pi is rebooted.

Getting it to connect on startup

Turns out wpa_cli wasn’t enough. Or if it is sufficient, I’m missing steps to add the required values. According to this other article you need to edit the wpa_supplicant config.

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

I then added the lines that were missing from mine and actually deleted one (disabled=1).

EDIT: In the case of my Pi Zero I actually had to type out the entire block below.

network={
ssid="YOUR_NETWORK_NAME"
psk="YOUR_NETWORK_PASSWORD"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
}

I then added a required line to the network interfaces file.

sudo nano /etc/network/interfaces

Which required the following line added somewhere near the top (I put it just below auto lo).

auto wlan0

The Pi now connects to my network after a reboot.

Startup Weekend Okanagan, Remote Working Panel

On Tuesday I was part of a panel on remote working moderated by Kazia Mullin and sponsored by Sproing Creative. I’m not big on public speaking and wasn’t sure I would have much to contribute to the discussion, especially since for the last month I’ve been a regular old employee who drives into work every day, working with other developers in an office. I was given a list of questions to prepare for but only glanced over them and may not have delivered quality answers during the panel. Having 2 kids and a full time job, and a 45 minute commute to work both ways, I don’t have much free time. The questions were as follows:

  1. Why did you decide to work remotely?
  2. How did you find or create your remote position?
  3. Tell me about the culture of the company you work for? How do they facilitate having remote workers?
  4. What tools do you use to make working remotely possible?
  5. What are your biggest challenges working remotely?
  6. What networks would you like to see in place to better support remote workers?
  7. What advice do you have for someone looking for remote work?

Why did you decide to work remotely? I was previously employed to a local software development studio. A small team with only two developers (myself included) which relied largely on a government contract. That contract dried up and I found myself unemployed. I wasn’t looking for remote work, I was just looking for a job. A friend was looking to subcontract another developer and I fell into the position. Once again working with a small team with only two developers (myself included) but this time I’d get to work from home.

How did you find or create your remote position? As above, I wasn’t looking for remote work. I needed work and a friend offered me a job. But once I worked remotely I told myself I never wanted to work in an office again. Four years later, when that contract dried up, I found myself once again looking for work. Any work. And I’m once again working in an office.

Tell me about the culture of the company you work for? How do they facilitate having remote workers? The company I worked for, in the beginning, was mostly local. Everyone lived within 30-45 minutes of each other, scattered across 4 local cities, with the exception of one support personnel who lived in the Philippines. We were each responsible for our own hardware. Us two developers chose Linux while the owners/marketers, accounting/QA, and support used various versions of Windows. The only commonality was the use of Skype which we’d use for semi-frequent but usually sporadic meetings. Though we all lived relatively in the same location, we’d rarely see each other. Maybe once a month or so, a few of us might meet for wings. Later, when the company sold, a more structured management system was put in place. One with regular weekly meetings, still done over Skype. The main body of the company was shifted to Vancouver where an office was set up and employees were hired to work in the office. The remote workers started dropping, starting with the lead developer and then lead support. Eventually I was let go, due to budgetary issues, and soon after that they gave up the office. Of the people left, they began working from home again.

What tools do you use to make working remotely possible? Skype for instant messaging and one-on-one or group voice chat. Company email addresses. Free and open source software to keep costs low. And since I worked from home, a room in the house dedicated to my work space. A lock on the door is optional, but a spouse who understands that work time is work time was a definite requirement. At least for me.

What are your biggest challenges working remotely? Taxes. I was a contractor so I was responsible for keeping track of business-related taxes and making sure I was paying them on a regular basis. Another challenge was getting paid enough. I don’t think I was very good at negotiating wages on my own. One contract I was getting $50/hour but the main 4-year long contract I was averaging in the mid-$20/hour range. Another contracting-related challenge was finding work. I looked for a remote employed position after the big contract dried up for a full 8 months. Mid-May through to the end of January. When you’re looking for work locally you compete against a local workforce. When you’re looking for work remotely, on sites such as http://weworkremotely.com and http://careers.stackoverflow.com, you’re competing with a global workforce. That’s a lot of competition.

What networks would you like to see in place to better support remote workers? I’d like to see a local co-working space. Working from home has its advantages, but in a house with small children it’s often hard to get the quiet that’s often needed to get “in the zone”.  The job I’m working right now, it’s a 45 minute drive away. I’d happily trade 45 minutes for a 15 minute drive to a local co-working office. As an aside, I found that working from home, by myself, that my skills were stagnating. I find it beneficial to be able to just walk over to someone to ask them a question, or to start a conversation with someone face to face to discuss the latest trends. Especially over lunch, which wouldn’t happen in isolation.

What advice do you have for someone looking for remote work? Know someone. Not everyone has that luxury, but networking has always played an important part in my professional life. Go to http://www.meetup.com and look for a group in your area that suits your interests. You might find a WordPress meetup, or even a Telecommuter group. Where I live, there is http://startupvernon.com which has been a huge boon to my social life. And that’s saying something, since as a geek I typically only left the house once a month to have #GeekBeers with the rest of the Startup Vernon community. And if you can’t find the time to know someone (people really do want to help place you in a job), check the remote-oriented job sites on a daily, or even hourly, basis. They’re linked two paragraphs above. Also, don’t talk yourself out of a position. Let the potential employer decide whether or not you’d make a good fit. Don’t let yourself be the biggest barrier to entry. Apply to everything you think you might be capable of.

Additional thoughts follow.

Someone asked the panel about how an employer with remote employees can help keep the employees motivated. That made me think of a previous remote position I had where, when the company exchanged hands to new owners, they removed everyone’s yearly bonus. Don’t do that. It did the opposite of motivate.

Though he made many good points, Justin Jackson’s “single point of failure” really made me nod my head. When an entire staff works under a single roof, the company is dealing with a single point of failure. The power goes out? A router died or the internet is flaky that day? Everyone stops working. Today at my job, the power went out at 10:10am. We had 8 minutes of battery backup to save our work. We did what little work we could with the outage, and though the power was back on within 30 minutes, that’s 30 minutes across maybe 70 employees. That’s 35 man-hours. Compound that with the fact the network wasn’t back online for another hour and a half after that. Had the team been distributed across the valley, or even the world, the downtime could have been mitigated. Work would have continued as normal.

A big reason to work remotely? Higher rate of pay. You can live in a town with a small tech scene with average wages in the $50k/year range, but find a wealth of employed remote positions online paying big-city competitive wages in the $70k-$90k/year range. Tonight I met a guy who works remotely for a company based out of Australia. Their support positions start at a higher salary than I make as a developer who works locally. Think about that.

Companies that have embraced remote working really have their finger on the pulse. Managers do not have to mistrust remote employees because they know those employees are happier and less likely to leave their jobs, all the while doing quality work. And employees get the benefit of competitive perks. During my remote-job search, I found companies that supplied personal-use cell phones, gym memberships, 401k plans, medical and dental, 5 weeks of vacation (to start), and regular in-person meetups at exotic locations.

Why not work remotely?

Fit Width of Background Image But Keep Aspect Ratio in Android

So you have an image that you want to use as a background on one of your activities.

android_01

 

You probably have something that looks like this.

android_scale_01

But the desired effect is to scale the original image into the blue outline below.

android_02

The actual effect (depending on your current layout)  is the graphic anchored to the top left (android:scaleType=”fitStart”) or center (android:scaleType=”fitCenter”) of the device’s screen with no scaling performed. Through all of your research on Google (directing you mostly to Stack Overflow threads) you’re stuck with a non-scaling graphic that’s positioned incorrectly on the screen. Or maybe you’ve got a distorted graphic that has stretched both in length and width and looks terrible. The short answer?

You can not scale the width of an ImageView to the screen’s resolution while maintaining aspect ratio in an Android layout using only XML.

That’s the information I got from one of the random Stack Overflows I found. And I ignored it for quite a while before giving in and trying to scale the image manually through code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
 
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
 
        <ImageView
            android:id="@+id/iv_background"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scaleType="fitCenter"
            android:src="@drawable/the_background" />
    </LinearLayout>
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
 
        <Button
            android:id="@+id/b_login"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="50dp"
            android:text="@string/login_button" />
    </LinearLayout>
 
</RelativeLayout>

And the necessary code placed at the bottom of the activity’s onCreate method.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int height = metrics.heightPixels;
int width = metrics.widthPixels;
 
BitmapDrawable bmap = (BitmapDrawable) this.getResources().getDrawable(R.drawable.the_background);
float bmapWidth = bmap.getBitmap().getWidth();
float bmapHeight = bmap.getBitmap().getHeight();
 
float wRatio = width / bmapWidth;
float hRatio = height / bmapHeight;
 
float ratioMultiplier = wRatio;
// Untested conditional though I expect this might work for landscape mode
if (hRatio < wRatio) {
	ratioMultiplier = hRatio;
}
 
int newBmapWidth = (int) (bmapWidth*ratioMultiplier);
int newBmapHeight = (int) (bmapHeight*ratioMultiplier);
 
ImageView iView = (ImageView) findViewById(R.id.iv_background);
iView.setLayoutParams(new LinearLayout.LayoutParams(newBmapWidth, newBmapHeight));

android_scale_02

This results in an ImageView that’s stretched to fit the width of the screen while maintaining the aspect ratio of the image.

Startup Weekend Postmortem: A Developers Perspective

A couple weekends ago I took part in Startup Weekend Okanagan at the Kelowna Innovation Center. It’s a full, catered, weekend of building a product from scratch, intending to build a business around that product, and pitching it to a panel of judges. I was lucky enough to be one of 6 attendees from Vernon who were fully sponsored by way of entrance fee (thank you Vernon UPS Store & Bold Media) as well as 2 nights in a hotel (thank you City of Vernon). While it’s all still relatively fresh in my mind, I thought I’d share my thoughts on what went right, what went wrong, and what I’d do differently next time.

What Went Right

Similar but not-so-popular groups merged into one · Initially there were 12 groups who gathered enough votes to move on to the recruitment round (before the planning/development round ~ rest of the weekend). I was one of the 12 (lucky) but only had one person interested in helping me. After joining my team, and wandering the floor, he actually found other groups with little enough individual interest but with similar enough ideas that we all merged into one group. 12 groups boiled down to 7, and our group ended up with 9 members with well rounded skills.

Building an MVP (Minimum Viable Product) · You only have a single weekend to piece together the group’s collective ideas to form an end product. We built our product around WordPress, customizing it with pre-built plugins where necessary. We used WordPress to express how the product would work rather than wasting time building a functional prototype from the ground up. When the weekend is over, and presentations begin, you only have 5 minutes to pitch your business and product. At least half of which is a presentation on the business plan of your product. There’s not much time left to show off the actual product. So we took our customized WordPress site and made it look pretty with a dummy profile page, pre-filled meals and static calendar feature. Enough to be able to quickly click through the main features to help express to the judges how the product would be used.

Picking a product name early · As soon as the name was decided, the rest of the team (marketing/business) could get to work on the social branding pages, including Twitter and Facebook. A logo was born, promotional video was shot. The team really felt like they had something to build around.

Ignoring everyone while they picked a name · From a developer perspective, work had to get done. We already knew we were building around WordPress but had no idea what the url of the site would be. So I set to work configuring my hosts file and apache vhosts with a dummy domain, installing WordPress, and starting on my piece of the project.

Focus on a limited feature set · We were 5 teams that merged together. 3 of our individual team ideas were very similar. We wanted to provide a service around sharing specific items. “Professional skills” was one idea, I wanted to do a co-operative advertisement service. The other idea was to share meals. Obviously cooking is a very specific “professional skill” which we could use to drive focus toward our product. We could have chosen lawn mowing. We could have chosen painting. We could have tried to tackle “all odd jobs” but we focused on this vertical slice, limiting the features and helping us make the most of the limited time we had.

What Went Wrong

I did not prepare my pitch · You get 60 seconds to pitch your idea. They are strict when it comes to those 60 seconds. I was just about to get to the good part when the buzzer rang and I was ushered off the floor. Without maximizing the use of my 60 seconds I failed to gain enough interest from my peers and barely gained enough votes to bring my idea it into the team building round.

Spending time creating features never shown · As previously stated, your time is limited. Part of my responsibilities early in the weekend were to work on the customer-facing interface. This had me researching how to customize the WordPress user profile page and installing and configuring the Adminimize plugin to limit what dashboard features the non-admin users would get to see. This was time wasted since during the final presentation we were never going to walk through the process of 1) signing up, 2) creating meals, and 3) “purchasing” other people’s meals.

Picking a product name early · You’ll notice this is in “what went right” as well. Most of the team was involved in this, while myself and the other programmer tried our best to start building something without first knowing the brand. It seemed like a whole hour (of our precious 50 or so) was dedicated to what we should call ourselves. It’s a necessary activity but most of the team was doing nothing else but this for the hour.

What I’d Do Differently

I’m guilty of this myself in that I did not do this, and had the project I’d pitched had support behind it I’d have wasted time, too: Already have a list of potential product names before the group meets for the first time. Having the brand figured out before-hand will help everyone hit the ground running. The community/social brand manager could then get to work right away creating the social profiles used to generate buzz. The project manager can get started securing a domain which in turn allows the developers to set up the site and their workspaces.

Next time I will not eat so much. There’s more food than anyone can eat in a weekend. Drinks included. I brought my own “snacks” (chocolate covered coffee beans and chocolate covered raisins) and I barely had an opportunity to eat them. I spent the weekend half focused on how uncomfortable I was from all of the food and drink in me. My own fault, a lesson learned.

While I didn’t see it as an issue, the other developer had said he wished everyone communicated a little better. I can see where he’s coming from but I was actually impressed with how well everyone worked together. Given that he thought that was an area for improvement, imagine how much we’d have accomplished if we did all communicate a little more. We didn’t really have an acting “project manager”. Rather, we had “the guy whose idea we were working on” and we all approached him when we had a specific question. If I’m responsible for that role next time, taking this lesson learned, I’ll make an effort to circle the room every so often to ensure 1) no one is working on duplicate tasks unless required and 2) there are no unasked questions from those who may not like to ask questions. All in all, we as a team didn’t suffer from 1) or 2) but a little more communication may have led to a better finished product.

Conclusion

Startup Weekend is a fantastic experience. Not only do you meet many people, making it a great networking event, but you’ll learn a thing or two as well. I know of an applications developer who learned MySQL for the first time. A Joomla developer who’s now eager to try his hand with WordPress. Myself, I was ready to build the MVP from scratch, account management system and all, before someone suggested we use WordPress instead. Brilliant.

Go for the comforts of food and drink and the company of like-minded individuals. Stay for the challenge. Take away a wealth of knowledge and industry contacts. And just maybe you’ll take first place.

*Note: We didn’t take first place. Our project, ChefShuffle.com, took the “biggest social impact” award. Coo Coo, a parking space service, took runner-up. Arkitektor took first place.

Trendnet TEW 423pi wifi and Ubuntu 10.04

I’ve spent parts of the last 24 hours trying to get wifi running on my desktop (I primarily use my work laptop). The desktop uses a cheapo Trendnet TEW 423pi (revision C1.xR).

After bashing my head against my desk following the Ubuntu Community instructions to installing ndiswrapper and Windows wifi drivers, and finding that the wireless networking still doesn’t work, I find a simple solution to my problem. I notice the network-manager, for both the wired and wireless connections, when clicked on displays: wireless networks device not managed.

A quick google search for ubuntu wireless networks device not managed and I find the simple solution. The solution was found at post #8 of this thread.

Changing [ifupdown] managed=false to true in /etc/NetworkManager/nm-system-settings.conf resolved the issue.

Staypressed theme by Themocracy