How can you backup your SD cards for your Raspberry Pi?

Given that SD cards have a limited lifetime for writes, using an SD card for a harddrive for Pi may not be the smartest idea in terms of reliability or longevity, so asking how you back up your SD card is a good question. There’s some good answers here.

Specifically on the Mac, find out the disk number of the attached sd card with :

diskutil list

then use the dd command:

dd if=/dev/rdiskx of=/path/to/image bs=1m

where x is the disk number listed from diskutil.

Scala: pass-by-value vs pass-by-name

pass-by-value: expressions as arguments to a function are evaluated once on passing to the function

pass-by-name: expressions are evaluated only when referenced, if they are not referenced they are not evaluated, and the expression is evaluated every time the expression is referenced

System.out.println("Calling squareCallByValue(): ")
squareCallByValue( doSomething() )

System.out.println("nCalling squareCallByName(): ")
squareCallByName( doSomething() )

System.out.println("nCalling callByNameNoReference(): ")
callByNameNoReference( doSomething() )
def doSomething() : Int = {
    System.out.println("doSomething() called")

    2
  }

  def squareCallByName(x: => Int) = {
    var result = x * x
    System.out.println("x in squareCallByName: " + result)
  }

  def callByNameNoReference(x: => Int) = {
  }

  def squareCallByValue(x: Int) = {
    var result = x * x
    System.out.println("x in squareCallByValue: " + result)
  }

JSTL notes

A few notes for a few common JSTL things so I don’t forget:

taglibs:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

Conditionals:

<c:choose>
  <c:when test=””>
  </c:when>
  <!--other when conditions -->
  <c:otherwise>
  </c:otherwise>
</c:choose>

String replace using replace function:

${fn:replace(foo, '"', '\"')}

This next tip for using a loop varStatus to build HTML ids is from: http://stackoverflow.com/questions/6600738/use-jstl-foreach-loops-varstatus-as-an-id

<c:forEach items="${loopableObject}" var="theObject" varStatus="theCount">
  <div id="divIDNo${theCount}">
  </div>
</c:forEach>

This unexpectedly gives:

<div id="divIDNojavax.servlet.jsp.jstl.core.LoopTagSupport$1Status@5570e2">

To get the actual varStatus id you need to use:

${theCount.index} gives value from 0
${theCount.count} gives value from 1

For example:

<div id="divIDNo${theCount.index}">

 

Raspberry Pi Raspbian wifi dongle network config

There’s probably many ways you could configure a similar setup to this, but here’s what worked for me.

This is for static IP on wired, and a different static IP on wireless, where the wireless is using WPA2. I also have two different routers one for wired and for one wireless. Replace static_ip_here with your required ip addresses, and x and y with the IP addresses for your routers.

Edit /etc/network/interfaces:

auto lo
iface lo inet loopback
iface eth0 inet static
address 192.168.1.static_ip_here
netmask 255.255.255.0
gateway 192.168.1.x

allow-hotplug wlan0
iface wlan0 inet static
address 192.168.0.static_ip_here
netmask 255.255.255.0
gateway 192.168.0.y
wpa-ssid "your_ssid"
wpa-psk "your passphrase"
wpa-pairwise CCMP
wpa-group CCMP