Lift Goals Q1 2011

It’s increasingly less un-stereotypical now, but as an IT worker who sits at a computer all day, i’m working toward amassing a completely useless amount of strength, via powerlifting/weightlifting.

Shortly before the end of 2010 I set some goals for this year. My first goal deadline is April, I’m aiming to:

  1. Deadlift 200kg
  2. Squat 160kg
  3. Bench 120kg

My current achievements are:

  1. Deadlift 175kg
  2. Squat 130kg
  3. Bench 100kg

I’m going to do this by using increasing lower rep sets as each workout goes and more importantly, listening to my body when hitting the gym. If i don’t feel that a body part is ready to be worked again, I won’t go, or will do something else.

For example; Bench Day:

  • Warmup @ 50kg x 8
  • 1 Set @ 70kg x 6
  • 1 Set @ 90kg x 4
  • 1 Set @ 100kg x 2

This kind of routine seems to work for me for Squats and Deadlifts, it remains to be seen if I can increase my Bench in the same way. All i know is that my chest hurts for days after.

Update:

I hit my first target: Deadlifts, on the 20th, easily got 200kg x 2 but couldn’t get 205 off the ground (by then it would’ve been my 6th set though) – 3 months early! I’m increasing my target to 210kg to make it 2xbodyweight

Managed 3x110kg Bench Yesterday, couldn’t do 120kg but didnt try 115. Increasing target to 130kg since I’m close already. Squats in a few days so if I have a spotter that might get smashed too!

Converting Sage Data to MySQL

Recently I came across a post by Rick Vause demonstrating a simple method for syncing your financial data from sage up onto your webserver. The advantages of this are plenty, most frequently this is required to show live stock and financial data on a web application.

I say simple, because the concept really is obvious once you read the code.

His post is here: sagetomysql

The process is easy to understand:

  1. Setup a DSN to the sage data, using the sage tool.
  2. Write a PHP script to connect to the DSN using PHP’s ODBC
  3. Add a MySQL connection to your PHP script.
  4. Tell ODBC which table you want to copy across
  5. Loop through the field names and field types with PHP’s odbc_field_name and odbc_field_type
  6. Allow the PHP script to create the duplicate table in your MySQL database.
  7. Copy the data across using php, updating records if this is not the first run

This script works fine for a single table, but it can be improved using odbc_tables().

We can eliminate the process of specifying the sage table name, and get all of the data online in one go. odbc_tables allows us to loop through every table in the Sage data source and pull them through into our initial database.

I’ve made the required modifications to Rick’s script and uploaded it here:

http://d62.net/demos/php/sage_to_mysql.phps

It’s currently untested, but I will be using it in some projects soon, so any required updates will be made then.

It’s worth noting that due to PHP’s large database support, it’s possible to convert it to any of the supported databases just by changing some of the function names used and confirming the CREATE TABLE syntax in those.

With some small modifications to use PEAR::SpreadSheet_Excel_Writer it could even just dump all of the data to an excel file – not very practical, but cool to know it can be done.

Yii: CActiveForm JUI – Slider Input (CJuiSliderInput)

After the topic yesterday about using a jQuery UI date picker in Yii forms, i’ll demonstrate a similar method of obtaining a slider form input for the same scenario:

In my example i’m setting the value of employee_holiday_entitlement by dragging a slider.

<div>
<?php echo $form->labelEx($model, 'employee_holiday_entitlement'); ?>
<?php
$this->widget('zii.widgets.jui.CJuiSliderInput', array(
'name' => CHtml::activeName($model, 'employee_holiday_entitlement'),
'value' => $model->attributes['employee_holiday_entitlement'],
// additional javascript options for the slider plugin
'options' => array(
'min' => 0,
'max' => 50,
'change' => 'js:function(){
$("#employee_holiday_entitlement_value").html($(this).slider("value"));
}'
),
));
?>
<span id="employee_holiday_entitlement_value"><?php echo $model->attributes['employee_holiday_entitlement']; ?></span>
<?php echo $form->error($model, 'employee_holiday_entitlement'); ?>
</div>

This will add a slider with an upper limit of 50, the “change” option is specified with a javascript callback to update the span below the slider with the current value. This gives the user an indication of the number they’ve chosen.

Yii: CActiveForm JUI – JQuery UI Inputs (CJuiDatePicker)

I found it pretty difficult to find a reference for how to integrate a jQuery UI date picker in with my CActiveForm view and model.

This is what I found to work correctly for datepicker, for the model field “dob_date”.

<div>
<?php echo $form->labelEx($model, 'dob_date'); ?>
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
   'name' => CHtml::activeName($model, 'dob_date'),
   'value' => $model->attributes['dob_date'],
));
?>
<?php echo $form->error($model, 'dob_date'); ?>
</div>

You might need to wrap a function around $model->attributes['dob_date'] to output it as dd/mm/YYYY from a timestamp if that’s the type of field the model attribute represents

Convert MSSQL timestamp to UNIX timestamp

Today I had to pull a number of datetime fields from MSSQL and update records in MySQL with them, using PHP.

The most efficient way to convert the date-time field to a unix timestamp for inputting into MySQL was the following:

DATEDIFF(s, "19700101", ro_job_date) as ro_job_date,

In this example the field was ro_job_date

19700101 is the 1st Jan 1970, the “unix epoch”.

I didnt have to convert from unix timestamp to MSSQL datetime, but researching the above turned up this snippet for that:

SELECT DATEADD(s, unix_timestamp, '19700101')

where unix_timestamp is your timestamp field