Saturday, November 19, 2016

Raspberry Pi installation guide (Mac User)

Raspberry Pi installation guide (Mac User)

1, install OS

COMMAND LINE

  • If you are comfortable with the command line, you can write the image to a SD card without any additional software. Open a terminal, then run:
    diskutil list
  • Identify the disk (not partition) of your SD card e.g. disk4, not disk4s1.
  • Unmount your SD card by using the disk identifier, to prepare for copying data to it:
    diskutil unmountDisk /dev/disk
    where disk is your BSD name e.g. diskutil unmountDisk /dev/disk4
  • Copy the data to your SD card:
    sudo dd bs=1m if=image.img of=/dev/rdisk
    where disk is your BSD name e.g. sudo dd bs=1m if=2016-09-23-raspbian-jessie.img of=/dev/rdisk4
    • This may result in a dd: invalid number '1m' error if you have GNU coreutils installed. In that case, you need to use a block size of 1M in the bs= section, as follows:
      sudo dd bs=1M if=image.img of=/dev/rdisk
    This will take a few minutes, depending on the image file size. You can check the progress by sending a SIGINFO signal (press Ctrl+T).
    • If this command still fails, try using disk instead of rdisk, for example:
      sudo dd bs=1m if=2016-09-23-raspbian-jessie.img of=/dev/disk4
      or
      sudo dd bs=1M if=2016-09-23-raspbian-jessie.img of=/dev/disk4

2, to use double quotes, you may need just try type @, you will know what I'm talking about when you do next step


3,

SETTING WIFI UP VIA THE COMMAND LINE

This method is suitable if you don't have access to the graphical user interface normally used to set up WiFi on the Raspberry Pi. It's especially suitable for use with a serial console cable if you don't have access to a screen or wired Ethernet network. Note also that no additional software is required; everything you need is already included on the Raspberry Pi.

GETTING WIFI NETWORK DETAILS

To scan for WiFi networks, use the command sudo iwlist wlan0 scan. This will list all available WiFi networks, along with other useful information. Look out for:
  1. ESSID:"testing". This is the name of the WiFi network.
  2. IE: IEEE 802.11i/WPA2 Version 1. This is the authentication used; in this case it's WPA2, the newer and more secure wireless standard which replaces WPA. This guide should work for WPA or WPA2, but may not work for WPA2 enterprise; for WEP hex keys, see the last example here. You'll also need the password for the WiFi network. For most home routers this is located on a sticker on the back of the router. The ESSID (ssid) for the network in this case is testing and the password (psk) is testingPassword.

ADDING THE NETWORK DETAILS TO THE RASPBERRY PI

Open the wpa-supplicant configuration file in nano:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Go to the bottom of the file and add the following:
network={
    ssid="The_ESSID_from_earlier"
    psk="Your_wifi_password"
}
In the case of the example network, we would enter:
network={
    ssid="testing"
    psk="testingPassword"
}
Now save the file by pressing Ctrl+X then Y, then finally press Enter.
At this point, wpa-supplicant will normally notice a change has occurred within a few seconds, and it will try and connect to the network. If it does not, either manually restart the interface with sudo ifdown wlan0 and sudo ifup wlan0, or reboot your Raspberry Pi with sudo reboot.
You can verify if it has successfully connected using ifconfig wlan0. If the inet addr field has an address beside it, the Pi has connected to the network. If not, check your password and ESSID are correct.

Friday, November 11, 2016

angularjs - ng-repeat execution forces input to lose focus - Stack Overflow

angularjs - ng-repeat execution forces input to lose focus - Stack Overflow


14
down vote
accepted
Yes (looking at the symptoms, you did not show us the data) your issue could be because your model is the text in the array that you (may have), so whenever you update the model, it will trigger digest cycle since ng-repeat is tracked by the text. You can easily fix this by providing. track by $index, so that the ng-repeat is watched over and repeat watch gets updated only when the array changes in its length.




Wednesday, November 09, 2016

javascript - AngularJS ngShow and focus - Stack Overflow

javascript - AngularJS ngShow and focus - Stack Overflow


Use $timeout:

.directive('previewFocus', function($timeout) {
return function(scope, element, attrs) {
scope.$watch('preview',
function (newValue) {
console.log('preview changed!')
$timeout(function() {
newValue && element[0].focus();
}, 0, false);
});
};
});
This works because $timeout defers execution of the code inside $timeout until after the render phase (so after the $watch for ng-show is executed, when the textarea becomes visible)

Side Note: I removed the second argument to your $watch - a deep watch is not necessary for a $watch on a primitive variable.

Demo Fiddle

css - Html input, always in focus - Stack Overflow

css - Html input, always in focus - Stack Overflow


[input autofocus="" onblur="this.focus()" /]
[input value="Can't focus on this" /]

replace [] with <>