Nov 30, 2013

Debian and XFCE: Print Screen Key

Print Screen Key

To enable the print screen key, just head on to Application Menu > Settings > Keyboard and click on the Application Shortcuts tab.

Add a new command and in the text box enter in the following:
xfce4-screenshooter -f
Hit Ok, and the next dialogue will require you to enter in the key (or key combination) that will trigger this command (in this case, we will press the 'Prt Scr' key).


References:

Nov 29, 2013

Notes for Think Again: How to reason and argue (Lectures 3 Validity and Soundness)

These are my course notes for the Coursera course "Think Again" by Walter Sinnott-Armstrong at Duke University and Ram Neta at University of North Carolina.

This follows on from my earlier notes.

VALIDITY

Remember that arguments consist of premises and conclusions, and these are supposed to be related in a good argument. We need some standards for evaluating arguments (so we can deconstruct, reconstruct and create our own). Two standards for evaluating arguments are 'Valid' and 'Sound'.

There are 2 main reasons for arguments to go wrong:
  • One or more premises are wrong or false
  • The premises do not provide a good reason for the conclusion

Remember the relation between premises and conclusions.
  • DEDUCTIVE: Conclusion follows from the premises. Trying to be valid.
  • INDUCTIVE: Argument is not supposed to be valid. Conclusion does not follow from premises.

The rule for validity is:
An argument is valid if and only if it is not possible that both all of its premises are true and its conclusion is false
This means that there can be no way both premises come out true when the conclusion is false. This stands if you assume that the conclusion is false and then test the premises; if they still remain true while the conclusion is asserted false, then it is NOT a valid argument.

This test helps us determine if the premises actually support the conclusion. Another way to look at it is that an argument is valid if and only if whenever its conclusion is false, at least one premise must also be false.

A valid argument is not:
  •  necessarily good. An argument can be valid but be no good at justifying or explaining the conclusion
  • dependent on whether the premises and the conclusion are actually true. It is only dependent on what is possible.
Validity in this context is simply a technical term. Validity should not be confused with other types of validity.

SOUNDNESS

A sound argument is one where the conclusion must be true.


An argument is sound if and only if:
  • all of its premises are true
  • it is valid
If the premises are true and the argument is valid, then the conclusion must be true because if it is false then one or more of the premises must also be false (as per the conditions of validity).

If a deductive argument is not sound, then it is not a good argument (because a deductive argument is trying to be valid, with the conclusion following from it's premises).

BASICS OF RECONSTRUCTION

The goal of reconstruction is to put an argument in a form in which we can easily and accurately assess it in as fair a manner as possible.
  1. Do a close analysis
  2. Remove all excess verbiage
  3. List all explicit premises and conclusion in standard form
  4. Clarify where needed (Sharpen edges)
  5. Break up where possible without distortion
  6. Divide the argument into sub-arguments, and arrange them in order
  7. Assess whether each argument is valid
  8. Add suppressed premises where needed
  9. Check each premise for truth
  10. Qualify premiese to make them true where needed if possible
  11. Assess the argument.
If we manage to reconstruct a sound argument, we know that the conclusion is true. If it is unsound, is it the fault of the argument or ourselves because we didn't understand the argument?

Excess verbiage includes:
  • People repeating themselves for rhetorical effect, stalling for time, or filling in the time
  • Road markers -> help keep track of an argument (what we are talking about, and why). They don't offer anything additional to the argument. Includes changing topics.
  • Tangents -> anecdotes and stories that make the argument interesting or memorable, but offer no reasons for the argument. They can also try to fool or distract you (red herring)
  • Examples -> trying to highlight or bring to home the point of the argument. However, the example may just be an outlier. It can sometimes be used as a premise for the argument.
You need to be careful when removing excess words (including assuring, guarding and other words), because if you remove too much you may make the argument worse and not true to the intentions of the original speaker.

Nov 4, 2013

Debian: Installing gitolite

Tried setting up gitolite in Debian following my earlier guide with CentOS, but it didn't work out as well because there were a few steps missing (Debian doesn't create the gitolite user automatically). These are the modified steps:

  1. Install gitolite:
    sudo apt-get install git git-core python-setuptools gitolite
  2. Add the gitolite user (this is the user that will host the git repositories and control access):
    sudo useradd gitolite
  3. As the user who will be administrating the set-up (i.e. someone OTHER than the gitolite user), create a set of ssh keys and move them to where the gitolite user can access them:
    ssh-keygencp ~/.ssh/id_rsa.pub /tmp/admin.pub
  4. Switch to the gitolite user:
    sudo su - gitolite
  5. Run the set-up command:
    gl-setup /tmp/admin.pub
  6. As the user who will be administrating the set-up, clone the repository
    git clone gitolite@[ip address]:gitolite-admin.git
You can now add in other keys and set up the configuration of gitolite.

References:

Nov 3, 2013

Debian and XFCE Dual Monitors

Open up a terminal and type in xrandr. This will output the configuration of the currently connected monitors. Identify the names of your monitors (such as HDMI2, LCD1, VGA1, CRT2 or whatever). In this example we have two monitors, HDMI1 and HDMI2.

Now type in the desired layout:

xrandr --output HDMI2 --left-of HDMI1
The monitors should now be showing your desired screen laytout. If not, play around until you have it.

To make this layout permanent, click on the Start menu > Settings > Session and Startup and then click on the Application Autostart tab. Add a new autostart item and then insert the xrandr command into the Command text field. Now if you restart your settings will be automatically loaded!

References

Nov 1, 2013

Debian: Sound issue

I had a bit of an issue with ALSA and Debian in regards to my sound device not being detected properly. This meant I had to dig around a bit to get it up and running.

Note that with this method may not work nicely with multiple sound cards. Your mileage may vary....

Problem:

Running the command alsamixer in a terminal returned this error message:
cannot load mixer controls: Invalid argument
Trying to restart the ALSA server got me this:
root@localhost:~# /etc/init.d/alsa-utils stop
[....] Shutting down ALSA...warning: 'alsactl store' failed with error message 'alsactl: get_control:250: Cannot read control info '2,0,0,Front Playback Volume,0': In[FAIL argument'...failed.
So there was something wrong with the system configuration or the control.

For reference, this is what my system has configured:

root@localhost:~# head -n 1 /proc/asound/card0/codec*
==> /proc/asound/card0/codec#2 <==
Codec: Realtek ALC887-VD

==> /proc/asound/card0/codec#3 <==
Codec: Intel PantherPoint HDMI
 root@caesar:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC887-VD Analog [ALC887-VD Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC887-VD Digital [ALC887-VD Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Explanation of these commands (skip if you want to get to the solution)

The first command reads out the first line (head -n1) of each of the files that match the search pattern (/proc/asound/card0/codec*). This matches two files (codec#2 and codec#3). The /proc/ filesystem is where Linux stores all the files necessary for running the operating system, including detected hardware devices. The first file tells us that the system recognizes the motherboard sound card, and the second files recognizes the HDMI output.

The second command confirms our suspicions, and also let's us know that ALSA detects these devices too (the Realtek and the HDMI devices are found and configured).

Now we know that the problem lies in the ALSA configuration, because everything is detected at this stage.

Solution:
  1.  Run the following command and look for your audio device:

    lspci -v
  2. The above step is important because you need to find the line 'Kernel driver in use' associated with your Audio controller (which is outputted by the above line). In my case the kernel was using snd_hda_intel.
  3. Now we need to check to ensure the driver is installed. A simple way is to start off writing (DO NOT PRESS ENTER YET!) modprobe snd and then tab complete it (press the <TAB> key twice). This should bring up a list of sound drivers your system knows about. If your driver is not listed you should try to find and install it.
  4. Edit /etc/modprobe.d/alsa_base.conf and add the following line (you may need to adjust this to suit your system):
    options snd-hda-intel model=generic
  5. Now we need to force ALSA to load the new configuration:
    alsa force-reload
  6. If you can hear sound after running the following command, congratulations!
    aplay /usr/share/sounds/alsa/Front_Center.wav

References: 

Oct 8, 2013

Laravel 4: Setting up and basics

This guide will go through one method of setting up a basic Laravel 4 environment. There are quick-start instructions, however in this guide we are not going to rely on a pre-installed global Composer binary.

These instructions require that you have git installed.

Installation

  1. Clone the laravel framework repository. This contains a basic layout for an application, although composer will be required to install all the dependencies.

    git clone https://github.com/laravel/laravel.git
  2. Rename the directory to one more suited for your project

    mv laravel/ [project]
  3. Change the permissions and owner of your project

    chown -R [user]:[group] [project]
  4. Go into your project directory

    cd [project]
  5. Download a copy of composer for your project

    curl -sS https://getcomposer.org/installer | php
  6. Since composer will now handle all dependancies, we no longer need git to mirror the laravel repository. Remove it:

    git remote -vgit remote rm origin
    If you wish to keep the repository around, you should just rename it:

    git remote rename origin laravel
  7. Edit your composer dependencies, which are stored in composer.json. If nothing else, edit the name, description, keywords, and license fields to suit your project.
  8. Ensure your composer.json is valid by running:

    php composer.phar validate
  9. Install all dependancies via composer

    php composer.phar install
  10. Run the in-built PHP development server to check that everything is working correctly

    php artisan server

    You should now be able to view your new application through http://localhost:8000/. Use the --help flag to see more configuration options.
  11. If you make changes to your composer dependancies, just run:

    php composer.phar update

Netbeans and Laravel set-up

  1. Follow the above instructions to create a new instance of Laravel
  2. Start a new project by clicking on File -> New Project
  3. Select PHP -> PHP Application  with existing sources
  4. Select the sources folder as the project directory you created earlier
  5. Set the 'Run As' configuration as PHP Built-in Web Server with the router script set to public/index.php. Note that other files (such as css and js files) stored in the public directory will not be served.

Eclipse and Laravel set-up

  1. Ensure you have installed the PHP development extensions
  2. Select File -> New Project -> Project
  3. Select PHP -> PHP Project
  4. Enter in a project name and choose the existing source folder. You can finish the settings now, or configure the project further.
  5. I could not get the Eclipse PHP server to work, so you will have to figure that one our for yourself.

Composer overview

  • The command php composer.phar will list all the available commands in composer
  • The composer.json file will list dependencies and configuration defaults for the composer binary.
  • The composer.lock file is generated after you run the install or update composer command. This file will store the exact version downloaded and any local configuration.

Resources

Sep 17, 2013

Notes for Think Again: How to reason and argue (Lectures 1 to 2)

These are my course notes for the Coursera course "Think Again" by Walter Sinnott-Armstrong at Duke University and Ram Neta at University of North Carolina.


  • There are four parts to reasoning and arguing effectively:
    1. Analyzing arguments: Which parts contain arguments? Which parts contain premises and which contain conclusions? We separate and order every part of an argument and supply missing parts or suppressed premises.
    2. Evaluate deductive arguments: Deductive arguments are valid logically, and can can be propositional or conditional. They are usually derived (or established) from a set of known facts or observations.
    3. Evaluate inductive arguments: Inductive arguments do not try to be logically valid, but does not make them less effective arguments. They use generalizations, inferences, analogies and causalities to make their case.
    4. Identify fallacies: Fallacies in arguments include vagueness, ambiguity, begging the question (basing a conclusion on a premise that needs just as much proof as the conclusion itself), irrelevance and ad hominem.
  • Arguments are an intellectual process. It is asserting your views and giving reasons for your views. In other words, and argument is a connected series of statements intended to establish or understand a definite proposition.
  • Arguments are NOT:
    • Fights
    • Abusive
    • Complaints
    • Contradictions or disagreements
  • Arguments ARE:
    1. a series of sentences, statements or propositions
    2. where some are premises
    3. and one is the conclusion
    4. where the premises are intended to give a reason for the conclusion
  • It is important to understand the purpose of an argument, as it will help understand the argument itself. Some reasons for an argument are:
    1. Persuasion: Making people believe or do something you would not ordinarily do (and these can include bad reasons).
    2. Justification: Showing someone a reason to believe a conclusion. They generally try to give good reasons as they are not intending to persuade you to change your belief.
    3. Explanation: Arguments meant to explain a situation or event. The conclusion is already known to be true, so we are trying to find the reasons or premises for the conclusion. Note that explanation does not necessarily lead to prediction, and predictions do not necessarily lead to explanation.

      There are four types of explanations:
      1. Causal: Why did something happen? Find the external causes.
      2. Teleological: For what purpose did something happen? What was the motive behind the act?
      3. Formal: Scientific or logical reason behind the act, usual based on the "design", "form" or "shape" of the object. This is different from Causal because it is an internal cause within the event.
      4. Material: The reason based on the physical composition of the object.
    4. Understanding: A strong argument will not necessarily be a persuasive one. But arguments are meant to clearly communicate what one thinks and why they think it. So a benchmark for arguments is not complete persuasion but how clearly one is understood.
  • In arguments, Language is:
    • Important: it is especially hard to live without.
    • Conventional: General pattern of communication that people use.
    • Representational: It refers to objects and facts.
    • Social: Conventions are shared and understood.
  • Parts of language include:
    • Semantics: meaning of words.
    • Physical production: volume and pronunciation
    • Structural combination: spelling and grammar
    • Etiquette: politeness and manner (not yelling, for example)
  • A word's meaning is mainly determined by how it is used.
  • We can split communication into the following:
    • Linguistic act: meaningful utterances. Only requires meaningful words, grammatical structure and that the relationships between words makes sense.
    • Speech act: A function of language that aim to inspire or convey a desired action in the world, even if that action does not occur. We take words and impose them on the world as long as they occur in the right circumstances (and attitudes help determine the circumstances in which a speech act is performed). Speech acts include promising, apologising, questioning, threatening, inviting etc.

      Note that a speech act is present tense. It denotes something occurring, not already been or could be done without the words being spoken.
    • Conversational act: Intends to bring about a change or intended effect in the world or belief, which is the standard effect for the kind of speech act that the speaker is performing. A conversational act does not occur if the resulting effect does not occur. Answering is a conversational act bought about by the speech act of questioning, and forgiveness is a conversational act bought about by the speech act of apology.
  • Arguing is a speech act.
  • Grice's rules for a co-operative conversation are:
    • Quality: Don't say what you don't believe or have no reason to believe.
    • Quantity: Don't say too much or too little.
    • Relevance: Be relevant.
    • Manner: Be brief, orderly, avoid obscurity and ambiguity. It is all about style.
  • Breaking or violating the rules for co-operative conversation are generally for deceiving people.
  • We can infer, following Grice's rules, the missing pieces of a statement. This process is called Conversational Implication; note that this is not logical implication! For instance, Mary had a baby and got married implies Mary had her baby first and then got married but the reversing the order of statements can strictly be true too. Depending on the intentions of the speaker they may be trying to deceive the listener by violating the Manner rule and confusing the order of events.
Lecture 2
  • Certain words imply certain meanings, and can be used to imply some sentences as reasons or conclusions for another. These words are called Argument Markers.
  • Two types of argument markers:
    • Conclusion markers indicate the sentence after is a conclusion. So, therefore, thus, hence, accordingly.
    • Reason/Premise markers indicate that the sentence after is a reason for the prior sentence. Because, for, as, since.
  • The presence of an argument marker does not always mean an argument is present; it depends on context. For instance, since can also be used in a temporal sense.
  • A good indicator for the presence of an argument is to substitute another suitable argument marker in it's place while still making the sentence comprehensible.
  • If is not an argument marker; it is a conditional statement (only if it asserts, then it can be an argument marker).
  • Standard form of arguments:
    (1) Premise
    (2) Premise
    __________
    ∴ (3) Conclusion (from 1-2)
  • Need to justify the belief in the premise to justify the belief in the conclusion.
  • Skeptical regress raises the question of whether and how any belief can be justified or known. Since no belief can be absolutely justified, this can result in infinite loops or unending arguments.
  • Tricks for dealing with skeptical regress include:
    • Assuring by appealing to an authority or shared assumptions.This is based on trust. The full evidence has not been cited because it is already known or has been verified by an authoritative source. We have limited time, so we cannot prove everything so we utilise a trusted source instead.
    • Discounting objections by citing them and cutting them out quickly. It shows you have already considered the objection, but other qualities or claims are more important. The speaker would use discounting terms such as but, although, even if, whereas and still. You would still use the substitution method to determine if a word is being used as a discounting term.
    • Guarding your claim by making it weaker, not definitive or acknowledging doubt. This makes it harder to object to your claim (and more likely to be true), and move focus to more important claims. 
  • Three types of assurances:
    • Authoritative: Cite but not give the actual evidence.
    • Reflexive: Talking about yourself and your own mental state.
    • Abusive: Abuses you or your argument. Common example is an appeal to common sense.
  • People can use assurances to trick you by citing untrustworthy sources, using it as a distraction, or dropping assurances.
  • The three types of guarding are:
    1. Extent: Size or scale of claim
    2. Probability: Likelihood or certainty of occurrence of claim.
    3. Mental: Your personal mental state, belief or knowledge of claim.
  • Discounting words do three things:
    1. Assert two claims
    2. Contrast claims
    3. Indicate one claim is more important than the other
  • Evaluating terms is used to paint a claim in a positive or negative light. Note that expressing a preference is not making an evaluation.
  • Good => meets the standards
    Bad => violates the standards
  • Ought/Ought Not, Should/Should Not, Right/Wrong are all evaluating terms.
  • Evaluative language is openly and literally evaluative irrespective of context.
  • Slanting is using evaluative language without having a reason for the evaluation.
  • Close analysis is going through an argument and marking it for terms and words that indicate conclusion/premise markers, assurances, discounting terms, guarding and evaluative terms. You can use the following markers to indicate these terms:
    • R/P = reason/premise marker
    • C = conclusion marker
    • A = assuring term
    • G = guarding term
    • D = discounting term
    • E+ = positive evaluation
    • E- = negative evaluation
    • N = nothing/neutral

This is an excerpt from one of my comments in the class Forum regarding the differences between the four types of explanation arguments:
From my understanding....
1) Causal are external events that impact on the one under observation (basing this on the idea of causality)
2) Teleological are the aims or purposes of the actor driving the event (if there is one)
3) Formal are the causes based on the design, positioning, form or shape. This is different from causal as we are looking within the event itself, not external phenomena. This can include scientific laws such as gravity etc.
4) Material are causes based on the physical composition of the object itself.
So for the nuclear explosion in hiroshima:
- Causal is an aeroplane over Hiroshima dropping an atomic bomb wired for explosion upon impact. This is the external event that leads to the explosion at Hiroshima.
- Teleological is the USA using the atomic bomb to devastate Japan and quickly end WW2. This is a simplification of the goals behind the explosion at Hiroshima.
- Formal will be the details explaining how, upon impact, the trigger mechanism sets off the fuel material to create a nuclear explosion. We are looking at the causes within the event itself, which is the bomb going off.
- Material is explaining how the material reacts explosively to certain phenomena due to it's inherent instability at the atomic level. We are looking at the phenomena that at the center of an atomic bomb; if this was a conventional bomb we would be explaining how gunpowder works.

Sep 7, 2013

AJAX with JQuery and Google App Engine: Python

This is an adaption of AJAX with JQuery and PHP. It is a continuation of my Python 2.7 and Google App Engine series, and portions of the code builds upon my earlier work.

A first example...

AJAX stands for Asynchronous JavaScript And XML, and allows us to make our websites seem more dynamic. Let's start with the JavaScript side of things...

Create a file called static.html and add the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
       <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
       <title>Ajax With Jquery</title>

       <!-- Grab the JQuery API from the Google servers -->
       <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript" charset="utf-8"></script>

       <!-- Our own JQuery code to do the AJAX-y stuff -->
       <script type="text/javascript" charset="utf-8">

          $(document).ready(function(){
             $('#txtValue').keyup(function(){
                 $('#display').html($(this).val());
             });
          });

       </script>
    </head>

    <body>
       <label for="txtValue">Enter a value : </label>
       <input type="text" name="txtValue" value="" id="txtValue">

        <div id="display"></div>
    </body>
</html>

Create a file called app.yaml and add the following:
application: almightynassar
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /(.*).html
  static_files: \1.html
  upload: (.*).html

The above will simply serve ALL html page requests directly (which is enough for this example).

Now, if you are using Eclipse just right click on the project, select 'Run As' and choose the 'PyDev: Google App Run' option. Depending on how you configured your Google SDK, it will start up a server on your machine on port 8080. Open up a new tab and navigate to http://localhost:8080/static.html. You should now see a text box; when you type into the box it will automatically display the text in the space below.

Something a little more AJAX - The HTML

So our original example just showed how we could manipulate the DOM (Document Object Model) of the browser during run-time, without a page refresh. How can we use this knowledge utilizing the power of Google App Engine? Well, first let us edit static.html to something we can manipulate:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
       <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
       <title>Ajax With Jquery</title>
     
       <!-- Grab the JQuery API from the Google servers -->
       <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript" charset="utf-8"></script>

       <!-- Our own JQuery code to do the AJAX-y stuff -->
       <script type="text/javascript" charset="utf-8">
       $(document).ready(function(){
            // This will run when the item of class 'button' is clicked
            $(".button").click(function() {
               
                // Grabs the text input
                var name = $("input#txtValue").val();
        
                var dataString = 'txtValue='+ name;  
                // This creates the AJAX connection
                $.ajax({
                    type: "POST",
                    url: "/tutorial",
                    data: dataString,
                    success: function(data) {
                        $('#display').html(data.text);
                    }
                });
            return false;
            });
        });
       </script>
    </head>

    <body>
         <form name="contact" method="post" action="">
            <label for="txtValue">Enter a value : </label>
            <input type="text" name="txtValue" value="" id="txtValue">
            <input type="submit" name="submit" class="button" id="submit_btn" value="Send" />
         </form>
         <div id="display">
         </div>
   </body>
</html> 

Our JavaScript now sends some data to an external URL (in this case /tutorial) and inserts the returned data into the display div. Now all we need to do is code our Python script....

Our Python webapp

Create a file called tutorial.py and add the following code:

# The webapp2 framework
import webapp2

# The JSON library
import json

# Our JSON handler class
class JsonPage(webapp2.RequestHandler):
    # The POST handler
    def post(self):
        # Our POST Input
        txtinput = self.request.get('txtValue')
       
        # Create an array
        array = {'text': txtinput}
       
        # Output the JSON
        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(json.dumps(array))

# URL map the JSON function
app = webapp2.WSGIApplication([('/tutorial', JsonPage)], debug=True)

Now we just need to edit app.yaml so it can serve up our tutorial script:

application: almightynassar
version: 1
runtime: python27
api_version: 1
threadsafe: no

handlers:
- url: /(.*).html
  static_files: \1.html
  upload: (.*).html

- url: /(.*)
  script: tutorial.app

Open up a new tab and navigate to http://localhost:8080/static.html. You should now see a text box with a button called 'Send'. Typing into this box and then clicking 'Send' will transmit the text to our tutorial script and then display the text in the space below.

References:

Aug 25, 2013

Linux Mint Multiseat with keyboards & mice(Xephyr)

I must state this important fact first:

Xephyr on Ubuntu/Linux Mint does not come compiled with evdev support.

This is important because Linux uses evdev to configure most input devices like keyboards and mice. You will see lots of documentation on configuring inputs with evdev, but none of those methods will work unless you compile Xephyr from scratch and enable evdev yourself.

I downloaded and installed the following executable to make my life easier. I repeat, this method will not work unless you have a modified version of Xephyr with evdev support!

Correct drivers - make sure they are installed!

I used an older Nvidia card so the following commands got me up and running:
sudo apt-get -y xserver-xorg-video-nouveau
#
# Upgrade our system
sudo apt-get -y install ubuntu-drivers-common
sudo apt-get -y install nvidia-current nvidia-settings

If you are unsure what graphics card you have then run the following (the second line is my output; yours will probably be different):
$ lspci | grep VGA
01:00.0 VGA compatible controller: NVIDIA Corporation GT218 [GeForce 210] (rev a2)

Input devices

Determine which devices are which by running the following command (unplug devices to help to narrow down your options). The paths you see are going to help in writing up our configuration file.

$ ls -l /dev/input/by-path/
total 0
lrwxrwxrwx 1 root root 9 May 27 18:39 pci-0000:00:1d.0-usb-0:1:1.0-event-kbd -> ../event3
lrwxrwxrwx 1 root root 9 May 27 18:39 pci-0000:00:1d.0-usb-0:2:1.0-event-mouse -> ../event4
lrwxrwxrwx 1 root root 9 May 27 18:39 pci-0000:00:1d.0-usb-0:2:1.0-mouse -> ../mouse0
lrwxrwxrwx 1 root root 9 May 27 18:39 platform-i8042-serio-0-event-kbd -> ../event2
lrwxrwxrwx 1 root root 9 May 27 18:39 platform-i8042-serio-1-event-mouse -> ../event5
lrwxrwxrwx 1 root root 9 May 27 18:39 platform-i8042-serio-1-mouse -> ../mouse1

Custom Xephyr script

The custom script (save it to /usr/sbin/Xephyr.sh) will act like the glue in our multi-seat environment. It will attach input devices to our monitors and some other stuff.

#!/bin/bash
# 20060905 - josean - added get_event() function to obtain eventNN from a physical address
# Original version:
# http://en.wikibooks.org/wiki/Multiterminal_with_Xephyr
# http://www.c3sl.ufpr.br/multiterminal/howtos/Xephyr.sh
trap "" usr1
XEPHYR=/usr/local/sbin/Xephyr
get_event()
{
    evento=`grep -A5 $1 /proc/bus/input/devices | grep 'H: Handlers=' | grep --only-matching -e 'event[0-9]*'`
}
args=()
while [ ! -z "$1" ]; do
    if [[ "$1" == "-xauthority" ]]; then
        shift
        if [ ! -z "$1" ]; then
            export XAUTHORITY="$1"
        fi
    elif [[ "$1" == "-display" ]]; then
        shift
        if [ ! -z "$1" ]; then
            export DISPLAY="$1"
        fi
    elif [[ "$1" == "-kbdphys" ]]; then
        shift
        if [ ! -z "$1" ]; then
            get_event $1
            args=("${args[@]}" "-keybd")
            args=("${args[@]}" "evdev,,device=/dev/input/$evento,xkbrules=evdev,xkbmodel=evdev,xkblayout=us")
        fi
    elif [[ "$1" == "-mousephys" ]]; then
        shift
        if [ ! -z "$1" ]; then
            get_event $1
            args=("${args[@]}" "-mouse")
            args=("${args[@]}" "evdev,5,device=/dev/input/$evento")
        fi
    else
        if ! expr match $1 'vt[0-9][0-9]*' >/dev/null; then
            args=("${args[@]}" "$1")
        fi
    fi
    shift
done
echo $XEPHYR "${args[@]}"
exec $XEPHYR "${args[@]}"

Xorg.conf settings

Edit /etc/X11/xorg.conf with something similar to the following. Please change the values to your whatever matches your system!!

############## SETTINGS#############
Section "ServerFlags"   Option  "DontZap"  "true"   Option  "DontVTSwitch" "true"   Option   "DontZoom" "true"   Option   "AllowMouseOpenFail"   "true"   Option   "AllowEmptyInput"   "true"   Option   "AutoAddDevices"   "false"   Option   "AutoEnableDevices"   "false"   Option  "Xinerama" "false"   Option   "NoPM" "true"   Option   "DPM" "false"   Option   "BlankTime" "0"   Option   "StandbyTime" "0"   Option   "SuspendTime" "0"   Option   "OffTime" "0"EndSection
############## INPUTS#############
Section "InputDevice"   Identifier   "Keyboard1"   Driver      "evdev"   Option      "Device" "/dev/input/event2"   Option      "Floating" "true"   Option      "XkbRules" "evdev"   Option       "XkbModel" "evdev"   Option      "XkbLayout" "us"EndSection
Section "InputDevice"   Identifier   "Mouse1"   Driver      "evdev"   Option      "Device" "/dev/input/event5"   Option      "Floating" "true"   Option      "GrabDevice" "on"   Option      "Protocol" "auto"   Option      "Emulate3Buttons" "no"   Option      "ZAxisMapping" "4 5"EndSection
Section "InputDevice"   Identifier   "Keyboard0"   Driver      "evdev"   Option      "Device" "/dev/input/event3"   Option      "Floating" "true"   Option      "XkbRules" "evdev"   Option      "XkbModel" "evdev"   Option      "XkbLayout" "us"EndSection
Section "InputDevice"   Identifier   "Mouse0"   Driver      "evdev"   Option      "Device" "/dev/input/event4"   Option      "Floating" "true"   Option      "GrabDevice" "on"   Option      "Protocol" "auto"   Option      "Emulate3Buttons" "no"   Option      "ZAxisMapping" "4 5"EndSection
########### SEAT 1##########
Section "Device"   Identifier   "Device1"   Driver      "nvidia"   Vendorname   "NVIDIA Corporation"   BoardName   "GeForce 210"   Option      "DPMS" "false"   Option      "UseDisplayDevice" "CRT"   Option      "ProbeAllGpus" "false"   Option      "NoLogo" "true"   Option      "RenderAccel" "true"   Screen      1EndSection
Section "Monitor"   Identifier   "Monitor1"   VendorName   "Toshiba"   ModelName   "Toshiba Matsushita Display Technology Co., Ltd LCD-MONITOR"   Option      "DPMS" "false"EndSection
Section "Screen"   Identifier   "Screen1"   Device      "Device1"   Monitor      "Monitor1"   DefaultDepth   24   Subsection "Display"      Depth   24      Modes   "nvidia-auto-select"   EndSubsection   Option      "DPMS" "false"   Option      "UseDisplayDevice" "CRT"   Option      "ProbeAllGpus" "false"EndSection
############# SEAT 0############
Section "Device"   Identifier   "Device0"   Driver      "nvidia"   VendorName   "NVIDIA Corporation"   BoardName   "GeForce 210"   Option      "DPMS" "false"   Option      "UseDisplayDevice" "DFP"   Option      "ProbeAllGpus" "false"   Option      "NoLogo" "true"   Option      "RenderAccel" "true"   Screen      0EndSection
Section "Monitor"   Identifier   "Monitor0"   VendorName   "Toshiba"   ModelName   "Toshiba Matsushita Display Technology Co., Ltd LCD-MONITOR"   Option      "DPMS" "false"EndSection
Section "Screen"   Identifier   "Screen0"   Device      "Device0"   Monitor      "Monitor0"   DefaultDepth   24   SubSection "Display"      Depth 24      Modes "nvidia-auto-select"   EndSubsection   Option      "DPMS" "false"   Option      "UseDisplayDevice" "DFP"   Option      "ProbeAllGpus" "false"EndSection
############## SERVERS#############
Section "ServerLayout"   Identifier   "multix"   Screen   0 "Screen0" 0 0   Screen   1 "Screen1" 0 0EndSection


MDM configuration

The MDM is what executes everything (if it has been configured properly). Edit /etc/mdm/mdm.conf and change the Server Section to the following:

## Also note, that if you redefine a [server-foo] section, then MDM will# use the definition in this file, not the MDM System Defaults configuration# file.  It is currently not possible to disable a [server-foo] section# defined in the MDM System Defaults configuration file.#
[server-Xephyr0]name=Xephyr0command=/usr/bin/X -ac -br -layout multix -audit 4 -dpmshandled=falseflexible=false
[server-Xephyr1]name=Xephyr1command=/usr/sbin/Xephyr.sh -display :0.0 -xauthority /var/lib/mdm/:0.Xauth -fullscreen -kbdphys usb-0000:00:1d.0-1/input0 -mousephys usb-0000:00:1d.0-2/input0 -verbosity 100 -audit 4 -screen 0 -dpms -retrohandled=trueflexible=false
[server-Xephyr2]name=Xephyr2command=/usr/sbin/Xephyr.sh -display :0.1 -xauthority /var/lib/mdm/:0.Xauth -fullscreen -kbdphys isa0060/serio0/input0 -mousephys isa0060/serio1/input0 -verbosity 100 -audit 4 -screen 1 -dpms -retrohandled=trueflexible=false

Resources

Aug 23, 2013

Coursera Notes: Stanford 'Start-up Engineering' (Lectures 5-8)

These are just some of my notes from Coursera's 'Start-up Engineering' course, taught by Balaji Srinivasan from Stanford.

This is a continuation of my existing series of notes.

Market Research, Wire-framing and Design

  • Idea \ne Mock-up
    Mock-up \ne Prototype
    Prototype \ne Program
    Program \ne Product
    Product \ne Business
    Business \ne Profit
  • Execution! It is not the idea, but the execution that matters. Sales rather than technology is what builds a business.
  • Market! Market will draw a product from a team, whether or not it is quality or the team is good.
  • An idea exists within a maze. A simple sentence is not enough to describe an idea; an idea is defined by the regulations, markets, and competition.
  • Execution mindset. This is essentially writing a to-do list and regularly checking off items. Rinse and repeat.
  • Market Research:
    1. News coverage and research papers. Google Books, SEC filings and Wikipedia.
    2. Back-of-envelope estimate of market size. Look for relevant statistics.
    3. Validate. Google keyword planner and Facebook advertiser tools help determine if there is actually a market need.
    4. Do a basic launch page with basic SEO. Use wireframes.
    5. Ad-word to discover the market. The launch page will then gauge market interest.
  • MVP or Minimum Viable Product.
  • Remember, a start-up aims to be very ambitious and scale rapidly.
  • Two features of successful start-ups:
    1. Exhibit economies of scale. Cost of production per unit decreases as more units are built (but revenue stays the same). We can then determine a break-even point and therefore the minimal capital required.
    2. Attack/Pursue large markets. Different pricing will attract different markets, but low price points require automation and industrial efficiency to make profits (because customer service is expensive). It may be better to charge higher initially to counter risks. Market sizing calculations should be done early and often.
  • Once a market and broad perspective has been set, versions and features need to be prioritized. Remember, it is execution and sales that matter!
  • Rough guide to prioritizing versions and features:
    • How much are they willing to pay for certain features or versions?
    • Which features are required in each version? What features make sense to bundle together?
    • Estimate the time and cost to build each feature. Is it feasible to implement the feature now, or wait for more funding?
    • Find the most popular features.
    • Calculate the market size for each feature.
  • Wireframing tools: omnigraffle, lucid chart, jet strap and popapp.
  • Copy-writing:
    • Home-page message must allow a customer to immediately figure out what the product is. This is a priority if this is going to be a major source of potential customers.
    • Work backwards from the press release (write the release then build the product). This allows you to figure out which features are making the news and which are not.
    • Find your competitors and explain why they are terrible options. Use this insight when explaining the benefits of your product.
    • Simple, factual and concise statements.
    • Call to action. Allow the customer to do something once they visit your website.
  • Vector graphics are better to work with.
  • In design remember Alignment, Repetition, Contrast and Proximity.
  • Start with a font heavy design (it is easier to do and images can always come later)

Mobile

  • Assumption behind the mobile phenomenon is that everything is going to be on the internet. The internet is going from a novelty to a utility.
  • Build for HTML5 and then move to native apps. HTML5 ensure your application works on all devices (and Android will soon utilise HTML5 and Javascript instead of native applications).
  • Internet of Things is the idea that every device will have it's own IP address. This offers a huge potential market.
  • Quantified self is the measuring of human beings and our actions. This is the collection of metrics that may revolutionize diagnosis and medicine.
  • One way to build mobile-aware applications is user-agent sniffing. This approach has the problems that a client can fake their own user-agent, and that the user-agent is inherently unreliable.
  • CSS media queries and Responsive web design allows the application of conditional styles depending on screen size. This is much more reliable, but does not have ubiquitous support (yet).
  • Some constraints with mobile include:
    • Unreliable networks (the fallacies of distributed computing)
    • Debugging requires logging (and bug reporting)
    • Minimization of user input (difficult problem to solve; how to collect everything you need without overwhelming the user)
    • Minimize the time to result (if you take too long the user will go elsewhere)

HTML / CSS / Javascript

  • HTML is the skeleton of a web application. It provides the structure of a page and the semantics. It is a set of finite elements with attributes.
  • CSS is the look and layout of a web application. It edits the element and attributes for styling and formatting.
  • Javascript is the dynamics and behavior of a web application. It allows you to provide client-side validation, pulling in content, playing games and much more.
  • Some useful tools include jsfiddle.net and Chrome Developer Tools.

Deployment, DNS and Custom Domains

  • Your code production environments should be along the lines of Development -> Staging -> Production
  • Separating environments bring the following benefits:
    • Testing of features before they reach the customer
    • Roll back of code in case of major bugs
    • Restore code or data in case of catastrophic crashes of the server
    • Incorporate contributions from multiple engineers
    • Perform AB testing of features
  • DNS (Domain Name System) converts IP address into human readable hostnames. The system first looks locally in a program, then the OS, then the ISP and then finally a trusted internet DNS server.

Inkscape and glue: Creating CSS sprites

I use a combination of Inkscape (to create raw SVG files and then export them to PNG images) and glue (to stich them all up and create the CSS file) to help me create CSS sprite icons for various websites. I also used iconmonstr as a starting point for some icons.

This is the BASH script I use to convert raw SVG files into PNG files and then into the sprite and CSS combination:
#!/bin/bash
mkdir -p ./img/48x48/ ./img/32x32/ ./img/16x16/
for i in ./svg/*.svg; do
    inkscape -z -w 48 -h 48 -e ./img/48x48/`basename $i .svg`.png $i
    inkscape -z -w 32 -h 32 -e ./img/32x32/`basename $i .svg`.png $i
    inkscape -z -w 16 -h 16 -e ./img/16x16/`basename $i .svg`.png $i
done
glue ./img/ --img=./img/ --css=./css/ --html --project

Aug 16, 2013

Coursera Notes: Stanford 'Start-up Engineering' (Lectures 1-4)

These are just some of my notes from Coursera's 'Start-up Engineering' course, taught by Balaji Srinivasan from Stanford.

Lecture 1:


  • A start-up is typically a company designed to grow rapidly and scale to global markets. The idea is to take ownership of the market before competitors move in.
  • The modern Start-up company is generally focused around the internet and other emerging technologies, but history is filled with start-up stories. The automobile, aviation, oil, and pharmaceutical industries all began with similar start-up journeys. Some of the biggest businesses we know had very humble beginnings.
  • The modern start-up industry began in 1989-1992. This was due to a combination of factors such as the widespread adoption of the internet, the fall of the USSR and the repeal of the NSF AUP in the USA.
  • The USSR (and other communist regimes) heavily regulated the use of technology, and you could be jailed for any unauthorized use. The fall of the USSR allowed the adoption of technology by the mainstream population, vastly increasing the amount of people interacting on-line. It also forced India to introduce policies that deregulated technology use and made China focus on market reforms. These factors helped to create the global free market.
  • The National Science Federation (NSF) in the USA had banned e-commerce because of fears of malware, spam and pornography. Eventually the US congress repealed the Accepted Use Policy (AUP), and this allowed people to start trading goods and services on-line.
  • The features of a modern start-up company include:
    1. Operational Scalability: This refers to the ability to conduct transactions from anywhere in the world without requiring a physical presence. This means you can rapidly expand into global markets without increasing operational overhead.
    2. Market size: The internet means a company now has access to a customer from anywhere in the world. This exponentially increases your market size (as long as border and geographical restrictions are solved).
    3. Generality: Software is a flexible and malleable tool with almost limitless potential. Software skills are also portable.
    4. Low capital barriers: Hardware costs are relative cheap, so sophisticated equipment can be bought with little capital overhead. Developers can also create their own software tools to suit the job at hand.
    5. Low regulation barriers: It is currently very hard to regulate the internet, but this should not be taken for granted. The firewall in China and the USA's NSA spying program are examples of attempts by governments to control, regulate and restrict the internet.
    6. Open source: The internet is built on open source technologies such as DNS, HTTP, HTML, IP, DHCP and other protocols and specifications. The free exchange of ideas and common technologies means the rapid emergence of new and useful tools for the entrepreneur.
    7. The long trail: The global scale of the potential market means that a start-up can target extremely specific customers and market niches like never before.
    8. Failure tolerance: Penalty for failure is lower than other industries (such as automobiles and aviation).
    9. Able to build a hybrid business: Can supply an API to interact with third-parties or the physical world. Automation through device drivers and actuators.
  • The current trend for start-ups is towards mobility and decentralization (or at least reducing the penalty for location and nationality).
  • Start-up engineering is focused on shipping a workable product. Iterative development is key; ship an initial product with reduced functionality to bring in some early funding to fuel further improvements in the next version.
  • Primary task of a start-up engineer is the integration of diverse technologies. They need to keep up with the latest developments, evaluate the usefulness of technology and quickly snap together the pieces.
  • Engineers need versatility, especially with Design, Marketing and Sales.
  • Mobile HTML5 and JS/JSON is the future of web applications. They allow for responsive mobile design (with a desktop UI as an aftereffect), which allows the use of the application on as many devices as possible.

Lecture 3 & 4:


  • Virtual Machines allows us to take a single physical computer and make it seem like multiple independent computers. Virtualisation significantly reduces the infrastructure overhead.
  • Linux has server-side license loophole. This allows a developer to modify open source code without distributing those changes to the public. This means you can modify code to create a service without releasing those code changes, as long as you are not distributing the changes for profit.
  • The Cloud Computer is a computer whose precise physical location is immaterial to the application. There are three approaches:
    1. IAAS: (Infrastructure As A Service) Direct access to hardware
    2. PAAS: (Platform As A Service) API access to the hardware.
    3. SAAS: (Software As A Service) API and GUI to the application, but no control over the hardware.
  • $PATH is the order of directories that Linux will use to search for a command. The first matching command found is assumed to be the desired command.
  • 'which' is a useful command to determine which command Linux will find first. This can help when you have multiple versions of a command installed
  • bash is a command-line shell implementation
  • A shell script begins with a sha-bang (#!) followed by the path to the command that the shell will use to interpret/execute the script.
  • ssh allows you to securely connect to a remote machine and run commands
  • scp allows you to connect and copy files to a remote machine
  • You can configure SSH so that you don't have to write out the connection details every time. Add the following to the file ~/.ssh/config and invoke with ssh <name>
    • Host <name>
    • HostName <hostname>
    • User <username>
    • Identityfile <the path to the file>
  • STDIN is the input stream, STDOUT is the output stream, and STDERROR is the error stream
  • Some useful linux commands:
    • cd - change directory
    • alias - set a command alias to save typing
    • rm - remove a file
    • mv - move a file
    • mkdir - create a directory
    • pwd - print the current working directory
    • env - list all environment variables
    • ls - list files in current directory
    • ln - create symbolic links
    • rsync - synchronise a local file with a remote file
    • wget - download a file (unlike rsync this is only for publicly available files)
    • curl - Only for single URLs, and can support more protocols than wget
    • ping - test network availability
    • less - used to view large files by paging it. CTRL+N down, CTRL+P up, Q quit
    • cat - File viewer, but does not have pagination features of less
    • head - view first few lines of a file
    • tail - view last few lines of a file
    • cut - Pull out columns from a file
    • paste - paste data into columns
    • nl - print our the line number
    • sort - sort lines in a file
    • uniq - determine unique elements in a file
    • wc - line, word and character count
    • split - split large files
    • man - single page manual files for commands
    • info - for some applications this will provide more detail than what man provides
    • uname - lists system information
    • hostname - name of machine
    • whoami - name of current user
    • ps - list current running processes
    • kill - kill a process
    • top - list processes based on criteria
    • sudo - act as root user for one or more commands
    • su - become root user
    • tar - archival utility
    • gzip - compression utility
    • find - non-indexed file search
    • locate - indexed file search. Requires updatedb command to be operational
    • df - determine disk space
    • du - determine file's disk usage
    • grep is a text and file parser that uses regular expressions. Very powerful.
    • sed is a string substitution command. Used to do a find and replace.
    • awk is a useful scripting language for tab-delimited text.
  • A list of useful bash shortcuts:
    • CTRL+K : Kill everything from cursor up
    • CTRL+C : Abort command
    • CTRL+L : Clear the screen
    • CTRL+D : Exit the command prompt
  • Backticks ` allows you to use results from commands as part of a new command
  • Ampersand & allows you to run a command in the background
  • xargs allows you to build command line arguments, and can spawn parallel processes.
  • tee allows you output to both a file and the display
  • time is useful for bench-marking commands
  • screen is a manager for remote tabs. This allows you to save a context that allows you to resume your work if you lose connection temporarily.