Main > stdout.in Ievgen Kuzminov IT blog

Autoupdate VirtualBox Guest Additions in Vagrant

vagrant

While using Vagrant (I'll leave the question "Why should I use it?" for some future post) and taking ready made Boxes from http://vagrantbox.es - the fist issue I have faced was a warning about inconsistency of VirtualBox Guest Additions and actual VirtualBox version I am using.

Why is this happening ?

Because VirtualBox Guest Additions - it is drivers etc. installed inside the Box (that you are downloading somewhere) and for each new VirtualBox version new Guest Additions are required.
It can work with old version in general, but very essential parts could fail - like shared folders etc.

How to fix it manually

You could go to VirtualBox downloads server and find yourself needed ISO, download it inside Vagrant box via wget for example, mount it and install. But it is boring :)

Autoupdate Guest Additions via Vagrant plugin

vagrant-vbguest comes to help us with it.

Install

vagrant plugin install vagrant-vbguest

Configure

Add one line in your Vagrantfile

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
...
  config.vbguest.auto_update = true
...
end

and restart Vagrant box vagrant up

If you are lucky - everything else will happens automatically and you will be notified about version of Guest Additions that is being installed.

Also go through Configuration docs for vbguest to see other useful params.


How Redis expires keys

redis

I am often asked by my "junior" colleagues - what happens with Redis keys after expiry time, are these expired keys automatically being deleted or are they just "hang in RAM till The End Of Times" ? *Dramatic music! :)*
Fine, if you are to lazy to read docs...

Redis keys are expired in two ways: a passive way and an active way.

Active

When client access key and the key is found to be timed out - it is being deleted.

Passive

The most interesting - what happens with keys that are expired are are never accessed after expiry.
10 times per second Redis check 100 random keys with associated expiry time from the keyspace and remove expired keys.
If more than 25 keys were expired, start check again.

This is a probabilistic algorithm, where the percentage of keys that are likely to be expired is under 25%. This means that at any given moment the maximum amount of keys already expired that are using memory is at max equal to max amount of write operations per second divided by 4. That means that about 1/4 of RAM occupied by Redis could be used to store "expired" keys.


Yii2 dev digest #3 Dec'13

Official CHANGELOG appeared so my digests could be not so useful now
but in any case I will keep going :)

Discussions

that could be interesting to participate in

Take a look into and share your view on these questions Implement Transaction strategy for database cleanup (start transaction for connection and then rollback) Implement Reset strategy for database cleanup (tables truncate) Implement Drop/Create strategy for database cleanup (drop tables then create them <->)

What's new

Namespace and package names Extension MUST use the type yii2-extension in composer.json file. Extension MUST NOT use yii or yii2 in the composer package name or in the namespaces used in the package. Extension SHOULD use namespaces in this format vendor-name\package (all lowercase). Extension MAY use a yii2- prefix in the composer vendor name (URL). Extension MAY use a yii2- prefix in the repository name (URL). etc...

Acceptance tests integration and examples Functional tests integration and examples Unit tests integration and examples

@cebe : I think we can close this issue now. I am done with all the system I know and can support as I am going to work with them on a regular basis. Others should be provided as extensions or by other core developers. If someone wants to start working on an implementation of an AR feel free to contact me, I can help with that.


Read more ...

Easy-one-step install Redis 2.8 (latest) + PhpRedis in Ubuntu from source code

redis

Redis is a modern and very fast key-value storage. Someone calls it a "NoSQL" storage, someone - "just a memory cache". And all of them partly right - as Redis is a powerful tool, that could became very effective in different use cases.

Learn Redis

If you are not familiar with Redis at all. Start here - The Little Redis Book by Karl Seguin (Russian version)

Redis gets a lot of updates and new features, that's why in Linux repos you almost always see outdated versions. I recommend to install Redis and php_redis (PHP Redis driver extension) from source - it is very easy and fast.


Read more ...

Yii2 dev digest #2 Dec'13

It has gone some time after Yii2 Alpha announce, it increased activity in GitHub issues, a lot more people have tried to touch Yii2. And this is what I have noted.

$drivers = Driver::find()->with('cars')->asArray()->all();

will get populated nested arrays with releations

 $count = Yii::$app->db->createCommand('
      SELECT COUNT(*) FROM tbl_user WHERE status=:status
  ', [':status' => 1])->queryScalar();

  $dataProvider = new SqlDataProvider([
      'sql' => 'SELECT * FROM tbl_user WHERE status=:status',
      'params' => [':status' => 1],
      'totalCount' => $count,
      'sort' => [
          'attributes' => [
              'age',
              'name' => [
                  'asc' => ['first_name' => SORT_ASC, 'last_name' => SORT_ASC],
                  'desc' => ['first_name' => SORT_DESC, 'last_name' => SORT_DESC],
                  'default' => SORT_DESC,
                  'label' => 'Name',
              ],
          ],
      ],
      'pagination' => [
          'pageSize' => 20,
      ],
  ]);

Read more ...
Ievgen
Kuzminov "iJackUA"
Web Team Lead
at MobiDev (Kharkiv, Ukraine)
Code in Ruby and Elixir, but still love PHP. Explore ES6 and Vue.js. Explore databases, use Ubuntu and MacOS, think about IT people and management

Notes