Faker - generating test data for database

Faker is a library that provide a set of generators for data types like fake name, address, number, IP, email, lorem ipsum text etc. - all generic data that is needed to create semi-real database content. Usually it has variations for different popular languages. All data is human-readable and taken from library, a lot of different combinations creates semi-unique data set.

It is needed mostly on testing and demonstration stages. Nobody likes to see a list of users like "test1", "Johnny35" etc. with posts "Test1", "Another test 35".

Implementation

PHP usage example

$faker = Faker\Factory::create();

// generate data by accessing properties
echo $faker->name;
  // 'Lucy Cechtelar';
echo $faker->address;
  // "426 Jordy Lodge
  // Cartwrightshire, SC 88120-6700"
echo $faker->text;
  // Sint velit eveniet. Rerum atque repellat voluptatem quia rerum. Numquam excepturi
  // beatae sint laudantium consequatur. Magni occaecati itaque sint et sit tempore. Nesciunt ...
for ($i=0; $i < 5; $i++) {
  echo $faker->name, "\n";
}
  // Adaline Reichel
  // Dr. Santa Prosacco DVM
  // Noemy Vandervort V
  // Lexi O'Conner
  // Gracie Weber

NB! Yii2 Framework has a Faker fixtures extensions


Getting started with Vagrant - automated dev servers deploy and provisioning

vagrant

What is it? Why do I need it?

Have you ever made big server side application with wide technologies and software stack in a team ? Or have you tried to connect quickly to an "old" backend project and bring some help? Or maybe one of your colleagues had ever said to you "hey, that script/soft is not working on my machine..." but you don't understand what is wrong and can't reproduce it. If yes - then you know this pain :

  • you have Windows PC, but want to develop webapp on Linux server
  • usually only some member of a team is a good sysadmin and he is responsible for setup and configuration, during development software stack is changing or require update etc. and every member of a team need to make it by himself on his localhosts
  • you are contributing to different projects and need quickly switch between then - but these projects require different versions of some software like PHP or MySQL and can't co-exist with each other
  • you often work on different laptops etc. and don't want to pollute all of them with server-stack software
  • you need to track versioning of you dev server environment and should be able to checkout not only app code to some moment of time, but server also
  • new member came to your team and you need to setup a full local dev environment in a minutes and for sure without "oh, really I forget this one ..."

We are lucky as now Vagrant exist to solve it. Literally Vagrant is a software that could setup you a local (or cloud) dev Virtual server using a configuration file. So it could be tracked as a project file inside Git repo. It can make server provisioning using Shell script or Ansible, Chef, Puppet.
Anyone, anywhere, anytime could run one terminal command to get their own local dev environment that is exact copy of your own - reliable, reproducible and for sure.

Very important to understand that Vagrant is for Dev machines only. It does not supposed to be used for Production env. deployment. It does not replace cloud orchestration software and great provisioning tools like Ansible/Chef/Puppet (but can utilize them as well, so you could reuse production provisioning scripts on dev machines).

Vagrant has quite good documentation and you should definitely go through it. Here I will juts cover briefly all major points.

Install Vagrant in Ubuntu

It is available for Linux, Windows and Mac. But all examples here assume Ubuntu Linux as Host and Virtual machine.

Quick start : Vagrantfile - The Journey Begins...

just 2 simple terminal commands ~~~ $ vagrant init precise32 http://files.vagrantup.com/precise32.box $ vagrant up ~~~

First command will create a Vagrantfile file in this dir and this config will be predefined ~~~ ... config.vm.box = "precise32" config.vm.box_url = "http://files.vagrantup.com/precise32.box" ... ~~~ now running vagrant up will actually start VirualBox instance according to Vagrantfile in current directory. In our case it will download Ubuntu 12.04 box from internet and run it/
Vagrantfile contain all settings for our server.
You can think running a VirtualBox is a big performance overhead for a dev server - but I think it is not. At least it is reliable price for a full isolation of environment. Plus don't forget that we are running server version of Linux without GUI - so 512 Mb Ram and some CPU time will be quite enough for a dev machine.


Read more ...

Yii2 dev digest #5 Jan'14

New Year holidays are coming to the end and finally I had some time to review all those issues and news on GitHub.
And you know - it seems that Yii core dev team was working all this time :)

[RU]Судя по географии посещений этих дайджестов - мне надо скорее доделывать поддержку мультиязычных постов и локализовать посты на русский язык ;)[/RU]

Read more ...

Build latest ffmpeg and all (generally) needed codecs from source

ffmpeg

In projects where you need to work with video data - converting video files or creating frame screenshot preview for a video, convert mp3 etc. it is very likely you will decide to use ffmpeg.
It is open source and free lib that is de-facto standard tool to operate with media files. But in Linux repositories it is often outdated version of ffmpeg and to get most recent features you'd better compile it from source. It is not a trivial things to get all needed dependencies, that's why I have gathered it all in one bash script.


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