Wednesday, July 6, 2016

Using PHP Composer

Setting up composer

Make sure composer is in your path. If on Linux this can be easily accomplished by adding the composer.phar file to ~/bin.



How to update composer


composer.phar self-update


Installing/updating project packages

1) A composer.json file should be stored in the root of your project.
2) cd into the root folder of your project
3) Run 
composer.phar update

Cordova Notes



How to update npm

npm install -g npm


Installing Cordova

npm install -g cordova

Setting up, building, and testing a project


Monday, January 5, 2015

Titanium sdk and Android SDK notes and command line stuff

titanium links
================

previous sdks

http://builds.appcelerator.com.s3.amazonaws.com/index.html#3_0_X

previous studios:

old studios: http://docs.appcelerator.com/titanium/2.1/#!/guide/Reverting_to_a_Previous_Version


android sdk
===========

* list avds
android list avd

* install apk (restart afterwards?)
adb -e install path/to/apk

* start emulator
emulator -avd name_of_avd

unfortunately you need a google api emulator to test out the map

* if you have a problem with the emulator (like it won't start), try restarting adb
adb kill-server

General titanium sdk notes
====================

it uses argb for colors

command line titanium interface
=========================

* build
ti build (cd to the project folder)

* build only w/o running
ti build --build-only --platform android







Tuesday, October 28, 2014

PHP and Databases Intro

Databases and PHP ================== PHp is interpreter. Translates PHP code to machine code, the processor runs and it outputs text (we use echo statements to output html friendly text). Programming languages require connectors to get to database. PHP usually comes with this. Just have to enable it. mysqli - class for working with mysql databases from PHP Database Management System - This is your database server (or service). Manages access to the databases in an efficient manner. Databases - Usually a collection of files efficiently organized to retrieve and update data. Contain tables and security information (login info and who has access to what). Tables - reside in a database. They store the data in the form of rows. Tables have columns which multiple properties. Index - way to improve the speed of searching a database based on certain fields, like if we wanted to search a dentist's name. Dentist table example ~~~~~~~~~~~~~~~~~~~~~ Dentist (id -primary key, name - unique, address, phone, email_address - unique ) Column properties: auto increment primary key data type - integers, strings (varchar, char, usually have to specify number of characters), date, datetime, bit (1 or 0) unique 1, john smith, 123 street, 123 456 7890 2, beth , 456 street, 123 456 7890 3, debbie, 789 street, 123 456 7890 3, james, 789 street, 123 456 7890 <-- illegal , can't happen because of primary key constraint 4, james, 123 street, 123 456 7890 <-- illegal, can't happen because of unique key constraint Dentist (id -primary key, name , address, phone, email_address - unique ) Better to use email address as unique constraint. Operations you usually do on a database: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ designing (create tables, columns, constraints, indexes etc) assigning access querying (reading) -- usually do this in php updating -- usually do this in php inserting (create) -- usually do this in php deleting -- usually do this in php CRUD (create, read, update, delete) operations

Thursday, October 9, 2014

Web Design - Basic elements of a web page


Download the files for this intro web design lesson from here 

How  web pages render. 

Web pages (or web document) are built using plain text files with special syntax.

Example:
<!DOCTYPE html>
<html>
<body>
<h1>
My First Heading</h1>
My first paragraph.
</body>
</html>

They are stored on web servers whether they be on a physical server, cloud server, or some other hosting system. Web servers wait for requests for documents and assets from web browsers. Assets usually consist of images, javascript files, and CSS files.

When a user points their web browser to a particular web address it creates a request to download the web page document to your browser for processing. If the syntax is correct within the web document then the page is rendered in your browser.

How to create a simple web document

1) Download a copy of notepad++ or sublime text 2
2) Create a new document
3) copy and paste this html text into your document

<!DOCTYPE html>
<html>
<body>
<h1>
My First Heading</h1>
My first paragraph.
</body>
</html>

4) Save it as test.html and double click it to open it in your web browser

Parts of a web document

<!DOCTYPE html>
<html>
<head><title>Page 1</title>
<style >
#header {
    background-color:red;
    color:yellow;
    text-align:center;
    padding:10px;
}
#nav {
    line-height:30px;
    background-color:#999999;
    height:350px;
    width:150px;
    float:left;
    padding:15px;
}
#section {
    width:400px;
    float:left;
    padding:15px;
}
#footer {
    background-color:red;
    color:white;
    clear:both;
    text-align:center;
    padding:15px;
}
</style>
</head>
<body>

  <div id="header">
  <h1>Some header</h1>
  </div>

  <div id="nav">
  Page1<br/>
  Page2<br/>
  Page3<br/>
  </div>

  <div id="section">
  <h1>Page 1</h1>
  <p>
  I'm a paragraph
  </p>
  <p>
  I'm a paragraph too</p>
  </div>

  <div id="footer">
  I'm a footer
  </div>
</body>
</html>

Let's go over the above. Our web page is broken down into main elements  which are separated by tags. We use the div tags to divide a html document so we get the layout we desire. Typically a web document is divided so it has a header, menu or navigation , body and footer. This is totally arbitrary but it is a good design because it allows users to navigate your site easily with a menu and there is enough real estate to brand your website and provide content. The style tag allows us to take advantage of CSS. There are few rules here and they directly pertain to the tags we defined in the body tag. As you probably noticed the div tags have id attributes to distinguish them. These allow us to easily apply CSS to them as above.

Exercise:

Try creating the other 2 pages and link them together. So page 1 through 3 are each can link to each other.



Intro to Bootstrap


Try the following example for bootstrap. Get a copy of it from here : http://getbootstrap.com/getting-started/

<!DOCTYPE html>
<html>
<head><title>Page 1</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">

</head>
<body>

    <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">Project name</a>
        </div>

      </div>
    </div>

    <!-- Main jumbotron for a primary marketing message or call to action -->
    <div class="jumbotron">
      <div class="container">
        <h1>Hello, world!</h1>
        <p>This is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
        <p><a class="btn btn-primary btn-lg" role="button">Learn more ></a></p>
      </div>
    </div>

    <div class="container">
      <!-- Example row of columns -->
      <div class="row">
        <div class="col-md-4">
          <h2>Heading</h2>
          <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
          <p><a class="btn btn-default" href="#" role="button">View details ></a></p>
        </div>
        <div class="col-md-4">
          <h2>Heading</h2>
          <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
          <p><a class="btn btn-default" href="#" role="button">View details ></a></p>
       </div>
        <div class="col-md-4">
          <h2>Heading</h2>
          <p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
          <p><a class="btn btn-default" href="#" role="button">View details ></a></p>
        </div>
      </div>

      <hr>

      <footer>
        <p>© Company 2014</p>
      </footer>
    </div> <!-- /container -->


    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>


</body>
</html>

Exercise: try sprucing up the layout we created before using bootstrap. 

Wednesday, June 25, 2014

Pregnancy Quiz Vocab App

Released a new android quiz app to the google play market!

It features over 100 multiple choice questions to help get you ready for your pregnancy.

Content for this quiz app, comes from the Women's Health government website.

Go to the google play store to get the Pregnancy Quiz Vocab App today :)


 




Friday, March 28, 2014

How to set up a test cas server on windows


Set up tomcat 


1)  install tomcat

2) download cas from http://www.jasig.org/cas

3) Extract the download and copy the war file from the modules folder to webapps folder in your tomcat root

4) Create a self-signed certificate with keytool (or get a certificate)

keytool -genkey -keyalg RSA -keysize 2048 -keystore c:\path\to\keystore.jks -alias mykey -validity <days>

Replace <days> with number days the certificate will be valid for.

Answer all the questions and put in a keystore password. This will be used in the tomcat configuration later.
Certain password characters like ampersands may need to be escaped in the tomcat config

4) Edit your server.xml

Add the following line under the <server ..> tag

    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
                   maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"  keystorePass='<password here>' keystoreFile="C:/path/to/keystore.jks"/>

5) restart Tomcat and the war should installed

Config CAS


6)  Open the webapps/cas-server-webapp-version/web-inf/deployerConfigContext.xml file

Comment out the bean

SimpleTestUsernamePasswordAuthenticationHandler

like this

<!--<bean
class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler" />-->

7)

Add the generic authentication method:

<bean class="org.jasig.cas.adaptors.generic.AcceptUsersAuthenticationHandler">
   <property name="users">
      <map>
            <entry key="testuser" value="test" />
</map>
</property>
</bean>


Under the authenticationHandlers tag.

8) Copy the cas-server-support-version.jar to webapps/cas-server-webapp-version/web-inf/lib folder

9) Restart tomcat

10) you should be able to login by going to the following url:

https://server-ip:8443/cas-server-webapp-version/login



Tips for the CAS clients to avoid redirect loops


CAS clients are pretty particular about the ssl certificates. If the certificate is not trusted by the web application using your CAS server you may get redirect loops.

To avoid this buy a certificate or put your self-signed certificate in the trusted store on the computer where the web server is.


Helpful links

To set up CAS you have a good knowledge of SSL, tomcat and java keystores, especially if you want to do proxy authentication. There are many links below that can shed some light on these concepts and related issues.