You are here

MyOSS Planet Feeds

Subscribe to MyOSS Planet Feeds feed
Updated: 15 min 47 sec ago

Harisfazillah Jamel: Malaysia Open Source Community Meetup Q2 2014 - Promotion One

13 hours 54 min ago
Malaysia Open Source Community Meetup Q2 2014

Event description :-

The Malaysia Open Source Community Meetup is an event for Open Source Communities in Malaysia to connect with each others. As a whole it also helps give software developers, students, and other interested people an opportunity to learn more about open source software and to discuss and share future planning of Open Source Project and Activities.
Date : 31 May 2014 (Saturday)
Time : 9am till 2pm
Venue :

Shah Alam Auditorium, Microsoft Office.
Level 26, Menara 3, KLCC
Kuala Lumpur, Malaysia

Registration :-

Latest and current update, schedule and speakers :-

Want to be a speaker? Open Source Software related topic? Please contact
linuxmalaysia @



Harisfazillah Jamel aka LinuxMalaysia

23 Apr 2014


Malaysia Open Source Community Meetup an event for OSS Communities in Malaysia to meetup #q2moscmy2014 #linuxmy
— linuxmalaysia (@linuxmalaysia) April 23, 2014
Categories: MyOSS Planet Feeds

Colin Charles: Ubuntu 14.04 – some MySQL ecosystem notes

Tue, 2014-04-22 23:56

Following my previous post on the launch, I just rolled Ubuntu 14.04 LTS on an Amazon EC2 t1.micro instance (not something you expect to run a database server on, for sure – 1 vCPU, 0.613GiB RAM). If you do an apt-cache search mysql you get 435 return result sets with the default configuration (trusty: main & universe).

If you do apt-get install mysql-server, you get MySQL 5.5. You enter the password of choice, and before you know it, MySQL is installed (a SELECT VERSION() will return 5.5.35-1ubuntu1).

Next you decide to install MariaDB. I run an apt-get install mariadb-server. It pulls in libjemalloc (for TokuDB) and I expect future releases to ship this engine by default. You enter the password, and you get a new message (as pictured).


I verify my test database that I created exists. It does. A SELECT VERSION() returns 5.5.36-MariaDB-1. The innodb_version returns 5.5.36-MariaDB-33.0.

I’m curious about MySQL 5.6 now. So I run apt-get install mysql-server-5.6. Not so straightforward. 

start: Job failed to start invoke-rc.d: initscript mysql, action "start" failed. dpkg: error processing package mysql-server-5.6 (--configure): subprocess installed post-installation script returned error exit status 1 Setting up mysql-common-5.6 (5.6.16-1~exp1) ... Processing triggers for libc-bin (2.19-0ubuntu6) ... Errors were encountered while processing: mysql-server-5.6 E: Sub-process /usr/bin/dpkg returned an error code (1)

Looks like MySQL 5.6 is more memory hungry… I edited /etc/mysql/my.cnf to ensure that innodb_buffer_pool_size = 64M (I increased this to 128M and it worked too) was set (there was nothing in the default config) and re-ran apt-get install mysql-server-5.6 and it started. My test database was still around ;-)

I wanted to make sure that MySQL 5.6 isn’t more memory hungry just on that instance so I created yet another clean t1.micro instance and did an apt-get install mysql-server-5.6. Same error. Reported lp#1311387.

Nothing to report in particular about Percona – 5.5.34 Percona XtraDB Cluster (GPL), Release 31.1 (Ubuntu), wsrep_25.9.rXXXX. One thing is for sure – if you’re playing around with the ecosystem, installs and upgrades aren’t exactly straightforward.

Related posts:

  1. MariaDB 10.0.5 storage engines – check the Linux packages
  2. Using MariaDB on CentOS 6
  3. Testing Fedora 19

Categories: MyOSS Planet Feeds

Lee Chin Sheng: Argus 3: Debug & Testing

Tue, 2014-04-22 23:39
If you are testing argus 3, the best way is always compile argus source with debug mode on -

Argus -
shell>tar xvzf argus-3.0.5.tar.gz
shell>cd argus-
shell>touch .devel .debug
shell>./configure --prefix=/usr/local/stow/argus-
shell>sudo make && make install

Argus Clients -
shell>tar xvzf argus-clients-
shell>cd argus-clients-
shell>touch .devel .debug
shell>./configure --prefix=/usr/local/stow/argusc-
shell>sudo make && make install

If argus or its client suite fails to run or behaves wrongly, you can just run them with -D 1-5 depending on the debug information you want. I'm just writing this as note to myself and hopefully it helps others who are using argus as well.

Cheers ;]
Categories: MyOSS Planet Feeds

Colin Charles: MySQL Community Awards: Community Contributor of the Year 2014

Tue, 2014-04-22 21:32

As one decompresses from the active month that April brings to the MySQL ecosystem, its worth noting that I received a MySQL Community Award – Community Contributor of the Year 2014 award at the Percona Live MySQL Conference & Expo 2014 in Santa Clara. I was extremely happy and thankful to receive such an award and I still am. Thank you MySQL Community.

My reason for winning, now immortalised:

Colin’s list of service to the MySQL Community goes back almost 10 years. He was a community engineer starting in 2005, chaired some of the O’Reilly MySQL conferences, ran the MySQL projects for Google Summer of Code. As a partner and Chief Evangelist for Monty program, he continues to promote and grow the MySQL ecosystem. Though it’s his job, he goes above and beyond, driven by his passion for open source and MySQL.

I was amongst very good company (congratulations to all the winners). Thank you to whom nominated me, and to the committee for vetting it. Frederic wrote a nice post with a little selfie. Tomas expresses heartfelt thanks from Oracle.

Anyway, not to rest on one’s laurels – while its great to be given an award after years of being involved in the community, I will work harder in the coming months to make things better in any way I can. Thank you again, MySQL Community.

(more pics of the award: #1, #2)

Related posts:

  1. O’Reilly MySQL Conference Awards 2010
  2. Percona Live MySQL Conference & Expo Santa Clara 2014
  3. New Year’s note, 2014

Categories: MyOSS Planet Feeds

Colin Charles: Apps should be conduits for web services

Tue, 2014-04-22 21:01

Beautiful designed apps should be conduits for web services. Or provide some form of “desktop” capability. Sync is important.

Brent Simmons recently wrote of Marco Arment

You know him from Tumblr, Instapaper, The Magazine, and (coming soon) Overcast.

You may think of Marco as an iOS developer — but every single one of those apps is a web service.

This thought process works very well with a presentation John Gruber gave at Web 2.0 Expo NY – watch the 10 minute video on Apple and the Open Web. He describes Apple as a “ht” company: they’ve embraced HTML and HTTP.

I look at my iPhone and think to myself what apps I use (i.e. have an icon on my screen) that are web apps:

  1. Google Calendar (direct web app, opens a browser window)
  2. RunKeeper
  3. Fitbit
  4. Withings
  5. Cardiio
  6. MyFitnessPal
  7. Chrome
  8. Mail
  9. TripIt
  10. Evernote
  11. Instapaper
  12. Kindle
  13. NewsBlur
  14. Hello (by Evernote)
  15. Skype
  16. Instagram
  17. Vine
  18. Rdio
  19. Spotify
  20. Google
  21. Reminders (stock Apple app, wonderful sync at work)
  22. Safari
  23. Facebook
  24. Foursquare
  25. Twitter
  26. KakaoTalk
  27. Line
  28. Messenger
  29. Hangouts
  30. Telegram
  31. Tweetbot
  32. Google+
  33. Dropbox
  34. 1Password
  35. Expensify
  36. MyTeksi
  37. Uber
  38. YouTube
  39. Paper
  40. Bloomberg

What isn’t a web app? Photos (though there is an iCloud Sync that I don’t use – I prefer it going to Dropbox), Camera, most of Apple’s standard apps (of course, FaceTime, Notes, Calendar – they all sync), DocScanner (syncs to Dropbox, but has no web app behind it), Snapseed, Camera+, 360 (has a web component though I never use it). Music/Podcasts theoretically sync with the web, but again, not my use case. I don’t consider Google Authenticator a web app either though I use it in conjunction with the web. Messages has iMessage but there isn’t a web interface (yet?).

We can argue that the messaging apps aren’t really web services. KakaoTalk/Line have desktop clients. Whatsapp is notoriously mobile-only. Viber/WeChat seem to be mobile only for me. Telegram leads the way by having a nice Chrome browser plugin. Skype is a desktop app.

That makes the majority of my apps that I use, really, web apps. My phone is a conduit to the Internet. This is why I consume data and WiFi.

My iPad is not much different – I use it a lot more for reading, and that includes the FT (fully HTML5 web + mobile app), WSJ, NYTimes, New Yorker, The Economist. OK, there’s GoodReader, iBooks, Zinio for offline reading too, a lot more magazines, and some office software – the iWork suite (which syncs to iCloud). A cool app like Penultimate (now free after Evernote purchased them – again syncs online).

This is the success metric for an app. No point building an application to have a F1 racing timetable (I get that from or a simple Google search). No point building an application that collects Malay proverbs (I can search for that if I was interested; or if it was the English context, I’d just look up wikiquote).

Games seem to be an exception to this, but as I have never played games and don’t intend to start (I don’t grok the mind of a gamer, sorry), I’ll pass on overall commentary. 

Related posts:

  1. Chrome Web Store – AppStore for Web?
  2. A battery management app I’d like to see
  3. Apps are the new channels

Categories: MyOSS Planet Feeds

Harisfazillah Jamel: Malaysia Open Source Community Meetup Q2 2014

Mon, 2014-04-21 00:32
Malaysia Open Source Community Meetup Q2 2014

Keterangan :-
Date : 31 May 2014 (Saturday)
Time : 9am till 2pm
Venue : TBA

Maklumat lanjut masih dalam draf dan dibincangkan dalam Facebook

Sesiapa hendak jadi speakers? PM or Email me

Maklumat acara semasa


Untuk archive

Event description
The Malaysia Open Source Community Meetup is a place for Open Source Communities in Malaysia to connect with each others. As a whole it also helps give software developers, students, and other interested people an opportunity to learn more about open source software and to discuss and share future planning of Open Source Project and Activities.

Harisfazillah Jamel aka LinuxMalaysia

Categories: MyOSS Planet Feeds

Lee Chin Sheng: Ubuntu Linux: Argus 3 Installation

Sun, 2014-04-20 13:42
If you want to test the latest version of argus with all the features enabled on Ubuntu Linux, here's the fastest way, just follow the steps below -

I use stow to manage argus source -

shell>sudo apt-get install stow
shell>mkdir /usr/local/stow

Install mysql server -

shell>sudo apt-get install mysql-server

Install software dependencies for argus clients -

shell>sudo apt-get install flex bison libmysqlclient-dev libncurses5-dev libreadline-dev libgeoip-dev libpcre3-dev

Now download argus and its client suite -


Install argus -

shell>tar xvzf argus-
shell>cd argus-
shell>./configure --prefix=/usr/local/stow/argus-
shell>sudo make && make install

Install argus client -

shell>tar xvzf argus-clients-
shell>cd argus-clients-
shell>./configure --with-libpcre --prefix=/usr/local/stow/argusc-
shell>sudo make && make install

Now you can use stow to link them to default PATH(/usr/local/sbin and /usr/local/bin) so that you don't need to define full path when running argus -

shell>cd /usr/local/stow
shell>sudo stow argus-
shell>sudo stow argusc-

Done and you can start testing argus for fun!
Categories: MyOSS Planet Feeds

Colin Charles: Congratulations Ubuntu, for the wide choice!

Fri, 2014-04-18 16:54

Inspired by Yngve Svendsen’s post, I too think it makes absolute sense to congratulate Ubuntu on the 14.04 LTS release (some server notes - MySQL has a section dedicated to it). Ubuntu users have a lot of server choice today (that’s from all major MySQL ecosystem vendors):

  • MySQL 5.5.35 ships in main. It is the default MySQL. Oracle has committed to providing updates to 5.5 throughout the LTS release cycle of Ubuntu (which is longer than the planned EOL for 5.5). This is why the grant of a Micro Release Exception (MRE).
  • MySQL 5.6.16 ships in universe
  • MariaDB 5.5.36 ships in universe.
  • Percona XtraDB Cluster 5.5.34 ships in universe

Ubuntu’s pitch is being the cloud platform of choice, with OpenStack support. This explains why Percona XtraDB Cluster (the only shipping Galera Cluster variant — no upstream Codership release, and no MariaDB Galera Cluster) is critical infrastructure as its used widely in OpenStack deployments. 451Research estimates that the OpenStack distributions market is worth $82 million in 2014 and $119 million in 2015.

Press release had a choice quote from Percona CEO, Peter Zaitsev:

“We are very pleased that Percona XtraDB Cluster is included in Ubuntu 14.04 LTS. Many organisations that use MySQL need high availability solutions to ensure that their applications meet the expectations of their users. Percona XtraDB Cluster is an easy to use, open source solution for MySQL clustering which addresses these high availability needs. We continue to see growth in Ubuntu usage by our customers and our open source software users so we are confident that the inclusion of Percona XtraDB Cluster in Ubuntu 14.04 will help spread the adoption of cost-effective, high availability MySQL.” Peter Zaitsev, Co-Founder and CEO at Percona


Related posts:

  1. Ubuntu 10.04 LTS released, MariaDB 5.1.44/5.2-BETA VM’s available
  2. OpenSUSE users have a choice of database now!
  3. Communications, Ubuntu 6.06 LTS & MySQL downloads

Categories: MyOSS Planet Feeds

Colin Charles: SSL and MariaDB/MySQL

Thu, 2014-04-17 18:25

With the recent Heartbleed bug, people are clearly more interested in their MariaDB/MySQL running with SSL and if they have problems. First up, you should read the advisory notes: MariaDB, Percona Server (blog), and MySQL (blog).

Next, when you install MariaDB (or a variant) you are usually dynamically linked to the OpenSSL library that the system provides. Typically on startup of MariaDB 10.0.10 on CentOS 6.5 (packages from the MariaDB repository), you can check what your status of SSL is.

MariaDB [(none)]> show variables like 'have_ssl'; +---------------+----------+ | Variable_name | Value | +---------------+----------+ | have_ssl | DISABLED | +---------------+----------+ 1 row in set (0.00 sec)

This means that SSL options are compiled, but mysqld didn’t start with it. You can verify SSL is linked dynamically:

ldd `which mysqld` | grep ssl => /usr/lib64/ (0x00007ff82d1b1000)

If you are running with SSL enabled (some documentation at MySQL) you will have different options naturally. You can do this via: /etc/init.d/mysql start --ssl. Output now changes:

MariaDB [(none)]> show variables like 'have_ssl'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | have_ssl | YES | +---------------+-------+ 1 row in set (0.00 sec)

The value NO will be displayed if the server is not compiled with SSL support. See SSL Server System Variables for more.

Related posts:

  1. MySQL 5.6 system variables in the MariaDB 10 server
  2. Using MariaDB on CentOS 6
  3. MariaDB 10.0.5 storage engines – check the Linux packages

Categories: MyOSS Planet Feeds

Bakhtiar: Kedai Android App

Mon, 2014-04-14 13:07
Here's a list of some of Kedai Android App : - terkini - himpunan hadis and a lot more at the google play
Categories: MyOSS Planet Feeds

Muhammad Shahriman (Yondie): Immutable Data and Memory Sensitivity..

Sun, 2014-04-13 02:18
Considered this python code snippets

import hashlib
while True:
   print("Enter your password")
   s = raw_input('--> ')
   print("Now the md5sum")
   s = hashlib.md5(s).hexdigest()

By any means it's relatively a simple code to understand, we use s as a placeholder for our incoming data string, compute it's md5sum and replace the s value with a hexdigest.. In short s now contain the md5sum in hex right? So any plaintext that we've entered should vanished and and flush out by the garbage collector in python VM right?

Let's give it a test.

So most people would think any previous plaintext value would be washed out from the memory. The String DogFood  won`t exist right? Let's attach this current script on a debugger ('Im using edb debugger , the best thing besides windbg sorry stallman gdb just sux!!!!');

I like using edb debugger, it helps for example binary search string. Since we have replace the s value from DogFood to a hex string. We shouldn`t see any DogFood string in the memory right? Unfortunely that is entirely not true :(

DogFood in Hex High-level languages often have data types that are immutable. The program can only write to an immutable object once, at creation time. In other words s is just a label and the string maybe be stored in the same address or  anywhere in the memory. (Noted to self, heap/stack/bss/dss/ is actually some sort of label the computer generated to ou  give it some of approximate understanding on a specific region in the memory) 

Let's search for the md5sum string. 36f65df05afee9fb079943b7ba5d9617

The string was stored in a different address!!

So in a High Level Language,  there is no gurantee your initial plaintext data in an address would be overwrite with a encrypted blob/binary . The only way to ensure overwrite is 100% is to use either mutable data structure that are capable of replacing dynamics element.

So why did u see a chunk of the unencrypted/crypted data in the heartbleed heak leak? Not a surprise anymore right?

Categories: MyOSS Planet Feeds

Colin Charles: Ai Weiwei – Evidence

Fri, 2014-04-11 21:52

I was fortunate enough to have some free time earlier today evening, and headed over to the Martin-Gropius-Bau to catch the Ai Weiwei (@aiww)exhibition titled Evidence. This is the first time I’ve seen Ai Weiwei’s work as I missed it at the Tate Modern in London a while back.

He is a modern artists. Playing around with a lot of different materials to come up with his artwork. And he makes use of the Web. I guess his claim to fame is that he’s all for freedom of speech & expression (something that’s hard to do in China – a dissident he is, if you must), and the fact that he’s a documenter of modern happenings (everyone is interested at the amazing pace of growth in China – he shows that by video recordings of highways, or driving around and recording his journey as an example).

For me, I was really moved by Zodiac Heads (Circle of Animals). I would so grab the rat, tiger and dog as examples! 

China in ten years (I first went to Beijing in 2004 – it has changed a lot in a decade) has become a lot more materialistic. The car of choice used to be the Audi; it still is, but you find a lot of other luxury vehicles on the roads nowadays in Beijing. So the Han Dynasty vases painted with metallic paint from BMW & Mercedes was great for cultural insight. Culturally, the want of antiques is also high and the Table & Chest with stripped chairs was also interesting – remove 1mm sheen from Ming Dynasty furniture and they look like new. What is the purpose of antiques again?

I enjoyed his Study of Perspectives (a selection at moma) as well. He goes to famous landmarks and takes a photo with his left middle finger.

He portrays the disputed islands (between China & Japan). I loved the stools because they each tell a story (6,000 of them). I enjoyed his re-enactment of how he was held captive by the Chinese authorities for some time. It’s shocking to see how you would sleep with a light on, always be watched by security guards and have everything covered up – where you have to do your own laundry and the only thing you get are 6 hangers. Its sad to see that his studio in Shanghai was demolished at a moment’s notice – but he made artwork out of it. He showed the evidence that was confiscated (lots of laptops/video recorders/PCs).

A protest pre-demolition involved river crabs (he xie). Guess that’s the beauty of the Chinese language :)

If you get the chance to check Ai Weiwei’s work out, its well worth it and will take you a good 2 hours (read a review in The Economist). You can’t take photos inside, but you will leave with a lot of memories. If you can’t see this one in Berlin, check out a video: Ai Weiwei – Dumbass. At five minutes long, it makes my video of the week.

Related posts:

  1. Malaysia’s Evidence Act – #STOP114A
  2. Software Freedom Day 2007, Beijing Report
  3. Software Freedom Day 2007 – Beijing

Categories: MyOSS Planet Feeds

Colin Charles: On device ecosystems

Sun, 2014-03-02 07:07

I was just listening This week in google #236, and they were talking about device ecosystems. The topic of smartwatches came up obviously. The first Samsung Galaxy Gear was apparently not a good seller because it had a limited app ecosystem and it was tied to just a few devices (I only know one person who has said watch, and wears it regularly).

If Apple builds an iWatch, they will tie it into the iOS ecosystem. This is why Leo Laporte the host likes the Pebble – it works with all his devices.

How many people are Leo with an iPhone and an Android phone? And whatever else is compatible with the Pebble? End users (consumers) usually have one phone. There’s nothing wrong with the iWatch to be tied into the iOS ecosystem — its an awesome ecosystem. Soon you may get cars with iOS on it (just like you can get cars with Linux on it).

The iWatch if Apple makes one will probably be compatible all the way back to the iPhone 4S. It should cover most iOS/iPhone users. And just like the apps you buy in the app store when the iPad came along (first you had iPhone only apps, with double-size; then you had separate iPad apps that would cost more; nowadays many apps are “universal” to work on both and cost the same), I expect something similar will happen with the iWatch. 

That said, I like my analogue watches. I had no interest in the Pebble or the Samsung Galaxy Gear. I’d be interested to see what they do with version 2, which has Tizen (even less apps maybe?). When Apple releases an iWatch, you can be sure I’d probably buy it — I have seen things from all sides, and I like their ecosystem.

Related posts:

  1. Messenger apps revisited
  2. Apple opens up Podcasts, iTunes U in Malaysia
  3. A new phone, new for 9 months?

Categories: MyOSS Planet Feeds

Lee Chin Sheng: Interesting Rootkit: Uroburos

Sun, 2014-03-02 04:33
My friend ebf0 has shared with me this interesting analysis report from GData Security Lab, you can find the report here -

To understand why the name "Uroburos", we should refer to

Doesn't matter it comes from which party, we all know Intel gathering is always there, by the time we know it it seems late by miles. Internet security community needs to work harder together to uncover them as soon as possible.

Cheers (;])
Categories: MyOSS Planet Feeds

Muhammad Shahriman (Yondie): OSINT Tricks: Combining Shodan + The Harvester

Fri, 2014-02-28 05:31
The Harvester is  a good tools for data mining enumeration during RECON/Information Gathering period. On version 2.2a  the harvester support integration with SHODAN.

In order to use SHODAN services in the Harvester you need to supply the API key . So if you try to use it without supplying the SHODAN API Key.

There is not a proper documentation on how to supply the the Shodan API key but after reading the source code , you need to supply the key at discovery/

After supplying , the results for information gathering/stalking becoming much more useful.

Categories: MyOSS Planet Feeds

Nicholas A. Suppiah (tboxmy): Managing PostgreSQL with pgsql and pgAdmin3

Tue, 2014-02-25 10:03
The command line interface (CLI) tool that comes with Postgres server is known as pgsql. Alternatively, pgAdmin3 and phpPgAdmin can be installed.

The pgsql

Among some of the commands for pgsql can be shown as below;


Categories: MyOSS Planet Feeds

Nicholas A. Suppiah (tboxmy): Installing PostgreSQL on Centos 6

Tue, 2014-02-25 09:46
PostgreSQL being an OSS licensed database is very different compared to MySQL. PostgreSQL (or Postges) maintains a repository for Linux systems like Centos to install the database. This repository is known as pgdg and is maintained at or

Installation of the Postgres comes with psql, this is a CLI to manage Postgres.

Installation of PostgreSQL 9.3 on Centos 6.4 is as follows;

Step 1:
Open a CLI as root user and retrieve the pgdg repo RPM, then install it. This will allow the Centos to find for software from the pgdg.


rpm -ivh pgdg-centos93-9.3-1.noarch.rpm

Step 2:
Install the client and server.

yum install postgresql93 postgresql93-server

Step 3:
Initialise database and tables, and start. This creates the default user postgres.

service postgresql-9.3 initdb
service postgresql-9.3 start
You can now login with the default user to the Postgres terminal as follows;
su postgressudo postgres
Step 4:As the postgres user, create an administrative user, then log out from the psql (use \q), then the shell (Control-d).
CREATE role dbmsuser LOGIN PASSWORD 'password' SUPERUSER;
Step 5:Edit Postgres configuration file;
vi /var/lib/pgsql/9.3/data/postgresql.conf
Uncomment the line and save.#listen_addresses = ‘localhost’ and change it to listen_addresses = ‘*’
vi /var/lib/pgsql/9.3/data/pg_hba.conf
Add a line at bottom of the file to allow non-local connections,    all             dbmsuser            md5

Post installationchkconfig postgresql-9.3 on
Ref: How to Install PostgreSQL 9.2 on CentOS 6.3/RedHat EL6/Fedora
Categories: MyOSS Planet Feeds

Wei Chong: Value Semantics, Concepts Based Polymorphism and Composite Pattern

Mon, 2014-02-24 13:28
Not long ago, I watched Sean Parent's Value Semantics and Concepts Based Polymorphism.
In the presentation, Sean showed a sample code that manipulates "document type".
Yesterday, while flipping over an old book on my book shelf, Pattern Hatching: Design Patterns Applied, by John Vlissides, I came across his example of using the Composite Pattern to illustrate a simplified file system structure with class Node, class File and class Directory.  There it uses the classical way of inheritance.I couldn't help but notice the similarity between the simplified file system recursive structure of the Composite Pattern with Sean's example of the document inside document.
So, I just play around with concepts based polymorphism a bit.Note that the code may not be optimize or anything, as it is a quick copy-and-modify.
Here is node.h:
#ifndef NODE_H #define NODE_H #include #include #include #include class node_t { struct concept_t { virtual ~concept_t() = default; virtual size_t total_size() const = 0; virtual void print(std::ostream& out) = 0; virtual concept_t* copy() = 0; }; struct file_model_t : concept_t { file_model_t(size_t x) : total_size_(x) {} size_t total_size() const { return total_size_; } void print(std::ostream& out) { out << total_size_; } concept_t* copy() { return new file_model_t(*this); } size_t total_size_; }; struct dir_model_t : concept_t { dir_model_t(std::initializer_list l) : children_(l) {} size_t total_size() const { size_t total_size = 0; for (const auto& c : children_) total_size += c.total_size(); return total_size; } virtual void print(std::ostream& out) { out << "("; auto i = children_.begin(); out << *i; ++i; while (i != children_.end()) { out << ","; out << *i; ++i; } out << ")"; } concept_t* copy() { return new dir_model_t(*this); } std::vector children_; }; std::unique_ptr p_; public: node_t(size_t value) : p_(new file_model_t(value)) { /*std::cout << "ctor file" << std::endl;*/ } node_t(std::initializer_list l) : p_(new dir_model_t(l)) { /*std::cout << "ctor dir" << std::endl;*/ } node_t(const node_t& x) : p_(x.p_->copy()) { /*std::cout << "copy" << std::endl;*/ } node_t& operator=(node_t x) { //std::cout << "assign" << std::endl; p_ = std::move(x.p_); return *this; } size_t total_size() const { return p_->total_size(); } friend std::ostream& operator<<(std::ostream& out, const node_t& n) { n.p_->print(out); return out; } }; using file_t = node_t; using directory_t = node_t; #endif //NODE_H And here is the client code:
#include #include #include "node.h" int main() { file_t f1 ( 10 ); std::cout << "f1: " << f1.total_size() << std::endl; file_t f2 ( 20 ); std::cout << "f2: " << f2.total_size() << std::endl; directory_t d1 { f1, f2 }; std::cout << "d1: " << d1.total_size() << std::endl; file_t f3 ( 30 ); std::cout << "f3: " << f3.total_size() << std::endl; directory_t d2 { f3, d1 }; std::cout << "d2: " << d2.total_size() << std::endl; std::cout << d2 << std::endl; } And this is the output:
f1: 10 f2: 20 d1: 30 f3: 30 d2: 60 (30,(10,20))
Note how the directory nests the subdirectory.
More importantly, the value semantics of the client code, polymorphism without reference or pointer, cool!

Admittedly, I'm quite new to this concepts-based polymorphism technique, and may also not be paying too much attention to other aspect of the C++ code in general. If you find any mistake, feedback and advice are appreciated.

Categories: MyOSS Planet Feeds

Lee Chin Sheng: The Practice Of Network Security Monitoring

Mon, 2014-02-24 09:10
Year 2014 will most probably be a refreshing year to myself, everything is like new all over again and what should I do next is important.

NSM has been big part of my career and I'm back to the root, and I would like to discuss/share anything regarding this huge topic. The first thing I would most probably do is to grab the book that is written by my friend - Richard, The Practice Of NSM. Thank you for your effort to write this book, it is really tough to stay focused and finished a book especially for a busy person like you.

Second thing to do would be reviewing the new version of existing tools, and also new tools that kick in without me noticing - Netsniff-ng, Snort, Suricata, Bro-ids, Argus, NetworkMiner, SIFT and many more, you name it.

Third thing to do is sharing, to share what I have found and learned, in the world of IT security.
Categories: MyOSS Planet Feeds

Colin Charles: Time spent on PR

Sat, 2014-02-22 16:00

How WhatsApp’s Arora Sealed Facebook Deal – Digits – WSJ: Time spent on PR is time not spent ‘making your users happy,’ Arora said. ‘The users you get from press and hype are not the best users.’

Related posts:

  1. Too many INBOXes
  2. Roaming data
  3. The quotable Satya Nadella

Categories: MyOSS Planet Feeds