teleren/devto huggingface dataset:
Speed up your PostgreSQL unit tests with one weird trick!
Tags: postgres, unittest, database, performance
Published: 2018-10-23 21:24:23

---
title: Speed up your PostgreSQL unit tests with one weird trick!
published: true
description: I used to work at a company where our PostgreSQL unit tests took over an hour 😱. Here's how we cut it by more than half.
tags: postgres, unittest, database, performance
---

\<Note: I know the title is hokey, but I couldn't think of what else to call it! Would love feedback on how to title articles effectively, since that's something I struggle with\>

About few years ago I worked on a product where our unit tests moved about as quickly as tar. My coworker was lamenting to her DBA friend about the tests, and after poking around together, they unearthed a PostgreSQL setting that halved our Jenkins build time when disabled. This was the single biggest performance boost to our unit tests after several months of attempted  optimizations.

## `fsync`

`fsync` is a PostgreSQL configuration setting that helps with reliability and disaster recovery. It’s a boolean flag that changes PostgreSQL's write settings. When enabled, it tries to ensure that updates are physically written to disk. This is a great safety measure if you want to protect your data against hardware crashes or operating system failures. However, it results in a significant performance hit.

## Why enable `fsync`?

`fsync` can be invaluable for recovery if you find yourself with a corrupted database. It’s enabled by default, and for good reason. If your production performance needs improvement, there are safer optimizations to make. It could save you from unrecoverable corrupt data should the worst happen. Unless you have a surefire way of recovering data from an external source, turning off `fsync` in production is dangerous.

## Why disable `fsync`?

There’s no need for `fsync` in most testing environments. When running unit tests, you probably expect to set up and tear down your database at least once. Writing to disk is an expensive operation for something you plan to throw away anyhow.


## How to change your PostgreSQL config

If you’ve never changed your PostgreSQL settings before, start by figuring out where the config file lives. If you don’t know you can find it by running

`SHOW config_file;`

in your `psql` interactive terminal. This will print out the path to the PostgreSQL config file.

Next, find the `fsync` option. It’s generally located near other Write Ahead Log options. Make sure the line is not commented out, as it defaults to `on`. Switch the boolean flag for `fsync` to `off`. Note that changes to the config require PostgreSQL to restart before taking effect.

> Note: PosgreSQL is very flexible when assigning boolean values for server configuration settings. `TRUE` values are `on`, `true`, `yes`, and `1`. `FALSE` values are `off`, `false`, `no`, and `0`. All of these values are case-insensitive, and any of these is fine. Just make sure to pick a single style and stay consistent.

Lastly, sit back and enjoy all the time you’ve won back now that updates to your test database aren’t writing to disk by default.
A bit more about Lean
Tags: lean, safe, agile, development
Published: 2018-10-23 21:06:59

---
title: A bit more about Lean
published: true
description: 
tags: Lean, SAFe, agile, development
---

This follows on from my [earlier notes about Lean](https://dev.to/mark_nicol/a-quick-sketch-of-lean-4g2j). Reading further I realize that what I described there is only one aspect of what Lean is about. The Lean philosophy also offers a set of other principles, designed to support finding flow. 

The SAFe literature uses a classical temple as a metaphor for how the Lean principles fit together. 

![Diagram of a Temple. The roof says value, the base says Leadership and there are four pillars. Respect for People and Culture, Flow, Innovation and Relentless Improvement](https://thepracticaldev.s3.amazonaws.com/i/e2y10yhx5g4gfcvqrbu0.png)
The roof of the temple represents the goal of delivering value to the customer. Everything else supports this goal.

The base of the temple is __'Leadership'__ - because it is the foundation. Leadership is not a management or a specific role. Instead,  'lead' activities are something that everyone does.

Everyone plans the work, and reports progress. The team understands the organization's strategic aims. The team has the knowledge to decide what is most valuable or important thing to work on. They can decide how long it will take to deliver.  Any 'lead role'  job is not to lead, but to act as a coach or servant to the team. They are responsible for smoothing the way, sorting problems so the rest of the team can deliver. 

This is why the first pillar __'Respect For People and Culture'__ is there.  It is people that do all the work.  This covers building mutual trust with the people you work with and helping them to reach their goals.  

Managers allow teams to evolve the practices that work best for them. A manager's main role is to provide appropriate guidance and support. 

* __Flow__ is all the stuff in my last notes. Focusing on understanding the value stream and aligning people to deliver it. Reducing batch sizes to match customer demand. Monitoring where the queues or bottlenecks are and always adjusting and reevaluating.

* __Innovation__ is about allowing people the time and space to be creative. Focusing on flow can mean people are busy dealing with the urgent so good new ideas are never developed. Teams need the space to try out ideas, and the support from the organisation to test and evaluate the most promising ideas that emerge. Successful organizations focus real effort on growing new ideas, and the most successful are willing to change their whole direction to take advantage of new opportunities.

* __Relentless Improvement__ is back to the idea that improvement is an ongoing activity.  The focus on the whole process isn't a one-off exercise.  Successful organizations reflect at key milestones. They study and learn and consider. They also act fast on what they find to determine and remove the root causes of any issues.
Using Storybook with VueJS
Tags: vue, javascript, storybookjs, frontend
Published: 2018-10-23 19:19:22

---
title: Using Storybook with VueJS
published: true
description: Learn how to build a component library with Vue and Storybook to create modular and reusable components.
tags: #vuejs #javascript #storybookjs #frontend
canonical_url: https://auth0.com/blog/using-storybook-with-vuejs/
---

Storybook lets us interactively develop and test user interface components without having to run an application. Because Storybook acts as a component library with its own Webpack configuration, we can develop in isolation without worrying about project dependencies and requirements.

In this post, you are going to learn how to integrate Storybook with an existing Vue.js project by using the popular Kanban Board Progressive Web App (PWA), available on GitHub, created by my teammate Steve Hobbs. This process can be followed for a new Vue project as well.

[Read on 📕✨](https://auth0.com/blog/using-storybook-with-vuejs/?utm_source=dev&utm_medium=sc&utm_campaign=storybook_vuejs)

![Using Storybook with VueJS](https://thepracticaldev.s3.amazonaws.com/i/q8yaazl9oiv0a1hm53m2.png)
Review my VueJS project
Tags: vue, feedback, discuss
Published: 2018-10-23 17:55:16

---
title: Review my VueJS project
published: true
description: feedback on my VueJS project
tags: vuejs, feedback, discuss
---
I successfully completed a simple project in VueJS I was given but I'm not entirely sure that it's filling all the needed requirements. If any of you have expertise any VueJS please check it out. I would love to hear your thoughts about it! 


$> git clone [https://github.com/xde013/vue-challenge.git](https://github.com/xde013/vue-challenge)

PS: Don't forget to check the project's README first.
Google CodeIn 2018 is here!
Tags: googlecodein
Published: 2018-10-23 21:49:53

---
title: Google CodeIn 2018 is here!
published: true
tags: Google CodeIn
canonical_url: https://miguelpiedrafita.com/codein-2018/
cover_image: https://images.unsplash.com/photo-1529612700005-e35377bf1415?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjExNzczfQ&s=80980493fd41279150cb9f1c9fa71dcb
---
_Originally published on [my blog](https://miguelpiedrafita.com/codein-2018/)_

Are you a student between 13 and 17 years old, who likes coding? Well, today's your lucky day, because the Google CodeIn inscription is open!

> According to its website, Google CodeIn is a contest to introduce pre-university students (ages 13-17) to open source software development. Since 2010, over 8100 students from 107 countries have completed work in the contest.

What does this mean for you? Well, you have an incredible opportunity to get started contributing to open-source. You'll also get an exclusive shirt if you complete three or more tasks, and you may even get a Google hoodie or a trip to Google HQ!

Eager to start? [Register today](http://g.co/gci)!

_Liked this article? Consider [supporting me on Patreon](https://miguelpiedrafita.com/patreon). [Learn more](https://miguelpiedrafita.com/patreon)._
Carp::Always sometimes
Tags: perl, cpan, troubleshooting
Published: 2018-10-23 16:53:24

---
title: Carp::Always sometimes
published: true
description: use Carp::Always to get full stack traces
tags: perl,cpan,troubleshooting
---

### Troubleshooting

Your program just died. Great, now what?

If the exception string ended with a `\n`, it didn't give you a line
number. But even if it did, a line number is often not enough to debug the
problem. That's where the problem occurred, but how did we get there?

[Carp::Always](https://metacpan.org/pod/Carp::Always) to the rescue.

```perl
use Carp::Always;
```

Put this anywhere and all exceptions (and warnings) will have a full
stack trace, including subroutine arguments.



### But wait...

You probably don't want to turn this on permanently for the entire program. Using `Carp::Always` is a global, process-wide change, and the stack trace will be added to *all* exceptions, even inside an `eval BLOCK`. That's probably not what you wanted.

So since it's a temporary debugging tool, this is a pretty bad thing
to forget in the code base since it changes **global behaviour**.

Do you know that nothing will go weird in the entire rest of your app
now that exceptions will look different? No you do not. So put a
reminder comment you can 'grep' for on the same line:

```perl
use Carp::Always; ### TODO: MyInitials: Remove before committing
```

Yes, it needs to have your initials on it, it's **your personal
responsibility** to remove this.



### Preventing mistakes

This low-key way of reminding yourself to not screw up may not be enough. After all, programmers are people, and people forget things and screw up all the time. You may even be one of them.

*If this turns out to be a problem for you* there are several approaches you can take, e.g. 

* Commit hooks in your source control system that prevents them to be checked in
* Automated test that looks through the source tree for any `use Carp::Always;` statements



### Ad-hoc Carp

Still worried about leaving in the use statements? You can also load the module on the command line with:

```
perl -MCarp::Always script.pl
prove -MCarp::Always -r t
```

just for that script invocation. Or, to make it semi permanent, set the PERL5OPT variable with this option:

```
export PERL5OPT=-MCarp::Always
perl script.pl
```


Remember: `Carp::Always`, but not all of the time!
Career Lessons Learned From Internship
Tags: discuss, work, programming, code
Published: 2018-10-23 16:33:48

---
title: Career Lessons Learned From Internship
published: true
description: lessons learned during intern
tags: discuss, work, programming, code
---


What are the lessons you actually got to learn during your intern period or maybe your very first programming job?

### What did I learn?
I actually got to learn was when you get stuck on a problem and you have no freaking idea to solve it whatsoever, just ask one of your senior. And don't just nod your head like you understand, but make yourself clear with the problem and get your art delivered. ;)
Top 5 DEV Comments from the Past Week
Tags: bestofdev
Published: 2018-10-23 14:48:10

---
title: Top 5 DEV Comments from the Past Week
published: true
description: Highlighting some of the best DEV comments from the past week.
tags: bestofdev
cover_image: https://res.cloudinary.com/practicaldev/image/fetch/s--7VrAA2ln--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://thepracticaldev.s3.amazonaws.com/i/qmb5wkoeywj06pd7p8ku.png
---

This is the second edition of a new weekly roundup which will surface awesome DEV comments that you may have missed.  You are welcome and encouraged to boost posts and comments yourself using the new **[#bestofdev](/t/bestofdev)** tag.

@miku86 starts things off with a quick tip in the **[Better console.logs](https://dev.to/wangonya/better-consolelogs-448c)** thread:
{% devcomment 68d0 %}

Next up we have @kayis who adds some quick thoughts regarding the **[12 Things Every Junior Developer Should Learn](https://dev.to/ben/12-things-every-junior-developer-should-learn-lco)**.  In short: learn "Keep it Stupid Simple" before "Don't Repeat Yourself." 
{% devcomment 67bn %}

In a thread asking for **[Thoughts on GitHub Actions?](https://dev.to/ben/thoughts-on-github-actions-5g1i)**, @kuhnerdm brings things back to GitHub's new corporate parent:
{% devcomment 67e7 %}

@citizen428 hops into the **[What types of features typically lead to lots of tech debt?](https://dev.to/ben/what-types-of-features-typically-lead-to-lots-of-tech-debt-p46)** discussion thread to discuss the term of "technical debt" itself:
{% devcomment 68d3 %}

Finally, @thecodetrane leaves a great comment in the post **[Developer is the next blue collar job](https://dev.to/stereobooster/developer-is-the-next-blue-collar-job-269b)**.  This discussion spanned 42 comments (so far) and the whole conversation is well worth your time.
{% devcomment 69pe %}

See you next week for more great comments ✌
Which units of measure do you use and why in CSS?
Tags: discuss, css, frontend
Published: 2018-10-23 14:37:23

---
title: Which units of measure do you use and why in CSS?
published: true
tags: discuss, css, frontend
canonical_url: https://www.iamdeveloper.com/posts/which-units-of-measure-do-you-use-and-why-in-css-nf4/
cover_image: https://thepracticaldev.s3.amazonaws.com/i/oxypyr6ze74fnkp5fgwt.png
---

I just opened an issue in the dev.to repo in regards to considering standardizing units of measure in the CSS part of the codebase. In a nutshell, I'm promoting the usage of `rem` (and `em` when necessary) like I use in my day to day at work as I'm sold on `rem`.

{%github https://github.com/thepracticaldev/dev.to/issues/987 %}

There are many articles that have discussed this in detail. A simple Google of "rem vs." will provide you with an abundance of articles.

![screenshot of a Google search on "rem vs."](https://thepracticaldev.s3.amazonaws.com/i/cr6f97fremx336vzba08.png)

I'm curious what everyone's thoughts are on this. Feel free to comment here as well as in the GitHub issue.
500 followers! What can I do to improve?
Tags: meta
Published: 2018-10-23 13:31:04

---
title: 500 followers! What can I do to improve?
published: true
description: 
tags: meta
---
I've been actively posting to dev.to over the last month and very quickly I've found myself here with 500 followers. Even though there isn't a lot of dialog yet, the likes and follows have been very encouraging. I feel so welcome here!

Thanks everybody for paying attention to my open source work. It helps me a lot since otherwise I'm making all this incremental progress all alone. I'll do it alone, of course, but it really helps my motivation to be getting any kind of feedback along the way.

I'd like to take this opportunity to get some feedback on my devlog posts themselves. You may have noticed there's a video with each one. I've been making these videos for a little bit longer than I've been posting here. They contain the meat of what I have to say since it's usually something to show. Pretty quickly I started writing the posts before making the video and using them as a rough script. 

Obviously I'd love to do more in-depth posts. I expect to when I have more finished projects to talk about. If there's anything else, though, what can I do to improve the content I'm putting here?

Thanks!
What is a tuple in C#?
Tags: webdev, beginners, backend, csharp
Published: 2018-10-23 13:21:22

---
title: What is a tuple in C#?
published: true
description: There's so many useful things in C# that it's hard to keep track of them all. Tuples are one of those things.
tags: #webdev, #beginners, #backend, #Csharp
---

This isn't something that most web developers know about because tuples aren't commonly used in web development. It's not because they aren't useful because they definitely can be. A tuple is just one of the many good things that gets buried under all of the other good things. So let's dig it up and polish it.

To start with, a tuple is a data structure that has a number of elements with different data types. An important thing to keep in mind is that a tuple is a reference type instead of a value type. That means it doesn't store the data in its own memory space. These store the location of where the data is in memory. Classes are a good example of how a reference type works with the memory.

Anyways, tuples are used in a few ways.

- When you want to hold some values temporarily without making a separate class. It can also be used to hold a database record.

- You can return multiple values from a method without needing the *out* or *ref* parameters.

- You can also pass multiple values to a method with just one parameter.

Now you've dug up what a tuple is, it's time to start polishing it. One thing that makes tuples distinct is that they are immutable. That means you can't change them at all once they have been created. Any properties in that tuple are going to be read-only. It also means that the size of the tuple is fixed after you create it.

There is some good news! In C# 7, tuples have been updated and made better. You don't have to worry about how many values your tuple has (originally, you could only have eight values in a tuple). You can also name your tuple properties instead of using the default super generic property names. And the best part is that all you have to do is install the System.ValueTuple NuGet package.

Hopefully this shed some light on one of the more obscure development tools available to you. Do you have any experience with tuples? Even I don't know a lot of people who do so I'd love to hear what you think in the comments.

<hr>

Hey! You should follow me on Twitter because reasons: https://twitter.com/FlippedCoding
State machine controller for Unity
Tags: gamedev, csharp, unity3d, opensource
Published: 2018-10-23 13:09:58

---
title: State machine controller for Unity
published: true
description: 
tags: gamedev,csharp,unity,opensource
---

On my free time I love to create game prototypes using C# in Unity. One of these prototypes is a turn-based game where I need to have multiple game states and a fine control over them.

I started working on a typical finite state machine (FSM) for controlling the game scenario and player input in different game modes, such as `battle` and `exploration`.

First the state machine looked something like this:

| StateMachine                 |
| ---------------------------- |
| StateExplorationUnitSelected |
| StateExplorationUnitMoving   |
| StateBattleUnitSelected      |
| StateBattleUnitMoving        |
| StateBattleSelectingSkill    |
| StateBattleCastingSkill      |

Immediately I started to stress about how bloated the single state machine would become as the codebase grows in size. This is when I divided it in two state machines:

| ExplorationStateMachine      | BattleStateMachine           |
| ---------------------------- | ---------------------------- |
| StateExplorationUnitSelected | StateBattleUnitSelected      |
| StateExplorationUnitMoving   | StateBattleUnitMoving        |
|                              | StateBattleSelectingSkill    |
|                              | StateBattleCastingSkill      |

After dividing the state machine in two, I wanted to have the ability to bundle related state machines together and allow their states to change the active state machine based on what happens in the game world. For example if player encounters an enemy in `StateExplorationMoving` - that state can call `ChangeStateMachine(BattleStateMachine);`

I created a parent state machine class that can hold a collection of child state machines:

| PlayerStateMachine           |
| ---------------------------- |
| ExplorationStateMachine      |
| BattleStateMachine           |

In the above table `PlayerStateMachine` is a parent state machine for controlling child state machines. `ExplorationStateMachine` and `BattleStateMachine` can be considered as the states of the `PlayerStateMachine`.

After having this structure in place, I created a StateMachineController class that holds a list of parent state machines and runs their update methods.

 ![StateMachineController.cs](https://i.imgur.com/W9V6xEA.png)

I extracted the code from my prototype and started editing it to be more generic. You are free to use it for your own Unity projects if you want - and feel free to create a pull request if you have ideas to make it better. The project can be found from [GitHub](https://github.com/jushii/StateMachineController).
gitlab runner error: No such image
Tags: gitlab, runner
Published: 2018-10-23 12:06:58

---
title: gitlab runner error: No such image
published: true
description: 'a possible reason for the error "ERROR: Preparation failed: Error: No such image:" with a gitlab runner'
tags: #gitlab, #runner
cover_image: https://thepracticaldev.s3.amazonaws.com/i/u402yekhjmkc01lcswf9.jpeg
---
if you run your own gitlab runner and you get the error message `ERROR: Preparation failed: Error: No such image: mariadb:10.1 (executor_docker.go:175:0s)` it can have multiple reasons.

sometimes the solution really can be very easy. in my case the error message was not really helpful but the soltuion was quickly to find. **the server ran out of harddisk space**, which can happen if you use lvm with extra small partitions like me.

```
ERROR: Preparation failed: Error: No such image: mariadb:10.1 (executor_docker.go:175:0s)
Will be retried in 3s ...
Using Docker executor with image c33s/php:7.1 ...
Starting service mariadb:10.1 ...
Pulling docker image mariadb:10.1 ...
ERROR: Preparation failed: Error: No such image: mariadb:10.1 (executor_docker.go:175:0s)
Will be retried in 3s ...
Using Docker executor with image c33s/php:7.1 ...
Starting service mariadb:10.1 ...
Pulling docker image mariadb:10.1 ...
ERROR: Preparation failed: Error: No such image: mariadb:10.1 (executor_docker.go:175:0s)
Will be retried in 3s ...
ERROR: Job failed (system failure): Error: No such image: mariadb:10.1 (executor_docker.go:175:0s)
```

links: 
- cover image by Viktoria Goda https://www.pexels.com/photo/blue-red-and-yellow-chalk-1107495/