teleren/devto huggingface dataset:
Hey, post a selfie! Show yourself!
Tags: ruby, rails
Published: 2020-01-05 23:52:30

<h3><center>WERQBOOK - Pt. 1</center></h3>
*********************************************************

I've seen some interest in a feature within one of my earlier apps called [WERQBOOK](https://github.com/JaredHarbison/WerqBook)- a chat app with some simple but really important features like time stamps, real-time updates, and image posting. It's the image posting that sparks the most interest. Rails made it so easy!

*********************************************************
<h1><center> Let's get started! </center></h1>
*********************************************************

I ran `gem install carrierwave fog mini_magick && bundle install` to get started. CarrierWave allowed access `rails generate uploader Picture` to create an image uploader. The images were to be uploaded into user posts, so I ran `rails generate migration add_picture_to_microposts picture:string && rails db:migrate` to add image strings to the existing schema. The generator added `mount_uploader :picture, PictureUploader` to the [micropost.rb](https://github.com/JaredHarbison/WerqBook/blob/master/app/models/micropost.rb) file. Then I needed to update the private micropost_params method in [micropost_controller.rb](https://github.com/JaredHarbison/WerqBook/blob/master/app/controllers/microposts_controller.rb) to "permit" `:picture`.

I added an image_tag to the [_micropost_form.html.erb](https://github.com/JaredHarbison/WerqBook/blob/master/app/views/microposts/_micropost.html.erb) partial to prompt image uploads. 
```
<span class="content">
  <%= micropost.content %>
  <%= image_tag micropost.picture.url if micropost.picture? %>
</span>
``` 

For some image validation I added a simple method into the [picture_uploader.rb](https://github.com/JaredHarbison/WerqBook/blob/master/app/uploaders/picture_uploader.rb) file. 
``` 
def extension_whitelist 
  %w(jpg jpeg gif png) 
end 
```

I added another validation in [micropost.rb](https://github.com/JaredHarbison/WerqBook/blob/master/app/models/micropost.rb) through `validate :picture_size` and a private picture_size method
```
def picture_size 
  if picture.size > 5.megabytes
    errors.add(:picture, "should be less than 5MB")
  end 
end
```

Images could be posted of any size, potentially ruining the layout of the application. I found I needed to `brew install imagemagick` into my development environment. The MiniMagick documentation was pretty good, which I followed to add the following into the [picture_uploader.rb](https://github.com/JaredHarbison/WerqBook/blob/master/app/uploaders/picture_uploader.rb) file. 
```
include CarrierWave::MiniMagick 
process resize_to_limit: [400, 400]
```

Finally I updated [picture_uploader.rb](https://github.com/JaredHarbison/WerqBook/blob/master/app/uploaders/picture_uploader.rb) for production storage with 
``` 
if Rails.env.production? 
  storage :fog 
else 
  storage :file
end
```

*********************************************************
<h1><center> That's all folks! </center></h1>
A year in review, what's coming 📆
Tags: goals, review, freshstart
Published: 2020-01-05 23:47:34

I am back from a well deserved holiday and thought first thing first, I should review the last year and set some goals for the new one to be able to focus my energy to the right direction and learn from any mistake or missed opportunities.


## A review on 2019

Last year was a super hectic year for me personally. I was working a full time consultancy job, advancing in my public speaking journey (more on this later), kicking some goals and missing others. All in all, it was a year with some 'wow great' and some 'oh boy' moments.

But let me start with the good parts first:

* Learnt so many new topics and concepts.
* Spoke at 8 major conferences and 7 meetups.
* Got promoted to lead consultant.
* Published 38 blog post.
* Restarted going to gym two to three times a week.
* Started on [Dev.to](https://dev.to) and reached 15K followers, 170K post views, 6.5K reactions.
* Published two _npm_ packages.
* Contributed to _Open Source_.
* Read 60 books 🤯 (technical and non-technical).
* Finished 10 side projects.
* Met so many amazing people and made new friends.
* And finished up with a position as a developer advocate for TelstraDev.

It was so good and I couldn't believe what a little motivation could do.

However, this came with a cost, I felt nearly burnt down and exhausted from all of these activities, so I reduced them towards the end of the year and gave myself some time to recover. I didn't touch Twitter (apart from posting some photos of my woodworking), didn't check LinkedIn, read some books, restarted woodworking, enjoyed doing nothing basically.

I don't want to go through too much detail, overall it was a great year.

## 2020, where to?

Starting 2020 for me was a with mixed feelings. I wanted to fix some errors I made last year, but at the same time I had to take some tough decisions. So here are my 2020 goals:

* Be a better person.
* Read more books.
* Publish more targeted blog posts.
* Take good care of my body and mind.
* Learn more, listen more, talk less.
* Continue public speaking, but be more selective, get more invitation, maybe a keynote/locknote, help others get started.
* Be a caring and mindful advocate for developers out there.
* Continue woodworking, spend more time with family, and spend less of weekends on technical subjects to balance lifestyle.
* Be more productive by sleeping more, eating healthy food, and more exercise.
* Make new friends, surround myself with good people.
* And a nice to have one is to start a video podcast on web and front end.

This list is not a far fetched list, it's a carefully drafted one based on last year's review and feedback.

And I am so grateful for the support I've received by all of you. Keep your positive energy coming and stay tuned for some quality content coming up.
Generators and Iterators Course Published!
Tags: javascript, pluralsight
Published: 2020-01-05 23:00:49

Cover Photo by Cedric Letsch on Unsplash

New Year, new Pluralsight course! 🎉[Javascript Generators and Iterators](https://pluralsight.pxf.io/dgjQq) has just published on Pluralsight 🎉. In this course, I will teach you about generator functions, iterators, and iterables. Ever wonder why `for..of` loops work over strings and arrays, but not objects? Have you used Redux-Sagas in your React app and would like to know what the `yield` keyword was doing in your code and how it relates to generators? Check out my course to learn all about it.

## Generator Functions

![code sample of a generator function](https://thepracticaldev.s3.amazonaws.com/i/m5abcsgvsj4g4ju8mwlr.gif)

## Custom Iterators

![code sample of a custom iterator](https://thepracticaldev.s3.amazonaws.com/i/2hw3hk0xm4ywiss9jgb5.gif)
A Tour of the High Voltage Gem – Ruby on Rails
Tags: ruby, rails, webdev, tutorial
Published: 2020-01-26 03:35:57

---
title: A Tour of the High Voltage Gem – Ruby on Rails
published: true
date: 2020-01-05 22:42:49 UTC
tags: ruby, rails, web dev, tutorial
canonical_url: https://web-crunch.com/a-tour-of-the-high-voltage-gem-ruby-on-rails/
---

The [High Voltage gem](https://github.com/thoughtbot/high_voltage) is one of my favorite no-nonsense Ruby gems that gets you moving quickly when the need for static pages arise in your Rails app.

I recently published [a list of some of my favorite Ruby gems](https://dev.to/justalever/some-of-my-favorite-ruby-gems-3ji0) but forgot to include this one. Doh!

{% youtube GJkFIORRdgo %}

Nearly any Ruby on Rails application I’ve built has needed some form of generic page. Doing this is very possible with a basic controller, views, and routing but the High Voltage gem is even easier. Simply add the gem to your `Gemfile`, run bundle install, create some templates within `app/views/pages` and you’re off to the races.

The best part is that there are no routing patterns to remember or much configuration at all. By default the URL structure of the High Voltage gem uses `/pages/your-page-name`. While that works perfectly I often reach for a configuration that rids of the `/pages` URL structure. To do that you can add an initializer to your app with the following:

```ruby
# config/initializers/high_voltage.rb

HighVoltage.configure do |config|
  config.route_drawer = HighVoltage::RouteDrawers::Root
end

```

And with that setting, you can turn `/pages/about` into `/about`.

Making static pages is a breeze with this gem. There is even documentation available explaining how to customize it even further as well as keep an up to date sitemap for more enhanced SEO. I invite you to take it for a test drive and see what you think!

The post [A Tour of the High Voltage Gem – Ruby on Rails](https://web-crunch.com/a-tour-of-the-high-voltage-gem-ruby-on-rails/) appeared first on [Web-Crunch](https://web-crunch.com).
Doctrine simple event listener are not Interface compatible
Tags: php, symfony, doctrine
Published: 2020-01-05 22:28:02

---
title: Doctrine simple event listener are not Interface compatible
published: true
description: 
tags: #php, #symfony, #doctrine
---

the old way of defining event listener for doctine was like this:

`service.yaml`:
```yaml
C33s\Doctrine\Listener\Entity\InjectFeatureManagerListener:
    tags:
        - { name: doctrine.event_listener, event: postLoad, connection: default, priority: 0 }
```

where the listener look like that:
```php
class InjectFeatureManagerListener
{
    /**
     * @var FeatureManagerInterface
     */
    protected $featureManager;

    /**
     * @param FeatureManagerInterface $featureManager
     *
     */
    public function __construct(FeatureManagerInterface $featureManager)
    {
        $this->featureManager = $featureManager;
    }

    public function postLoad(LifecycleEventArgs $args)
    {
        $entity = $args->getEntity();
        if ($entity instanceof FeatureFlagable) {
            $entity->setFeatureFlagManager($this->featureManager);
        }
    }
}
```

btw. don't do that. don't inject stuff into your entity. its a bad practice.

this way the listener is called for each entity and each entity is checked against the `FeatureFlagable` interface. so i have the nice feature of injecting the feature manager in each entity which implements the `FeatureFlagable` interface no matter which entity it is.

with the new way to define the listener https://symfony.com/blog/new-in-symfony-4-4-simpler-event-listeners its getting shorter but is incompatible with interfaces:

the following config will not work because no entity with the name `FeatureFlagable` exists.

`service.yaml`
```yaml
C33s\Doctrine\Listener\Entity\InjectFeatureManagerListener:
    tags:
        - { name: doctrine.orm.entity_listener, event: postLoad, entity: C33s\Doctrine\Entity\Interfaces\FeatureFlagable, connection: default, priority: 0, lazy: true }

```
changing the code by adding the explicit entity name `App\Entity\News`

```yaml
...
        - { name: doctrine.orm.entity_listener, event: postLoad, entity: App\Entity\News, connection: default, priority: 0, lazy: true }
...
```
make it work again but i would need to tag all my entities manually even if they are already "marked"/"tagged" with the `FeatureFlagable` interface.


i haven't digged too deep into the doctrine event listener code just came to `vendor/doctrine/doctrine-bundle/DependencyInjection/Compiler/EntityListenerPass.php`. maybe its an easyfix. would be nice to be able to use interfaces again.
Upgrading to Ubuntu 18.04 from Ubuntu 16.04 LTS Server
Tags: ubuntu, upgrade, update, linux
Published: 2020-01-05 22:17:25

## Introduction: Upgrading to Ubuntu 18.04 LTS
Ubuntu 16.04 LTS Server can be upgraded to the new Ubuntu release 18.04 Bionic Beaver with the steps provided in this post. Those who will like to try the new Ubuntu 18.04 LTS can also use this post to upgrade their Ubuntu version to Ubuntu 18.04 LTS development release.

Ubuntu 18.04 LTS has been released on April 26th, 2018 as planned and it will be supported for  5 years. To enjoy the new ubuntu associated with it, you will have to upgrade to this version of Ubuntu.

You can easily upgrade from Ubuntu 16.04 LTS to 18.04 LTS, even though 17.04 or 17.10 are not LTS version we can also upgrade to those as well.
### Step One: Update Ubuntu 16.04 LTS
It is recommended that you update your current version of the Ubuntu Server before proceeding with any of the steps in this post. To update Ubuntu use the following commands below:
```
sudo apt update && sudo apt upgrade && sudo apt dist-upgrade && sudo apt autoremove
```
### Step Two: Install Ubuntu Update Manager
You probably have Ubuntu Update Manager installed on your machine but if you don’t have then the following commands will be helpful for you.
```
sudo apt-get install update-manager-core
```
After installing update-manager, we need to make sure that the update-manager is configured for Long-term support (LTS). So make sure Prompt is set to lts. Then check with the following command:
```
sudo nano /etc/update-manager/release-upgrades
```
Ensure that Prompt equaled lts.
```
Prompt=lts
```
### Step Three: Upgrade to Ubuntu 18.04 LTS
Now, we can be sure that our system is ready for the upgrade. To begin, run the command below to upgrade your Ubuntu to the latest development release.
```
sudo do-release-upgrade -d
```
Follow the upgrade wizard on your screen and answer the questions asked. When asked whether you wish to upgrade type y for yes.

This might take some time depending on your internet speed. New packages will be installed and you will be prompted to remove obsolete packages. Type y to remove obsolete packages.

Wait for the installation to be complete and when prompt to restart type ``y`` to finish the installation and reboot the computer.

Your system should be upgraded to the latest ubuntu, Ubuntu 18.04 LTS.

According to Ubuntu wiki the support lifespan of Ubuntu 18.04 LTS :

> The ‘main’ archive of Ubuntu 18.04 LTS will be supported for 5 years until April 2023. Ubuntu 18.04 LTS will be supported for 5 years for Ubuntu Desktop, Ubuntu Server, and Ubuntu Core. Ubuntu Studio 18.04 will be supported for 9 months. All other flavors will be supported for 3 years. [ubuntu wiki](https://wiki.ubuntu.com/BionicBeaver/ReleaseNotes#Upgrading_from_Ubuntu_16.04_LTS_or_17.10)

### Conclusion
Now that you have completed the steps to upgrading your Ubuntu, you should notice that your login screen is different. The system may switch automatically from Unity to Gnome for you. Depending on your choices during the Ubuntu distribution upgrade, the system may automatically make the switch from Unity to GNOME for you.
Hugo & Dev.to workflow
Tags: blogging, hugo, devto
Published: 2020-01-05 22:08:35

How do you go about minimizing issues with writing your blog posts for hugo so that you can cross post to dev.to without lots of formatting/editing work?

I use hugo and it supports shortcodes to allow you to format items like gists, images, and so on with a code like `{{% gist 1234 %}}` so you simplify your markdown syntax to avoid lots of direct embedded html. Callouts, images, and other shortcuts exist. 

This is problematic when importing into dev.to and some other platforms I've noticed. For example my images sometimes aren't there and my embedded gists are just gone.  Static image resources from project also use path based on directory (relative) so dev.to doesn't show them. 

I'm considering possibility of using Stackbit too, but it's a lot of work to convert existing site so it's a future consideration, not active. 

Any hugo pros have some secrets they can share? 

My current blogging workflow has been modified to write my post in Notion, and then export as markdown to put in my repo once I'm ready. I want easy offline editing/autosave access, and this is the best way I've found to reduce overhead to tweaking posts.
It's okay to say "Yes"
Tags: motivation, risk, development
Published: 2020-01-05 21:58:19

---
title: It's okay to say "Yes"
published: true
description: 
tags: motivation, risk, development
---

I would never have come to believe it was true, but going forward I realized you do not need to know everything from before. Some things are just meant to be figured out and it's okay to say “Yes” even if you do not know everything about how it will be done.

While I was in college I used to freelance a lot and do a lot of projects. Trust me, most of the projects I said yes to were something I never had heard of before. That has helped me in learning so much that I wouldn’t have, had I not said yes.  Sometimes it’s just about taking that extra step.

In a hindsight, I came to believe and even now that there is a difference between what you can do and what you are not familiar with but can do it if you do your homework. 

As a developer, if you wait for an opportunity to adapt to your expectations, you will never test your boundaries.

There might be a case you might not be able to deliver it completely but I’m sure that is better than not attempting it at first.
Parallels, VMWare Fusion, VirtualBox or Another?
Tags: discuss, macos, virtualmachine
Published: 2020-01-05 20:39:24

My new MBP is on its way and I'm wondering what everyone is using these days in regards to a VM for Windows on a Mac.

In the past I've had VMWare Fusion and it seemed decent. I've also been using VirtualBox at work and that seems to have been fine as well.

I'm fine with upgrading my VMWare Fusion or buying Parallels, I'm just wondering what everyone else is running on a Mac these days.

![A Will Ferell SNL character saying "Heck, I'm curious like a cat!"](https://media.giphy.com/media/5nOfj9kFKN6Ss/giphy.gif)
Do you want to start a blog? Here is a checklist for you
Published: 2020-01-05 20:11:03


Follow the below given checklist if you want to start blogging and become popular

1. Choose niche wisely

2. Know Your Audience – find out your ideal customers – find out where they hang – find out their problems and offer solutions – interact with them, answer their questions

3. Serve & Help Your Audience – write valuable content – promote right products – address their questions

4. Show Persistence – be a doer – striking balance between learning and doing – dont give up easily – dont get distracted (there may be many distractions coming your way

Presented by http://tossingcoins.com
How to start solving problems ?
Tags: beginners, codequality, codenewbie, webdev
Published: 2020-01-05 19:54:07

##We are coders. What we do whole day ?

![how i code](https://media2.giphy.com/media/rMS1sUPhv95f2/giphy.gif?cid=790b7611a54796bb3483375cb85a033539d993fd7361be2c&rid=giphy.gif)
<figcaption>What I thought when I code (giphy)</figcaption>

Solve the problems!

![problemSolving](https://media3.giphy.com/media/5z0cCCGooBQUtejM4v/giphy.gif?cid=790b7611086ce3d66f8eeba778cb0c67d8e228968b6f1bfb&rid=giphy.gif)

First, get into mindset to solving problem.

![mindset](https://media3.giphy.com/media/fjyG5huNIBaB2Ppik5/giphy.gif?cid=790b7611aabcbb5017b5b5cff51e6b36b719d48964f298d9&rid=giphy.gif)
<figcaption>mindset to solve anything (giphy)</figcaption>

###Now how to solve a problem?

We need to learn a programming language for the solving a problem.
- Focus on data structures
- Work on algorithms
- Test properly your code, or there can be bugs

This is how you can solve a problem a problem. Programming languages can be learn anytime, but if you are not good with problem solving, then sure you’ll fall someday! Keep working on your problem solving skills. Practice more will help you the best.

###Just start creating or you’ll just think “I wish!”


You can see the graphical version here
{% instagram B68vvMoAiLX %}

Originally it published on [nerdjfpbblog](https://blog.nerdjfpb.com/how-to-start-solving-problems/). You can connect with me in [twitter](https://twitter.com/nerdjfpb) or [linkedin](https://www.linkedin.com/in/nerdjfpb/) !
Bash Script: Knex Database Refresh
Tags: bash, productivity, node, database
Published: 2020-01-05 19:47:27

Ever get tired of running the same knex commands every time you need to reset your database? Why not just make a bash script that will run them all in one command?

#### It's super simple and easy

```bash
#!/bin/bash

knex migrate:rollback
knex migrate:latest
knex seed:run
```

I named mine `dbrefresh` so now anytime I need my database to be reset all I need to do is type `dbrefresh` inside my terminal and it will rollback, magrate latest and run my seeds in one sweet and easy command. 

Thank you very much for reading! Do you have any bash scripts that you use everyday? I've love to see them in the comments below!
The risk of unprotected private keys (orbjet.org)
Tags: bash, privacy, encryption, linux
Published: 2020-01-05 19:33:56

There have been numerous occations where I’ve heard the following expression: “…yeah my stuff is safe on my computer, no need to have additional encryption, or special administrative accounts…”.

Well yeah, sure, if you say so.

Let that sink in as a intro. An old laptop I was using for testing stopped working and wouldn’t start anymore. So I decided to take out the disk and retrieve the data I had laying in there. For everyone else, getting data out would be impossible. For me, the good thing was that I had Linux running on it and the disk was encrypted with LUKS (Linux Unified Key Setup), meaning that only I, with the decryption password, could access the enclosing data (by no means I consider myself as a cryptography expert, I just use common sense and best practices).

While copying some files, I remembered that I had an ssh key setup for accessing a VPS I used for testing. In that moment, an interesting idea popped into my head! 

..the post continues on the original site [orbjet.org](https://www.orbjet.org/post/2020-01-05/the-risk-of-unprotected-private-keys/)