Run phpunit code coverage only without running all the tests?

You can’t do it because PHPUnit needs to run the tests in order to know which lines of code were touched by the tests. But there’s a workaround: merging code coverage reports. Example: You run your full test suite, and the report says you have 72% of you code covered. Then you add a few more tests. You run only these new tests, ending up with, let’s say, 3% of code coverage. After that you Read more

Constructors in Golang

There are no default constructors in Go, but you can declare methods for any type. You could make it a habit to declare a method called «Init». Not sure if how this relates to best practices, but it helps keep names short without loosing clarity. package main import "fmt" type Employee struct { Name string Age int } func (e *Employee) Init(name string, age int) { e.Name = name e.Age = age } func info(name Read more

delete map[key] in go?

package main func main () { var sessions = map[string] chan int{}; delete(sessions, "moo"); } seems to work. This seems a poor use of resources though! Another way is to check for existence and use the value itself: package main func main () { var sessions = map[string] chan int{}; sessions["moo"] = make (chan int); _, ok := sessions["moo"]; if ok { delete(sessions, "moo"); } }

Технология CRUD-матрицы. Практический опыт

Технология CRUD-матрицы — это хороший инструмент для каждого члена Agile-команды на протяжении всего жизненного цикла продукта. CRUD-матрица позволяет наладить адекватный диалог с клиентом и выявить дублирование функционала, а также устранить противоречивость модели. Что касается оценки времени, то в этом моменте CRUD-матрица значительно уступает такому инструменту, как “planning poker”, который позволяет провести адекватную оценку с учетом объективных причин. Немного теории: описание методики IIBA в компетенцию бизнес-аналитика в области Agile (далее Agile-аналитик) относит следующие технологии:— Определение критериев Read more

Find the total size of certain files within a directory branch

23 The ultimate answer is: { find <DIR> -type f -name "*.<EXT>" -printf "%s+"; echo 0; } | bc and even faster version, not limited by RAM, but that requires GNU AWK with bignum support: find <DIR> -type f -name "*.<EXT>" -printf "%s\n" | gawk -M '{t+=$1}END{print t}' This version has the following features: all capabilities of find to specify the files you’re looking for supports millions of files other answers here are limited by Read more

Recursively counting files in a Linux directory

This should work: find DIR_NAME -type f | wc -l Explanation: -type f to include only files. | (and not ¦) redirects find command’s standard output to wc command’s standard input. wc (short for word count) counts newlines, words and bytes on its input (docs). -l to count just newlines. Notes: Replace DIR_NAME with . to execute the command in the current folder. You can also remove the -type f to include directories (and symlinks) Read more

Accessing private properties in PHP

Private properties can only be accessed by the class that defines the property… right? Actually, PHP has a few ways to circumvent this: reflection, closures and array casting. Reflection: slow, but clean PHP provides a reflection API to retrieve metadata of classes, methods, interfaces, and so on. Of special interest to us is the ReflectionProperty class. Among other things, it has the wonderful method setAccesible. In our code samples, we’re going to try to retrieve Read more

Awesome HTTP Load Balancing on Docker with Traefik

Why Traefik? Traefik is the up-and-coming ‘Edge Router / Proxy’ for all things cloud. Full disclosure, I like it. The cut back features compared to products like F5 which I have used throughout my career is refreshing — these products still do have their place, and they can do some very cool stuff. I’m a strong believer in avoiding technical debt when I’m building out my infrastructure and applications. Traefik is a production scale tool, Read more

Zero Downtime Deployments With Docker Swarm

Zero downtime deployments is an important topic when it is come to hosting a highly available software. This is especially the case with frequent software deployments ,following Agile methodologies, and trying to apply continuous deployment guidelines and techniques. The Problem The zero-downtime deployment topic is most relevant to the web applications or services that expose public interfaces for their clients. These interfaces must be highly available for clients all the time, even during software deployment Read more

Очистка места на диске после docker

Технология Docker позволяет упаковать приложение или сервис в контейнер, который легко может быть запущен в любом окружении. Однако при активной работе с Docker жесткий диск быстро засоряется неиспользуемыми образами, контейнерами и томами данных. Давайте разберемся с набором инструментов для чистки системы, предоставляемым Docker и рассмотрим несколько примеров! Как мы уже упоминали ранее, для очистки неиспользуемых данных можно воспользоваться командой: docker system prune Однако данная команда появилась в docker-engine начиная с версии 1.13.0, а в предыдущих Read more

Любишь мемасики?

Подпишись на мой телеграм-канал!