Aims for 2017

It's that time of year again when I look back over the goals I set myself over the previous year and decide on some new ones for the year ahead.

What I intended to do in 2016:

  • Contribute to some open source projects – Failed miserably.
  • Put more time into electronics projects – Plenty of time put in, much frustration and little fun :(.
  • Clear out Garage – It’s getting clearer.
  • Write an android application for my tablet/phone – Fail – idea abandoned.
  • Build a new PC – Some parts have been sourced, waiting for AMD to release the Ryzen processors early in 2017.
  • Do something useful with a virtual machine - Fail, looked into 3D acceleration of a VM. It appears that it is best achieved with a separate graphics card. This requires hardware support which my current set-up lacks.
  • Finish Back Yard – Still need to put a slab in for a step.
  • Buy a new kitchen bin – I still need one that matches, but it functions.
  • Cook a good Lamb Pathia from scratch – Failed – attempt next year.
  • Eat more fruit and veg – More cabbage has been eaten (along with pie & mash).
  • Perform more off-site data backups - More backups in general are needed. 2016 saw me attempt crypto-ransomware recovery. Luckily a success due to decryption program availability. Backup Now!!!
  • Read more books – Didn't get through many in 2015 or 2016.

2016 hasn’t been the most productive year. I hoped to have progressed further with my electronics projects but difficulties along the way resulted in periodic loss of motivation. The PC build was researched and was close to being realised. The VM 3D investigation focused new build on needing 2 graphics cards. Intel’s platform offering made this set-up along with new and future hardware connectivity quite limiting. With AMD’s new CPU offering and Intel’s new chipsets on the horizon the decision was made to delay purchasing core build components until the new year. One thing has become clear, I need to plan my free time to achieve more.

What I aim to do in 2017:

  • Lose weight – I have slowly been gaining weight 🙁
  • Continue work on STM32 development – I’m slowly making progress.
  • Clear out Garage – A few large items need to go.
  • Build a new PC – This will happen, I can’t delay it any longer.
  • Finish Back Yard – The step will be installed at long last.
  • Buy a new kitchen bin – It might happen.
  • Cook something new – I will break out of my routine dishes and try making something different.
  • Eat more healthily – Less chocolate, fat, carbs.
  • Perform more data backups – More off-site backups too.
  • Read more books – I have a shelf of unread books waiting to be read.
  • Plan Free time – Make time for things I want to do.

2017 has some achievable targets. I three I want to achieve are losing weight, building a new PC and finishing the back yard. I need a good excuse if I don’t manage these.

AIMS FOR 2016

It's that time of year again when I look back over the goals I set myself over the previous year and decide on some new ones for the year ahead.

What I intended to do in 2015:
  • Contribute to some open source projects – I only contributed a single bug report. The only open-source projects I contributed to were my own. Needs more work. Failure.
  • Put more time into electronics projects (Raspberry Pi/Wireless Sensor System) - I have been working on my Wireless Rat Trap Notification System and experimenting with a small OLED display. A variable dummy load is waiting to be built. Success.
  • Tackle the rodent menace in the loft - All the insulation was removed, the holes plugged with wire wool and expanding foam. Re-insulated and as far as I know still rodent free. Success.
  • Clear out Garage – I did clear out the garage but filled it with bags of old loft insulation whilst tackling the rodent menace. Still need to get rid of the stuff. Partial Success.
  • Buy a new Android Tablet – I bought a Pixel C, a vast improvement. Success.
  • Write an android application for my tablet/phone – Didn't get around to to it. Failure.
  • Build a new PC – I am still waiting to find a new case I like and instead spent the money on a Tablet. Failure.
  • Repave Back Yard – Main paved area complete. Needs the edges finishing off and a step putting in. Partial Success.
  • Buy a new kitchen bin – Still got the old one. Failure.
  • Cook a good Lamb Pathia – Haven't had another attempt. Failure.

2015 was another mixed year. Plenty of successes, but too many failures. On the positive side the successes were in bigger/more important projects. The failures are things that can be addressed in the future.

What I aim to do in 2016:
  • Contribute to some open source projects – Other than my own this time.
  • Put more time into electronics projects – More experiments, more fun.
  • Clear out Garage – Time for another attempt.
  • Write an android application for my tablet/phone – I have an idea for something simple.
  • Build a new PC – Current systems are around 7 years old.
  • Do something useful with a virtual machine.
  • Finish Back Yard – A little bit of finishing off from 2015.
  • Buy a new kitchen bin – I still need one that matches.
  • Cook a good Lamb Pathia from scratch – I like a good curry.
  • Eat more fruit and veg – Might have long term benefits.
  • Perform more off-site data backups.
  • Read more books – Didn't get through many in 2015.

2016 has fewer big projects, so hopefully I will have more time to tackle my list. The three I need to get done are the Garage Clearout, Finishing the Back Yard and building a new PC. All should be achieveble and it will be a bad year indeed if I can't manage them.

Aims For 2015

Time for a look back at what I intended to do last year.

  • Contribute to some open source projects – Failed Completely.
  • Put more time into electronics projects (Raspberry Pi/Wireless Sensor System). - Work continues, some code committed to GitHub.
  • Get curtains for lounge – Done, it looks more like a home.
  • Clear out Garage (again) – Some progress but it keeps filling up.
  • Write an android application for my tablet/phone – Failed, never even thought about it.
  • Pay off student loan – Done, mortgage is the next big one.
  • Carpet master bedroom – Failed, sticking to laminate flooring.
  • Build a Gaming PC and/or Steam Box – Failed, didn't have the games to justify building.
  • Repave Back Yard – Failed, never even started.
  • Use a Linux desktop environment other than Gnome 3 for at least a month – Failed, LXQt was on the list but wasn't in the Fedora Repo. It is now.

So 2014 was mixed, some things achieved some not. Too many not unfortunately.
Time to see if I can complete some of last years goals in 2015.

  • Contribute to some open source projects
  • Put more time into electronics projects (Raspberry Pi/Wireless Sensor System)
  • Clear out Garage (This time I mean it)
  • Write an android application for my tablet/phone
  • Build a new PC – A couple are approaching 6 years old.
  • Buy a new Android Tablet – My Nexus 7 (2012) is starting to show its age.
  • Repave Back Yard – It would be nice to have a BBQ surface.
  • Tackle the rodent menace in the loft – They are back again 🙁
  • Buy a new kitchen bin – I need one that matches the rest of it.
  • Cook a good Lamb Pathia – Previous attempt needs significant improvement.

Another to do list, but as before it will be a good year if I can cross a few of them off.

New Year, New Ideas, Problems Solved

Well its now 2010, Happy New Year!!!, and my mailserver guide is still not on the site. It has not been forgotten and in fact part of the guide is already hidden away under going editing. One of the issues that was delaying progress was finding the best way to display code on the site. There are alot of plugins for WordPress that will do syntax highlighting using Geshi. What I have wanted to do is highlight specific lines of highlighted syntax to make it easier to show changes. I did a little research and found that Geshi already supports the functionality I required but it hadn't been implemented in any WordPress plugins. So I decided to modify one. I selected CodeColorer to modify as it already had a method of processing arguments within the "cc" tag it uses.

The modification is simple but has a few limitations. Firstly each line that needs to be selectively highlighted needs to be referenced by line number. This is easy for a few lines but is going to mean alot of number typing for large chunks of code. That said for really big chunks of code they are probably best split off from the rest of the file anyway. The line highlight only stretches to the limit of the longest line and not the whole of the code window. Only a single colour can be specified for the selective highlight and it only works if the Geshi style is selected rather the the custom CodeColorer themes.

Lets now have a look at the modification and what it does. I only needed to modify the codecolorer-core.php file in the plugin directory with a few lines. I have highlighted the changes on lines 161-167 using the modification. To achieve this I placed a new argument 'highlight' into the tag after the language argument [cc lang="php" highlight="161,162,163,164,165,166,167"]. The 'highlight' argument takes a comma separated list of line numbers to highlight. Thats basically it, the modification takes the line numbers, puts them into an array and passes it on to the inbuilt functionality of Geshi which handles the rest.

codecolorer-core.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
<?php
/*
CodeColorer plugin core part
http://kpumuk.info/projects/wordpress-plugins/codecolorer
*/
/*
    Copyright 2006 - 2009  Dmytro Shteflyuk <kpumuk@kpumuk.info>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

class CodeColorer {
  var $blocks = array();
  var $comments = array();

  var $geshiExternal = false;
  var $geshiVersion = '1.0.8.4';

  var $samplePhpCode = '
   [cc_php]
   /**
    * Comment
    */
   function hello() {
     echo "Hello!";
     return null;
   }
   exit();
   [/cc_php]
 ';

  /** Search content for code tags and replace it */
  function BeforeHighlightCodeBlock($content) {
    $content = preg_replace('#(\s*)\[cc([^\s\]_]*(?:_[^\s\]]*)?)([^\]]*)\](.*?)\[/cc\2\](\s*)#sie', '$this->PerformHighlightCodeBlock(\'\\4\', \'\\3\', $content, \'\\2\', \'\\1\', \'\\5\');', $content);
    $content = preg_replace('#(\s*)\<code (.*?)\>(.*?)\</code>(\s*)#sie', '$this->PerformHighlightCodeBlock(\'\\3\', \'\\2\', $content, \'\', \'\\1\', \'\\4\');', $content);

    return $content;
  }

  function AfterHighlightCodeBlock($content) {
    $content = str_replace(array_keys($this->blocks), array_values($this->blocks), $content);

    return $content;
  }

  function BeforeProtectComment($content) {
    $content = preg_replace('#(\s*)(\[cc[^\s\]_]*(?:_[^\s\]]*)?[^\]]*\].*?\[/cc\1\])(\s*)#sie', '$this->PerformProtectComment(\'\\2\', $content, \'\\1\', \'\\3\');', $content);
    $content = preg_replace('#(\s*)(\<code .*?\>.*?\</code>)(\s*)#sie', '$this->PerformProtectComment(\'\\2\', $content, \'\\1\', \'\\3\');', $content);

    return $content;
  }

  function AfterProtectComment($content) {
    $content = str_replace(array_keys($this->comments), array_values($this->comments), $content);
    $this->comments = array();

    return $content;
  }

  /**
   * Perform code highlightning
   */
  function PerformHighlightCodeBlock($text, $opts, $content, $suffix = '', $before = '', $after = '') {
    // Preprocess source text
    $text = str_replace(array("\\\"", "\\'"), array ("\"", "\'"), $text);
    $text = preg_replace('/(< \?php)/i', '<?php', $text);
    $text = preg_replace('/(?:^(?:\s*[\r\n])+|\s+$)/', '', $text);

    // Parse options
    $options = CodeColorerOptions::ParseOptions($opts, $suffix);

    if ($options['escaped']) {
      $text = html_entity_decode($text, ENT_QUOTES);
      $text = preg_replace('~&#x0*([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $text);
      $text = preg_replace('~&#0*([0-9]+);~e', 'chr(\\1)', $text);
    }

    $result = '';
    // Check if CodeColorer has been disabled for this particular block
    if (!$options['enabled']) {
      $result = '<code>' . $text . '';
    } else {
      // See if we should force a height
      $num_lines = count(explode("\n", $text));

      $result = $this->PerformHighlightGeshi($text, $options);

      $result = $this->AddContainer($result, $options, $num_lines);
    }

    if ($options['inline']) {
      $blockID = $this->GetBlockID($content, false, '<span>', '</span>');
    } else {
      $blockID = $this->GetBlockID($content);
    }
    $this->blocks[$blockID] = $result;

    if ($options['inline']) {
      $result = $before . $blockID . $after;
    } else {
      $result = "\n\n$blockID\n\n";
    }

    return $result;
  }

  /**
   * Perform code protecting from mangling by Wordpress (used in Comments)
   */
  function PerformProtectComment($text, $content, $before, $after) {
    $text = str_replace(array("\\\"", "\\'"), array ("\"", "\'"), $text);

    $blockID = $this->GetBlockID($content, true, '', '');
    $this->comments[$blockID] = $text;

    return $before . $blockID . $after;
  }

  /**
   * Perform code highlighting using GESHi engine
   */
  function PerformHighlightGeshi($content, $options) {
    /* Geshi configuration */
    if (!$this->geshi) {
      $this->geshi = new GeSHi();
      $this->geshi->enable_line_numbers(GESHI_NO_LINE_NUMBERS, 1);
      if (is_feed()) {
        $this->geshi->set_overall_style('padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap');
      }
    }

    $geshi = $this->geshi;
    $geshi->set_source($content);
    $geshi->set_language($options['lang']);
    $geshi->set_overall_class('codecolorer');
    $geshi->set_tab_width($options['tab_size']);
    if (!is_feed()) {
      $geshi->enable_classes($options['theme'] != 'geshi');
      if ($options['nowrap']) {
        $geshi->set_overall_style('white-space:nowrap');
      } else {
        $geshi->set_overall_style('');
      }
    } else {
      $geshi->enable_classes(false);
    }
    if (!is_null($options['strict'])) $geshi->enable_strict_mode($options['strict']);
    if ($options['no_links']) $geshi->enable_keyword_links(false);
    /* My Custom Bit */    
     if ($options['highlight']){
        $myarray = explode(",",$options['highlight']);
        $geshi->highlight_lines_extra($myarray);
        $geshi->set_highlight_lines_extra_style('background-color: #ffff66;'); /* Select the colour of the highlight */
    }
    /* End My Custom Bit */  
    if ($options['inline']) {
      $geshi->set_header_type(GESHI_HEADER_NONE);
    } else {
      $geshi->set_header_type(GESHI_HEADER_DIV);
    }

    $result = $geshi->parse_code();

    if ($geshi->error()) {
      return $geshi->error();
    }

    if ($options['line_numbers'] && !$options['inline']) {
      $table = '<table cellspacing="0" cellpadding="0"><tbody><tr><td ';
      if (is_feed()) {
        $table .= 'style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"';
      } else {
        $table .= 'class="line-numbers"';
      }
      $table .= '><div>';
      for ($i = 0, $count = substr_count($result, '<br />') + 1; $i < $count; $i++) {
        $table .= ($i + $options['first_line']) . '<br />';
      }
      $result = $table . '</div></td><td>' . $result . '</td></tr></tbody></table>';
    }

    return $result;
  }

  function AddContainer($html, $options, $num_lines) {
    $custom_css_class = empty($options['class']) ? '' : ' ' . $options['class'];
    if ($options['inline']) {
      $theme = empty($options['inline_theme']) ? 'default' : $options['inline_theme'];
      $result  = '<code class="codecolorer ' . $options['lang'] . ' ' . $theme . $custom_css_class . '">';
      $result .= '<span class="' . $options['lang'] . '">' . $html . '</span>';
      $result .= '</code>';
    } else {
      $theme = empty($options['theme']) ? 'default' : $options['theme'];
      $style = 'style="';
      if ($options['nowrap']) $style .= 'overflow:auto;white-space:nowrap;';
      if (is_feed()) $style .= 'border: 1px solid #9F9F9F;';
      $style .= $this->GetDimensionRule('width', is_feed() ? $options['rss_width'] : $options['width']);
      if($num_lines > $options['lines'] && $options['lines'] > 0) {
        $style .= $this->GetDimensionRule('height', $options['height']);
      }
      $style .= '"';

      $css_class = 'codecolorer-container ' . $options['lang'] . ' ' . $theme . $custom_css_class;
      if ($options['noborder']) $css_class .= ' codecolorer-noborder';
      $result = '<div class="' . $css_class . '" ' . $style . '>' . $html . '</div>';
    }
    return $result;
  }

  /**
   * Generate a block ID that will be replaced at the end (after all that
   * crazy WP text work!) with the right code
   */
  function GetBlockID($content, $comment = false, $before = '<div>', $after = '</div>') {
    static $num = 0;

    $block = $comment ? 'COMMENT' : 'BLOCK';
    $before = $before . '::CODECOLORER_' . $block . '_';
    $after = '::' . $after;

    // Just do a check to make sure the user
    // hasn't (however unlikely) input block replacements
    // as legit text
    do {
      ++$num;
      $blockID = $before . $num . $after;
    } while (strpos($content, $blockID) !== false);

    return $blockID;
  }

  function GetDimensionRule($dimension, $value) {
    $rule = '';
    if (!empty($value)) $rule = "$dimension:$value" . (is_numeric($value) ? 'px;' : ';');
    return $rule;
  }

  function ShowWarning($type, $title, $message) {
    $disable = ' <a href="options-general.php?page=codecolorer.php&amp;disable=' . $type . '">' . __('Close', 'codecolorer') . '</a>';
    echo '<div id="codecolorer-' . $type . '" class="updated fade"><p><strong>' . $title . "</strong> " . $message . $disable . "</p></div>\n";
  }

  function ShowGeshiWarning() {
    if ($this->geshiExternal) {
      $this->ShowWarning('concurrent', __('CodeColorer has detected a problem.', 'codecolorer'), sprintf(__('We found another plugin based on GeSHi library in your system. CodeColorer will work, but our version of GeSHi contain some patches, so we can\'t guarantee an ideal code highlighting now. Please review your <a href="%1$s">plugins</a>, maybe you don\'t need them all.', 'codecolorer'), "plugins.php"));
    }
  }

  function ShowOptionsPage() {
    $page = $this->GetOptionsPage();
    $page->Show();
  }

  function GetOptionsPage() {
    if (!$this->optionsPage) {
      if (!class_exists('CodeColorerAdmin')) {
        $path = dirname(__FILE__);
        if (!file_exists("$path/codecolorer-admin.php")) return false;
        require_once("$path/codecolorer-admin.php");
      }
      $this->optionsPage = new CodeColorerAdmin($this);
    }
    return $this->optionsPage;
  }

  function GetCodeHighlighted($code) {
    $content = $this->BeforeHighlightCodeBlock($code);
    return $this->AfterHighlightCodeBlock($content);
  }

  function GetSampleCodeHighlighted() {
    return $this->GetCodeHighlighted($this->samplePhpCode);
  }

  function &GetInstance() {
    static $instance = null;

    if (null === $instance) {
      $path = dirname(__FILE__);
      if (!class_exists('CodeColorerOptions')) {
        if (!file_exists("$path/codecolorer-options.php")) return null;
        require_once("$path/codecolorer-options.php");
      }

      $instance = new CodeColorer();

      # Maybe GeSHi has been loaded by some another plugin?
     if (!class_exists('GeSHi')) {
        if (!file_exists("$path/lib/geshi.php")) return null;
        require_once("$path/lib/geshi.php");
      } else {
        $instance->geshiExternal = true;
      }
    }

    return $instance;
  }
}

Wave Goodbye To WebbAlert

It's unfortunate that my first post in 2009 has to be on this sad topic but I guess it has been on the cards for a few weeks now. The nice twice/thrice weekly tech update presented by Morgan Webb has come to an end. This means her smilling face will be missing from the main page of this site in future. The reason according to webbalert.com is that Morgan has more pressing regular commitments and does not have the time to dedicate to this project. It is certainly a shame and you will be missed. A few minutes of condensed tech news allowed me and others to keep up to speed on world tech happenings. There doesn't appear to be an alternative at the moment :(.

I hope everybody out there who has at some point watched WebbAlert joins me in wishing Morgan all the success in her future projects.

Goals for 2008

Happy New Year to all of you out there in internet land; I hope the festivities didn't take their toll.

Instead of resolutions for 2007 I set a few simple goals its time for a look at how I got on.

  1. Contribute more to Open Source Software - It might be writing documentation or code, perhaps just helping other users. It’s about time I gave back to the community.
  2. Upgrade my PC - A new TFT & GFX card are on the main list, possibly new case fans and another hard disk as the budget allows.
  3. Finish reading the book I started over a year ago - Once I get through it I can start on something else.

The first goal can only be considered a partial success, I didn't contribute to the Open Source community as much as I could have done. This is partly down the the amount of travelling I do but is not a good enough excuse not to do more in 2008. On the positive side my contributions included a few forums posts and my Laptop installation guide. It was only the other day I received a comment on my guide from a person who found it useful. It was nice to have the feeling of helping somebody and it will encourage me to post more (and better) guides in the future.

The second goal was to upgrade my PC with a new TFT and GFX, well I am glad to say I managed that one. I was thinking of a further upgrade in 2008 but the system is still performing well. I threw some new games on it and they run fantastically. The next planned big hardware upgrade will not be until the end of 2008 beginning of 2009.

The third goal was to finish reading a book that kept taunting me with its unfinished status. Well good news, I finished reading it and can now file it away on a remote shelf some place to collect dust.

So I mostly met my goals for 2007 but now its time to set the goals for 2008.

  1. Contribute more to Open Source Software - The same as last year but as I need to do more its the first on my list.
  2. Backup Data - An important thing to do so I need to do a full backup and keep it up to date.
  3. Reduce Carbon Footprint - I have already done a bit to reduce my power consumption, lets see if I can do more.
  4. Try and avoid parking fines and other motoring offences - 2007 was expensive.

Let's see how I get on. Number 4 could be an interesting one to review and will probably summarise how well my year has gone.