RSS

Monthly Archives: June 2012

Function to get numeral range for code

Here’s the code I wrote for the ‘numbers’ function. This is another simple function to obtain input from the user.The only thing needed if to verify that the input is within range and that that value is passed back out of the function:

 

//function to get numerals to be used in code

var numbers = function(){

var enteredNumber = 0;

var numbersVeritas = false;

while (numbersVeritas === false){

console.log(“***numbers function reached***”);

//player inputs how many digits the code will be

// so far numbers function works fine

enteredNumber = prompt(“code will consist of numerals 1 – : (1-9)”);

if (enteredNumber>0 && enteredNumber <=9){

console.log(“We will be using numerals from 1 to “+ enteredNumber+ ” for our code”);

numbersVeritas = true;

return enteredNumber;

} else{

alert(“number is out of range.”);

numbersVeritas = false;

}

}

 

};

 

 

//function call

var enteredNumber = numbers(); // brings the variable enteredNumber out of the function

console.log(enteredNumber); // used to verify enteredNumber is passed back from function

 
Leave a comment

Posted by on June 30, 2012 in Uncategorized

 

Abiogenesis

Sometimes, in the summer, I forget I’m a teacher and get pretty down. I love having the summer off to spend with my son, but I certainly have the itch to get back in the classroom. I found a paper today from the March4, 1876 edition of the British Medical Journal entitled, “A word on the Origin of Bacteria, and on Abiogenesis.” In this article William Roberts (a contemporary of Pasteur) does a wonderful job in explaining the faults of the theory of abiogenesis. Such a wonderful job that I will have to include this letter in my reading packet / handbook for General Biology.

We live in an age of certainty about where life comes from. It is very interesting to go back and see just how hard fought the ideas we take for granted once were.

 
1 Comment

Posted by on June 30, 2012 in Uncategorized

 

Cool site about RNA folding

A friend of mine just made me aware of this site that makes RNA folding into a game. The educational aspect focuses on teaching students/ players that RNA is not just a simple, linear molecule (like people think of mRNA most of the time) that carries information from DNA about making proteins. RNA is also a very dynamic molecule that has a number of functions not directly related to carrying information about building proteins. In fact, these molecules are so multifunctional, there is a pretty believable theory out there that the first life on this planet was wholly RNA-based.

This game illuminates just why the RNA-first theory makes so much sense: Because RNA can actually ‘do things’. It can fold on itself and form structures very similar to proteins and these structures can have functions very much as proteins do. In fact, many of us think about RNA as functional all the time. Ribosomes are perfect examples of this: RNA that acts as an enzyme.

I can’t wait to show this to my students in the Fall and see if it helps them get a better grasp on DNA/RNA base-pairing as well as the idea that folding of molecules dictates functions.

 

here’s the link, I hope you enjoy:

 

http://eterna.cmu.edu/eterna_page.php?sort=largest&page=groups&pageindex=0

 
Leave a comment

Posted by on June 29, 2012 in Education, Uncategorized

 

Tags: , , , , , , ,

function#1: User provides number of digits in the secret code

Here’s my first function.

It prompts the user to provide a number of digits from 1-6. It then confirms this with the user – well, really just me for debugging purposes. I also use a Boolean ‘codeVeritas’ to ensure that the number of digits the user enters is within the parameters defined.

 

//gets the number of digits used
var code = function(){
    var enteredCode = 0;
    var codeVeritas = false;
    //so far the codeVeritas is working fine
    while (codeVeritas === false){
        console.log(“***code function reached***”);
        enteredCode = prompt(“How many digits shall the code be? (1-6)”);
        //verify input
        if (enteredCode > 0 && enteredCode <= 6){
            console.log(“We will be using “+ enteredCode+ ” digits in our code”);
            codeVeritas = true;
            return enteredCode;    
        } else{
            alert(“number is out of range.”);
            
        }
    }

};

 

Tags: , , , , , , ,

Outlining and early steps in coding mastermind

The only language that I have an even decent grasp on right now is javascript. So, even though I know I’ll have to redo most of my work in order to get this project into XCode, I’m starting there.

 

My first thought was to create an outline of how I think the program should function.

 

I’m not sure what will change over time, but to start I had this:

 

//gets the number of digits used

var code = function(){

console.log(“***code function reached***”);

};

 

//gets numerals to be used in code

var numbers = function(){

console.log(“***numbers function reached***”);

};

 

//sets up an array of numbers that will be the secret code

// code is the number of digits, number is the integers used for each digit

setSecretCode = function(code,numbers){

console.log(“***reached setSecretCode function***”);

};

 

//accepts guess from user and parses it into an array of ‘code’ length

acceptGuess = function(code,numbers){

    console.log(“***acceptGuess function reached***”);

};  

 

var compareGuess = function(){

    console.log(“***compareGuess function reached***”);

};

 

var showResult = function(){

    console.log(“***showResult function reached***”);

    exitShowResultLoop = true;

};

 

 

var exitShowResultLoop = false;

//computer prompts users for parameters to build secret code

var enteredCode = code(); // brings the variable  enteredCode out of the function

console.log(enteredCode); //checking variable

var enteredNumber = numbers(); // brings the variable enteredNumber out of the function

 console.log(enteredNumber); //checking variable

 

//computer sets secret code

var secret = setSecretCode(enteredCode,enteredNumber);

 

//printout of array for debugging

console.log(“secret code is: “+ secret);

 

//play the game using a while loop to loop until correct guess is made

while (exitShowResultLoop === false){

    var guessArray = acceptGuess(enteredCode, enteredNumber);

    console.log(“guess is: “+guessArray);

    compareGuess();

    showResult(); //contains an exit clause

}

console.log(“You’ve done it!!! Congratulations!!”);

 

 Really, this is just a list of functions and function calls that I want to build out. I think that if I can write each of these properly, I should have a functioning game. For starters, I have a ton of console.log()’s littered everywhere just to make sure that the program is going to each function in turn. Once I complete a section, I comment them out or completely delete then and replace them with notes about how things work.

Another important thing I learned was that it’s easiest to look at this in chunks. set variables myself and send them into the functions so they could be made independently. I’m sure this is not worth mentioning to anyone who has done any programming, but to someone like me it was an epiphany.

 

More later as I flesh things out….

 

Tags: , , , , , ,

Still hot

My son wanted to roast marshmallows this morning.

Outside.

On an open fire.

I’ve mentioned that it’s been 100+ degrees for as long as I can remember – and zero rain. We’re living in a state that might as well be a tinderbox. And he wants to have a fire.

Well, I’ve been reading ‘The Happiness Project’ – a book which I have to say is OK, but at least half of my interest in it comes from my amazement over the author’s life. It’s primarily a handbook on happiness punctuated with personal vignettes illustrating how the author puts the rules she proposes to work in her own life. 

My amusement comes from rules like ’embrace failure’ which she provides examples for that remind the reader of what a perfect life she has and how much yours sucks. Failure in her life is exemplified by not getting a regular column in The Washington Post or New Yorker or something and only being the #5 most awesome blog in the world.

Examples of failure in most people’s lives are more like,’fired from job and left by spouse / girlfriend / S.O. on same day that you were diagnosed with cancer. – Oh, and I don’t have a nationally syndicated column in the world’s best newspapers either.’

She’s also a bit sad because being beautiful, smart and rich sometimes leaves you with no need to have direction in her life. 

 

Hey – I didn’t mean to pan this book or anything. Actually, there’s a lot of pretty decent advice in there. And most of it is at least putatively grounded in solid research (I admit to being too lazy to look that up myself). In fact, I wouldn’t be making this blog at all if it wasn’t for her suggestion to do it.

But, why am I talking about this book at all? Because the author also references another work on parenting that I thought was interesting. The advice she passes along can be boiled down to – ‘Take it easy. Stop saying NO to everything and get behind your child’s ideas rather than obstructing them.’ That sounds obvious, but how many of us actually do that? It’s so much more likely that we say, ‘No, we’re not doing that’ than, ‘well, why not start a campfire and roast marshmallows in the scorching heat while risking starting a wildfire that could engulf the entire midwest?’

And you know what? It was fun. It wasn’t that hot early in the morning. And keeping a bucket of water next to the fire made me feel much more in control of the situation and at least somewhat ameliorated the risk of catastrophe. 

All in all, being amore agreeable person helped us both enjoy our day a little more.

 
 

Tags: , , , , , , , ,

More on setting up the mastermind app

In my last post I mentioned that several things had to be set up in iTunes Connect, but I didn’t provide much in the way of details. Here, I’m uploading a couple screenshots to show what kind of setup was done. I am assuming that you already have a developer account and can sign into iTunes Connect with it. The first screenshot if of iTunes Connect after signing in. This is the main menu page where you can look at stats of previous apps you’ve made, read your contracts, adjust financial information or goto ‘manage apps’ to see what you have going on right now – this is also the place where you make new apps.

Go into the manage tab and you will see something that looks like screenshot #2. For DHS, this presently shows that we have two apps available on the app store (green lights), one that had a problem that I still need to fix (red light) and the new one I just made (SafeCracker! -which has a yellow light).

If you click on any of these apps, you will see info about them. I clicked on the new SafeCracker! app and was taken to a screen that looks like screenshot#3.

You can create a new app from the screenshot#2 page and you will be prompted to enter info that you see in my screenshot #3. As I said before, you may have to upload some placeholders until you have artwork made up.