Tuesday, August 31, 2010

Work Problem 5

The following was a question a anonymous visitor asked: Jim can fill a pool carrying buckets of water in 30 minutes. Sue can do the same job in 45 minutes. Tony can do the same job in 1 ½ hours. How quickly can all three fill the pool together?



Work problem 5 solution here


solve algebra word problems

Finding The Slope of a Line


solve free math problems

Strawberry Basket - HOTP Template

I know I know, I'm very bad ! But I couldn't help it, I've joined the Template HOTP Personal shopper. I thought why not since the pound is getting stronger and it's delivered every other month. This month the template allows you to make this lovely basket ! I've used the papers that came with the kit and the brads too. We also received as a thank you gift another mini template to make envelopes.

You all know I'm ! template mad so this kit was right up my street. I can see myself making a few for Xmas and Easter next year !



You can see the rest of my blog posts either by clicking the HOME link (Top Left) or this LINK

point paper template

Garage Sale-Purchased Negatives Found to be Ansel Adams', Appraised at $200 Million

In this Antiques Roadshow era, everyone dreams of finding some lost gem of art or antiquity to cash in on later.

In this case, a box of 65 glass plate negatives found at a garage sale 10 years ago for $45, has now been verified by handwriting and photography experts to be the work of Ansel Adams. Appraisers have valued the treasure trove at around $200 million. It was 10 years of hard work proving that they were authentic. I'm sure the California man who found them invested quite a bit of money toward that e! nd, so I suspect $45 initial price tag may be slightly misleading about the overall net cost.

The reason for their being off-premises is not explained, but that saved them from a fire that claimed 5000 other Adams negs. I have a hunch this was a reject bin Adams used for teaching materials. Granted, Adams' reject bin has amazing stuff in it, but perhaps he never intended some of these to see the light of day. Imagine someone going through your studio's garbage and selling your work after you're dead. Guess we'll never have to worry about that.

Story here on CNNs website.

So... if you see glass plate negs at the Elephant's Trunk flea market one Sunday... look very closely.

By the way, we can print from black-and-white glass negatives and other antique media, both traditionally and digitally. In color, we ! can reproduce them digitally. We did a job for the Newtown His! torical Society a number of years ago and pulled an incredible amount of detail out of some glass plate negs. Gorgeous prints of historical images. Film may be dying, but it is still sending us love letters from bygone eras.


online calculator with negatives

Using the PEBL Survey Generator

Version 0.10 of PEBL offers a survey generator, distributed in the Test Battery. It is designed to offer only limited interaction, so that the respondent sees only the survey questions and keys must make responses to continue. And as an experimenter, you can design it simply by editing a .csv file in your favorite spreadsheet or text editor.

There are a lot of web-based options for creating surveys.  PEBL won't run via a web browser, and so if you want to create a web survey, this is not the tool for you.  This will run on a dedicated computer, without internet access.  It is probably most useful for getting demographic information during a laboratory or field study, and this is mainly how I have used it in the past.

It is located in the test battery under the survey/ directory, but you need to tune it to your own situation. Here's how:




Features of the survey generator



The survey generator allows you to specify a sequence of screens which either provide information or request responses. One such screenshot is shown on the right. By editing a .csv file in a spreadsheet, you create the survey. Responses and time taken for each response are saved into a file for later processing; and the file gets saved according to a subject code which is the first response input during the survey.


Baseline survey demo
The baseline survey is set up to run at a resolution of 1024x600.   The layout is fairly flexible, so if you change the hard-coded resolution by editing survey.pbl, it will adapt to fit.  It has a title "PEBL Survey Generator" and a logo file hard-coded into the file survey.pbl. Finally, it uses by default the file questions.csv to specify the survey, and saves output as output/response-X.csv. You may want to change some or all of these parameters. The survey is set up to scale fairly easily to other screen sizes.

To customize the overall look and feel, open the file survey.pbl in a text editor, and look for the following lines:



Screen size:

Screen size is controlled by
gVideoWidth <- 1024  
gVideoHeight <- 600
Change these to a pixel width/height that your screen can handle. You can make the screen larger, but making it smaller may not afford enough space to use some of the survey questions.

Logo:

The logo is controlled by the line:
gLogoFileName <- "images/logo.png" #change to your own logo file. (400x80)

To use a different logo, create a 400x80 image (png, bmp, gif, or jpg) and save it in the survey directory. Then change the file name in the above line.

Title:
The title is specified by:

gSurveyLabel <- "PEBL Survey Generator"

Edit this line to change the name of the survey. To remove the survey text, change it to "".


Input and output files:
Input file is specified by:

dat <- ReadCSV("questions.csv")
 

Change questions.csv to some other csv file you want to use.

Output file is specified by the line:

 

fileout <- FileOpenAppend("output/results-"+gSubNum+".csv")

Note that this creates a file that depends on the variable gSubNum, which saves data for a subject to a file that depends upon their subject code. 
 
Defining the questions
The different types of questions are defined in a .csv file. The first column is a question ID which gets copied to the output file. The second file is typically a text description that appears in the survey. The rest of the columns depend on the question type, and are described in the next section. If you create the CSV file in excel, you sometimes have to be careful that it doesn't append empty lines at the end.  If the survey crashes when you get to the end of the questions, edit the questions.csv file with a text editor, and delete any lines at the end that only have commas



Types of screens
The survey generator offers sevenl different screen types. The third column of the questions.csv file controls which type of survey question is used.













Here is a description of the different question types, and the codes in column C used to specify them:

Type: Instruction
Code: inst
Description: Give a text instruction to user, who clicks 'next' to continue.
Notes: Text in column 2 of csv.





Type: Long answer
Code: long
Description: Probe with a question, allow respondent to type a long answer, which gets verified when complete.
Notes: Text in column 2 of csv.








Type: Short answer
Code: short
Description: Probe with a question, allow respondent to type a short answer and continue by hitting enter.
Notes: Text in column 2 of csv.






Type: Multiple choice
Code: multi
Description: Probe with a question, allow respondent to click on one of a set of answers.
Notes: Text in column 2 of csv. Column 3 contains a number describing how many options. Columns 4-N contains the response labels.








Type: Multiple check
Code: multicheck
Description: Probe with a question, allow respondent to click on any responses that apply.
Notes: Text in column 2 of csv. Column 3 contains a number describing how many options. Columns 4-N contains the response labels.





Type: Likert scale
Code: likert
Description: Probe with a question, allow respondent to click on an anchored scale
Notes: Text in column 2 of csv. Column 3 contains the number of responses.




Type: Image view
Code: image
Description: Show an image and give text. No direct input availabile.
Notes: Text in column 2 of csv. Column 3 contains name of image file.





Data output
The data are saved to a .csv file with the following columns:
subject code, question id, timestamp, response, type, response_time, response2
In these files, you can ignore response in favor of response2.

Tips and Tricks
* Under windows, you do not need to run the pebl launcher to execute a survey. Create a file called run.bat, and edit with a text editor. Put the following in the file:

"c:\Program Files\pebl\bin\pebl.exe" survey.pbl --fullscreen

This will execute the survey fullscreen. Because the subject code gets entered in the experiment, the launcher really isn't necessary.

* To abort an experiment mid-run, hit ctrl-shift-alt-\ simultaneously.
* If you accidentally reuse a subject code, the data will get appended to the data file (not overwritten).
* If the subject uses the 'back' button, response for that question will be recorded twice. You must filter the data to look at just the last response.

Summary
There are many online tools that allow you to easily create surveys. But sometimes you don't have access to the internet or wish to run a survey within a series of other tests. The PEBL survey generator allows you to develop fairly complex surveys with little effort, and you don't need web access to run the survey.

Here is a screencast of what taking the survey looks like:




number line generator

Extending NServiceBus: Avoiding Two-Phase Commits

When using non-transactional queues processing a message is trivially easy—just handle the message and write to your data store.  If the process dies and we lose a message, that’s okay.  But when using a transactional queue things can become more difficult because we want our infrastructure to ensure consistency between our message queues and application database.  I have already outlined the trouble of using two-phase commits in a previous post.

What if we were able to handle the inconsistency between our message queue and application data store at an application rather than infrastructure level?  What if we embraced receiving duplicate messages?  What if our application had the ability to make message processing idempotent, despite the message not being idempotent?  What if we were able to pi! ck and choose the messages that that became idempotent on a per-message type basis?

A Typical Example

Let’s go through a typical message processing example to see how this might work.

When everything is working properly we:

  1. Receive a message from the queue.
  2. Process the message.
  3. Save any changed application state to our data store and call Bus.Publish.
  4. Publish resulting messages.
  5. Message transactionally removed from the message queue.

But what about failure conditions?  This is exactly the type of thing that transactions are designed to handle.  How can we maintain application integrity without 2PC?  L! et’s consider a few failure conditions.

When the database transaction fails:

  1. Receive a message from the queue.
  2. Process the message.
  3. Write the changes to the database.
  4. Fail to commit, e.g. power outage, process restart, etc.

When the process comes back online, it’s going to pick up right where it left off and the application and message queue will be in a consistent state.

Now let’s examine a failure condition where the database commits but resulting messages failed to publish because of a power or hardware failure.

  1. Receive the message from the queue.
  2. Process the message.
  3. Save application state and call Bus.Publish.
  4. Commit application state (inside of a separate transaction).
  5. Power failure.

Herein lies the problem.  When the process comes back up, it’s going to reprocess the message…but it’s already been processed.  How do we handle that?

The Solution

What if we were to keep a log of all received messages (at least their identifiers) along with all bus activity (Publish, Send, Return, Reply) associated with the processing of that message?  What if we stored that list as part of our application state during the commit operation?  Doing so would allow us to check if a message was already processed.  If it was already processed, we could get the associated messages that resulted from processing and redispatch them.  It may be worth noting that event sourcin! g already stores all of the changes that resulted from process! ing a me ssage.  In that scenario you’re already saving the data, now it’s just a small initial check before processing.

What I have outlined above is actually a well-understood pattern and some message queue providers even provide database hooks to facilitate message de-duplication.  Pat Helland who worked at Amazon and Microsoft wrote a really good paper on this exact same topic a few years back.  One critical difference between what Pat proposes vs. what the message queue providers do is that Pat always works on local copies of data.  In other words, the boundary of each transaction is against a single machine or tightly bound cluster of machines.  This rings true to me because it is harmonious with SOA principles.

I recently created a proof of concept around these very same! principles and I call it “IdempotentConsumer”.  It’s an NServiceBus message handler along with associated application services that facilitate de-duplication of a message before handing it off.  In my proof of concept I am relying on two concepts—that each logical business message can be uniquely identified by a business identifier specific to the message and that each message is addressed to a single business entity—like an aggregate root.  Plug-ins could be written to work with alternative storage engines.

UPDATE: IdempotentConsumer has been updated to utilize more optimistic styles of concurrency.  Rather than checking each message that arrives before handing it off to the application, we instead assume that messages are not duplicate and handle any optimistic concurrency exceptions raised by our data store.

NoSQL

While the above wo! rks great when you have a resource that supports transactional! integri ty in the form of TransactionScope, it becomes more difficult when working with NoSQL storage engines, such as CouchDB, Cassandra, Riak, etc.

In a relational DB we can perform multiple writes to various tables and have all writes be transactional.  In NoSQL the boundary of a transaction is a single write.  Multiple writes means multiple transactions.  Granted, CouchDB does support batching, but you lose some consistency checks when doing a batch write to multiple documents simultaneously, such as the ability to raise an optimistic concurrency exception if you’re not writing using the latest version of a particular document.

So how do we write the list of published messages resulting from the message currently being processed and maintain transactional integrity with the changes in application state?  Easy.

Write the list of messages to be published as a result of processing the ! incoming message.  Once that transaction is complete, write the associated document containing the changes in application state--but include the ID of the message being processed *inside* the document.  When we query to obtain the list of messages we do a server-side or client-side MapReduce of sorts to effectively “join” the list of published messages with the associated parent message ID found in the application state document/row.  If the application state contains the ID found in the list of messages, redispatch the stored messages and we’re done.  If it doesn’t, delete the list of published message—they were never published because a failure occurred prior to writing the application state record.

Because we are doing this on a per-message type, we can customize the way we query each business object—we can have a standard way of querying most and then customize the way we qu! ery specific ones depending upon how they store the parent mes! sage ID.   We can vary the way we query based upon the document storage structure or even storage engine.

Conclusion

The biggest advantage of what I have elaborated is that we can effectively simulate a two-phase commit among multiple resources without the overhead of a 2PC.  These allows us to use storage engines whose drivers don’t support two-phase, e.g. MySQL, PostgresSQL, or virtually all NoSQL implementations.  Furthermore the receipt and publishing of a message is still transactional, it’s just a separate transaction from the storage of application state.  As I mentioned previously those that do event sourcing effectively get this for free, but a small amount of application service code must be written to facilitate it.

One big argument against the above is that we’re doing lots of unneeded queries to determine if we should even bother to process the m! essage.  Yes, that’s true, but we should only ever be querying a local storage (truly local or inside of our cluster). [UPDATE: The previous argument is nullified by using optimistic concurrency as noted in the previous UPDATE above.]  Next, we don’t need to implement this for every message type.  You are free to make your messages inherently idempotent.  You are also free to use safe, slow two-phase commit if the situation requires or operational environment allows.

These same patterns can be applied even when using non-transactional resources, such as sending an email.  The only quirk here is that there may be a one in a million scenario where we publish the same email twice.  But in that case, it’s not really a big deal if someone gets duplicate emails.


idempotent set to off

The Human Timepiece, Water Intake Calculator

I watched a really neat show last night called The Human Timepiece on the Discovery channel. It went through a day in two hour segments, breaking down what the body is naturally doing biologically at those times. It even said when the best time to eat and workout would be according to the body's biological clock. Here are some interesting tidbits I picked up from the show:

- Exercise in the late afternoon or early evening. (Around 4pm.)
Most athletic records have been set and broken during this time. They studied various athletes who did the exact same workout at different times of day and found out that those exercising around 4pm were up to 10% more effective than those working at other times of day. The morning is the lest effective time to work out because your blood vessels and arterie! s are less flexible. It even increases your chances for things like heart failure since your blood is also "thicker" for a few hours right after you wake up.

In other words: do you want to burn 10% more calories doing the same amount of work? Try to exercise around this time. Your body's core temperature is naturally slightly higher so you get extra benefits. I wish I didn't have to work graveyard. I'm two or three hours from waking up during this time. :/

- Eat the majority of your calories shortly after you wake up.
I use the term "morning" very loosely because I know that's different for everyone. For me it's usually around 7pm! Right after you wake up your blood pressure is naturally at its highest and stays that way until about mid day. If you eat your calories early on your body has the entire day to burn through them before putting the remainder in storage. On t! he show they gave people the exact same meals adding up to the! exact s ame amount of calories, but they ate the meals at different times. Those who had a large breakfast (50% of their daily calories,) a moderate lunch (35%,) and very little for dinner (15%) used their caloric intake most effectively. For those who prefer to snack between meals, subtract calories from your dinner allowance.

Eating causes your glucose levels to go up and if that happens right before a period of relaxation (like sleep) your body is much more likely to store the fat for a time when you need it. I guess this is why I've always heard you shouldn't eat ____ hours before you go to bed.

Following a calorie plan like this one would be very difficult for me. I normally eat a huge amount (if not all of!) my calories right before bed for a bunch of reasons: I'm home and done rushing around so I actually have time to dedicate to a meal, I feel like relaxing and having something to eat, I have nothing to do so I get bored and eat, plus I usually feel tir! ed after eating a decent meal. My weight struggle also comes into play here. I can't help but think that if I'm going to eat, at least I can do it right before I peace out from the world for a while. That way I know the food has hours to digest before I have to look at the scale again.

I also find that I feel more hungry if I haven't had a chance to really acknowledge and comprehend a meal. How do I do that? Do I sit there and have a conversation with it? Do I read into it? Do I practice active listening while the food communicates with me? What I mean to say is that I really need to remember the experience of eating. I want to have something that I enjoy the taste of and take a while to consume it. If I rush through a meal that isn't very stimulating to my senses I think I'm more likely to forget that I ate or feel like I've cheated myself in some way. This goes back to some of my cardinal rules, one of which is...

"I have to love it. This applies for everything from now on. If I'm going to put it inside of me and risk all the calories, fat, weight, and stress... then it better be super delicious and exactly the way I like it. If there's something I don't like about it then that's just another excuse for me to stop eating it."

-Drink a ton of water.
I never ever used to drink enough water. I would have sodas all day, and maybe some juice, chocolate milk, or other flavored beverage if it came my way. It's no wonder that I was 50lbs+ / 23kg+ heaver than I am today. Even today I struggle with it because I feel like I'm going to put on a ton of weight. This show reminded me that water is totally neutral and has no calories. It's what most of your body is made of and it needs a lot of it to function at its peak! . If you're not hydrated, you won't burn as many calories by doing normal activities (breathing, sleeping, etc.) I have to tell myself that it'll be worth it in the long run. (Plus... I'm a creep and I weigh myself every time I use the restroom at home. It's neat to see how much weight I can lose just by doing it.)

There are also so many zero calorie things that can be done to water to give it flavor. You can have it at a variety of temperatures and textures (0 calorie gelatin, anyone?) This cool calculator will tell you exactly how much water you need in a day. Not everyone needs the recommended 64 ounces. It says I should have 90 ounces a day... bleh.

Theme for thinspiration is before and after. It's probably my favorite, along with scene/alternative/emo/whateveryouwannacallit. [:


















I've mentioned my roommate a few times (she's with me in some of my MySpace pictures.) My height, 90lbs, vegan, constant reminder that I need to lose some weight? Here's what she looks like.



Don't forget about the giveaway on this blog! It ends soon! [:


how many hours until calculator